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 UserImpl method disable.
/**
* @see User#disable(String)
*/
public void disable(String reason) throws RepositoryException {
if (isAdmin()) {
throw new RepositoryException("The administrator user cannot be disabled.");
}
if (reason == null) {
if (isDisabled()) {
// enable the user again.
PropertyImpl disableProp = getNode().getProperty(P_DISABLED);
userManager.removeProtectedItem(disableProp, getNode());
}
// else: nothing to do.
} else {
Value v = getSession().getValueFactory().createValue(reason);
userManager.setProtectedProperty(getNode(), P_DISABLED, v);
}
}
use of org.apache.jackrabbit.core.PropertyImpl in project jackrabbit by apache.
the class AuthorizableImplTest method testUserGetProperties.
public void testUserGetProperties() throws RepositoryException, NotExecutableException {
AuthorizableImpl user = (AuthorizableImpl) getTestUser(superuser);
NodeImpl n = user.getNode();
for (PropertyIterator it = n.getProperties(); it.hasNext(); ) {
PropertyImpl p = (PropertyImpl) it.nextProperty();
if (p.getDefinition().isProtected()) {
assertFalse(user.hasProperty(p.getName()));
assertNull(user.getProperty(p.getName()));
} else {
// authorizable defined property
assertTrue(user.hasProperty(p.getName()));
assertNotNull(user.getProperty(p.getName()));
}
}
}
use of org.apache.jackrabbit.core.PropertyImpl in project jackrabbit by apache.
the class RetentionManagerImpl method removeHold.
/**
* @see RetentionManager#removeHold(String, Hold)
*/
public void removeHold(String absPath, Hold hold) throws PathNotFoundException, AccessDeniedException, LockException, VersionException, RepositoryException {
NodeImpl n = (NodeImpl) session.getNode(absPath);
if (hold instanceof HoldImpl && n.getNodeId().equals(((HoldImpl) hold).getNodeId()) && n.isNodeType(REP_RETENTION_MANAGEABLE) && n.hasProperty(REP_HOLD)) {
PropertyImpl p = n.getProperty(REP_HOLD);
Value[] vls = p.getValues();
List<Value> newValues = new ArrayList<Value>(vls.length - 1);
for (Value v : vls) {
if (!hold.equals(HoldImpl.createFromValue(v, n.getNodeId(), session))) {
newValues.add(v);
}
}
if (newValues.size() < vls.length) {
if (newValues.size() == 0) {
removeItem(p);
} else {
setProperty(n, REP_HOLD, newValues.toArray(new Value[newValues.size()]));
}
} else {
// no matching hold.
throw new RepositoryException("Cannot remove '" + hold.getName() + "' at " + absPath + ".");
}
} else {
// invalid hold or no hold at absPath
throw new RepositoryException("Cannot remove '" + hold.getName() + "' at " + absPath + ".");
}
}
use of org.apache.jackrabbit.core.PropertyImpl in project jackrabbit by apache.
the class VirtualNodeTypeStateManager method recursiveAdd.
/**
* Adds a subtree of itemstates as 'added' to a list of events
*
* @param events
* @param parent
* @param node
* @throws RepositoryException
*/
private void recursiveAdd(List<EventState> events, NodeImpl parent, NodeImpl node) throws RepositoryException {
events.add(EventState.childNodeAdded(parent.getNodeId(), parent.getPrimaryPath(), node.getNodeId(), node.getPrimaryPath().getLastElement(), ((NodeTypeImpl) parent.getPrimaryNodeType()).getQName(), parent.getMixinTypeNames(), node.getSession()));
PropertyIterator iter = node.getProperties();
while (iter.hasNext()) {
PropertyImpl prop = (PropertyImpl) iter.nextProperty();
events.add(EventState.propertyAdded((NodeId) node.getId(), node.getPrimaryPath(), prop.getPrimaryPath().getLastElement(), ((NodeTypeImpl) node.getPrimaryNodeType()).getQName(), node.getMixinTypeNames(), node.getSession()));
}
NodeIterator niter = node.getNodes();
while (niter.hasNext()) {
NodeImpl n = (NodeImpl) niter.nextNode();
recursiveAdd(events, node, n);
}
}
Aggregations