use of javax.jcr.UnsupportedRepositoryOperationException in project jackrabbit by apache.
the class AuthorizableActionTest method testAccessControlAction.
public void testAccessControlAction() throws Exception {
AccessControlAction action = new AccessControlAction();
action.setUserPrivilegeNames("jcr:all");
action.setGroupPrivilegeNames("jcr:read");
User u = null;
Group gr = null;
try {
setActions(action);
String uid = getTestPrincipal().getName();
u = impl.createUser(uid, buildPassword(uid));
save(superuser);
assertAcAction(u, impl);
String grId = getTestPrincipal().getName();
gr = impl.createGroup(grId);
save(superuser);
assertAcAction(gr, impl);
} catch (UnsupportedRepositoryOperationException e) {
throw new NotExecutableException(e.getMessage());
} finally {
if (u != null) {
u.remove();
}
if (gr != null) {
gr.remove();
}
save(superuser);
}
}
use of javax.jcr.UnsupportedRepositoryOperationException in project jackrabbit by apache.
the class ValueFactoryTest method setUp.
public void setUp() throws Exception {
super.setUp();
session = getHelper().getReadWriteSession();
try {
valueFactory = session.getValueFactory();
} catch (UnsupportedRepositoryOperationException e) {
String message = "ValueFactory Test not executable: " + e.getMessage();
throw new NotExecutableException(message);
}
//notReferenceableNode = getProperty(not_ReferenceableNode);
nameValue = testRootNode.getName();
pathValue = testRootNode.getPath();
dateValue = Calendar.getInstance();
binaryValue = createRandomString(10).getBytes();
referenceNode = createReferenceableNode(nodeName1);
}
use of javax.jcr.UnsupportedRepositoryOperationException in project jackrabbit by apache.
the class ShareableNodeTest method testRemoveMixin.
/**
* Remove mix:shareable from a shareable node.
*/
public void testRemoveMixin() throws Exception {
// setup parent node and first child
Node a = testRootNode.addNode("a");
Node b = a.addNode("b");
testRootNode.getSession().save();
// add mixin
ensureMixinType(b, mixShareable);
b.getSession().save();
// (per Section 14.15 of JSR-283 specification)
try {
// remove mixin
b.removeMixin(mixShareable);
b.getSession().save();
// If this happens, then b shouldn't be shareable anymore ...
assertFalse(b.isNodeType(mixShareable));
} catch (ConstraintViolationException e) {
// one possible outcome if removing 'mix:shareable' isn't supported
} catch (UnsupportedRepositoryOperationException e) {
// also possible if the implementation doesn't support this
// capability
}
}
use of javax.jcr.UnsupportedRepositoryOperationException in project jackrabbit by apache.
the class LuceneQueryFactory method create.
protected Query create(Constraint constraint, Map<String, NodeType> selectorMap, JackrabbitIndexSearcher searcher) throws RepositoryException, IOException {
if (constraint instanceof And) {
return getAndQuery((And) constraint, selectorMap, searcher);
} else if (constraint instanceof Or) {
return getOrQuery((Or) constraint, selectorMap, searcher);
} else if (constraint instanceof Not) {
return getNotQuery((Not) constraint, selectorMap, searcher);
} else if (constraint instanceof PropertyExistence) {
return getPropertyExistenceQuery((PropertyExistence) constraint);
} else if (constraint instanceof Comparison) {
Comparison c = (Comparison) constraint;
Transform left = new Transform(c.getOperand1());
return getComparisonQuery(left.operand, left.transform, c.getOperator(), c.getOperand2(), selectorMap);
} else if (constraint instanceof FullTextSearch) {
return getFullTextSearchQuery((FullTextSearch) constraint);
} else if (constraint instanceof SameNode) {
SameNode sn = (SameNode) constraint;
return getNodeIdQuery(UUID, sn.getPath());
} else if (constraint instanceof ChildNode) {
ChildNode cn = (ChildNode) constraint;
return getNodeIdQuery(PARENT, cn.getParentPath());
} else if (constraint instanceof DescendantNode) {
DescendantNode dn = (DescendantNode) constraint;
return getDescendantNodeQuery(dn, searcher);
} else {
throw new UnsupportedRepositoryOperationException("Unknown constraint type: " + constraint);
}
}
use of javax.jcr.UnsupportedRepositoryOperationException in project jackrabbit by apache.
the class VersionManagerImplConfig method restore.
/**
* Restores the versions recorded in the given baseline below the specified
* path.
* @param parent the parent state
* @param name the name of the new node (tree)
* @param baseline the baseline that recorded the versions
* @return the node id of the configuration
* @throws RepositoryException if an error occurs
*/
protected NodeId restore(NodeStateEx parent, Name name, InternalBaseline baseline) throws RepositoryException {
// check if nt:configuration exists
NodeId configId = baseline.getConfigurationId();
NodeId rootId = baseline.getConfigurationRootId();
if (stateMgr.hasItemState(rootId)) {
NodeStateEx existing = parent.getNode(rootId);
String msg = "Configuration for the given baseline already exists at: " + safeGetJCRPath(existing);
log.error(msg);
throw new UnsupportedRepositoryOperationException(msg);
}
// find version for configuration root
VersionSet versions = baseline.getBaseVersions();
InternalVersion rootVersion = null;
for (InternalVersion v : versions.versions().values()) {
if (v.getVersionHistory().getVersionableId().equals(rootId)) {
rootVersion = v;
break;
}
}
if (rootVersion == null) {
String msg = "Internal error: supplied baseline has no version for its configuration root.";
log.error(msg);
throw new RepositoryException(msg);
}
// create new node below parent
WriteOperation ops = startWriteOperation();
try {
if (!stateMgr.hasItemState(configId)) {
// create if nt:configuration node is not exists
internalCreateConfiguration(rootId, configId, baseline.getId());
}
NodeStateEx config = parent.getNode(configId);
// create the root node so that the restore works
InternalFrozenNode fn = rootVersion.getFrozenNode();
NodeStateEx state = parent.addNode(name, fn.getFrozenPrimaryType(), fn.getFrozenId());
state.setMixins(fn.getFrozenMixinTypes());
parent.store();
// and finally restore the config and root
internalRestore(config, baseline, null, false);
ops.save();
return configId;
} catch (ItemStateException e) {
throw new RepositoryException(e);
} finally {
ops.close();
}
}
Aggregations