try
{
InternalQName qname = InternalQName.parse(cname);
QPath qpath;
String parentCid;
if (parentPath != null)
{
// get by parent and name
qpath = QPath.makeChildPath(parentPath, qname, cindex);
parentCid = cpid;
}
else
{
// get by id
if (cpid.equals(Constants.ROOT_PARENT_UUID))
{
// root node
qpath = Constants.ROOT_PATH;
parentCid = null;
}
else
{
qpath = QPath.makeChildPath(traverseQPath(cpid), qname, cindex);
parentCid = cpid;
}
}
// PRIMARY
ResultSet ptProp = findPropertyByName(cid, Constants.JCR_PRIMARYTYPE.getAsString());
try
{
if (!ptProp.next())
throw new PrimaryTypeNotFoundException("FATAL ERROR primary type record not found. Node "
+ qpath.getAsString() + ", id " + cid + ", container " + this.containerName, null);
byte[] data = ptProp.getBytes(COLUMN_VDATA);
InternalQName ptName = InternalQName.parse(new String((data != null ? data : new byte[]{})));
// MIXIN
MixinInfo mixins = readMixins(cid);
// ACL
AccessControlList acl; // NO DEFAULT values!
if (mixins.hasOwneable())
{
// has own owner
if (mixins.hasPrivilegeable())
{
// and permissions
acl = new AccessControlList(readACLOwner(cid), readACLPermisions(cid));
}
else if (parentACL != null)
{
// use permissions from existed parent
acl =
new AccessControlList(readACLOwner(cid), parentACL.hasPermissions()
? parentACL.getPermissionEntries() : null);
}
else
{
// have to search nearest ancestor permissions in ACL manager
// acl = new AccessControlList(readACLOwner(cid), traverseACLPermissions(cpid));
acl = new AccessControlList(readACLOwner(cid), null);
}
}
else if (mixins.hasPrivilegeable())
{
// has own permissions
if (mixins.hasOwneable())
{
// and owner
acl = new AccessControlList(readACLOwner(cid), readACLPermisions(cid));
}
else if (parentACL != null)
{
// use owner from existed parent
acl = new AccessControlList(parentACL.getOwner(), readACLPermisions(cid));
}
else
{
// have to search nearest ancestor owner in ACL manager
// acl = new AccessControlList(traverseACLOwner(cpid), readACLPermisions(cid));
acl = new AccessControlList(null, readACLPermisions(cid));
}
}
else
{
if (parentACL != null)
// construct ACL from existed parent ACL
acl =
new AccessControlList(parentACL.getOwner(), parentACL.hasPermissions()
? parentACL.getPermissionEntries() : null);
else
// have to search nearest ancestor owner and permissions in ACL manager
// acl = traverseACL(cpid);
acl = null;
}
return new PersistedNodeData(getIdentifier(cid), qpath, getIdentifier(parentCid), cversion, cnordernumb,
ptName, mixins.mixinNames(), acl);
}
catch (IllegalACLException e)
{
throw new RepositoryException("FATAL ERROR Node " + getIdentifier(cid) + " " + qpath.getAsString()
+ " has wrong formed ACL. ", e);
}
finally
{
try