use of org.apache.jackrabbit.core.PropertyImpl in project jackrabbit by apache.
the class ImpersonationImpl method updateImpersonatorNames.
private void updateImpersonatorNames(Set<String> principalNames) throws RepositoryException {
NodeImpl userNode = user.getNode();
try {
String[] pNames = principalNames.toArray(new String[principalNames.size()]);
if (pNames.length == 0) {
PropertyImpl prop = userNode.getProperty(P_IMPERSONATORS);
userManager.removeProtectedItem(prop, userNode);
} else {
Value[] values = new Value[pNames.length];
for (int i = 0; i < pNames.length; i++) {
values[i] = new StringValue(pNames[i]);
}
userManager.setProtectedProperty(userNode, P_IMPERSONATORS, values);
}
} catch (RepositoryException e) {
// revert pending changes
userNode.refresh(false);
throw e;
}
}
use of org.apache.jackrabbit.core.PropertyImpl in project jackrabbit by apache.
the class RetentionRegistryImpl method onEvent.
//-------------------------------------------< SynchronousEventListener >---
/**
* @param events Events reporting hold/retention policy changes.
*/
public void onEvent(EventIterator events) {
while (events.hasNext()) {
Event ev = events.nextEvent();
try {
Path evPath = session.getQPath(ev.getPath());
Path nodePath = evPath.getAncestor(1);
Name propName = evPath.getName();
if (RetentionManagerImpl.REP_HOLD.equals(propName)) {
// hold changes
switch(ev.getType()) {
case Event.PROPERTY_ADDED:
case Event.PROPERTY_CHANGED:
// build the Hold objects from the rep:hold property
// and put them into the hold map.
PropertyImpl p = (PropertyImpl) session.getProperty(ev.getPath());
addHolds(nodePath, p);
break;
case Event.PROPERTY_REMOVED:
// all holds present on this node were remove
// -> remove the corresponding entry in the holdMap.
removeHolds(nodePath);
break;
}
} else if (RetentionManagerImpl.REP_RETENTION_POLICY.equals(propName)) {
// retention policy changes
switch(ev.getType()) {
case Event.PROPERTY_ADDED:
case Event.PROPERTY_CHANGED:
// build the RetentionPolicy objects from the rep:retentionPolicy property
// and put it into the retentionMap.
PropertyImpl p = (PropertyImpl) session.getProperty(ev.getPath());
addRetentionPolicy(nodePath, p);
break;
case Event.PROPERTY_REMOVED:
// retention policy present on this node was remove
// -> remove the corresponding entry in the retentionMap.
removeRetentionPolicy(nodePath);
break;
}
}
// else: not interested in any other property -> ignore.
} catch (RepositoryException e) {
log.warn("Internal error while processing event. {}", e.getMessage());
// ignore.
}
}
}
use of org.apache.jackrabbit.core.PropertyImpl in project jackrabbit by apache.
the class RetentionRegistryImpl method readRetentionFile.
/**
* Read the file system resource containing the node ids of those nodes
* contain holds/retention policies and populate the 2 path maps.
*
* If an entry in the retention file doesn't have a corresponding entry
* (either rep:hold property or rep:retentionPolicy property at the
* node identified by the node id entry) or doesn't correspond to an existing
* node, that entry will be ignored. Upon {@link #close()} of this
* manager, the file will be updated to reflect the actual set of holds/
* retentions present and effective in the content.
*
* @throws IOException
* @throws FileSystemException
*/
private void readRetentionFile() throws IOException, FileSystemException {
if (retentionFile.exists()) {
BufferedReader reader = null;
try {
reader = new BufferedReader(new InputStreamReader(retentionFile.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
NodeId nodeId = NodeId.valueOf(line);
try {
NodeImpl node = (NodeImpl) session.getItemManager().getItem(nodeId);
Path nodePath = node.getPrimaryPath();
if (node.hasProperty(RetentionManagerImpl.REP_HOLD)) {
PropertyImpl prop = node.getProperty(RetentionManagerImpl.REP_HOLD);
addHolds(nodePath, prop);
}
if (node.hasProperty(RetentionManagerImpl.REP_RETENTION_POLICY)) {
PropertyImpl prop = node.getProperty(RetentionManagerImpl.REP_RETENTION_POLICY);
addRetentionPolicy(nodePath, prop);
}
} catch (RepositoryException e) {
// node doesn't exist any more or hold/retention has been removed.
// ignore. upon close() the file will not contain the given nodeId
// any more.
log.warn("Unable to read retention policy / holds from node '" + nodeId + "': " + e.getMessage());
}
}
} finally {
IOUtils.closeQuietly(reader);
}
}
}
use of org.apache.jackrabbit.core.PropertyImpl in project jackrabbit by apache.
the class AuthorizableImplTest method testGroupGetProperties.
public void testGroupGetProperties() throws RepositoryException, NotExecutableException {
AuthorizableImpl group = (AuthorizableImpl) getTestGroup(superuser);
NodeImpl n = group.getNode();
for (PropertyIterator it = n.getProperties(); it.hasNext(); ) {
PropertyImpl p = (PropertyImpl) it.nextProperty();
if (p.getDefinition().isProtected()) {
assertFalse(group.hasProperty(p.getName()));
assertNull(group.getProperty(p.getName()));
} else {
// authorizable defined property
assertTrue(group.hasProperty(p.getName()));
assertNotNull(group.getProperty(p.getName()));
}
}
}
use of org.apache.jackrabbit.core.PropertyImpl in project jackrabbit by apache.
the class MembershipCache method isMemberOfNodeBaseMembershipGroup.
/**
* traverses the group structure of a node-based group to check if the given authorizable is member of this group.
*
* @param authorizableNodeIdentifier Identifier of the authorizable node
* @param groupId if of the group
* @param nIds output set to update of group node ids that were found via the node memberships
* @param node the node to traverse
* @throws RepositoryException if an error occurs
*/
private void isMemberOfNodeBaseMembershipGroup(String authorizableNodeIdentifier, String groupId, Set<String> nIds, NodeImpl node) throws RepositoryException {
PropertyIterator pIter = node.getProperties();
while (pIter.hasNext()) {
PropertyImpl p = (PropertyImpl) pIter.nextProperty();
if (p.getType() == PropertyType.WEAKREFERENCE) {
Value[] values = p.isMultiple() ? p.getValues() : new Value[] { p.getValue() };
for (Value v : values) {
if (v.getString().equals(authorizableNodeIdentifier)) {
nIds.add(groupId);
return;
}
}
}
}
NodeIterator iter = node.getNodes();
while (iter.hasNext()) {
NodeImpl child = (NodeImpl) iter.nextNode();
if (child.isNodeType(NT_REP_MEMBERS)) {
isMemberOfNodeBaseMembershipGroup(authorizableNodeIdentifier, groupId, nIds, child);
}
}
}
Aggregations