use of org.apache.jackrabbit.spi.commons.conversion.NameException in project jackrabbit by apache.
the class IdFactoryImpl method createPropertyId.
/**
* Creates a <code>PropertyId</code> for the given <code>property</code>.
*
* @param property the JCR Property.
* @param resolver
* @return the <code>PropertyId</code> for <code>property</code>.
* @throws RepositoryException if an error occurs while reading from
* <code>property</code>.
*/
public PropertyId createPropertyId(Property property, NamePathResolver resolver) throws RepositoryException {
Node parent = property.getParent();
NodeId nodeId = createNodeId(parent);
String jcrName = property.getName();
Name name;
try {
name = resolver.getQName(jcrName);
} catch (NameException e) {
throw new RepositoryException(e.getMessage(), e);
}
return createPropertyId(nodeId, name);
}
use of org.apache.jackrabbit.spi.commons.conversion.NameException in project jackrabbit by apache.
the class RepositoryServiceImpl method getNodeInfo.
/**
* {@inheritDoc}
*/
public NodeInfo getNodeInfo(SessionInfo sessionInfo, NodeId nodeId) throws ItemNotFoundException, RepositoryException {
SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
Node node = getNode(nodeId, sInfo);
try {
return new NodeInfoImpl(node, idFactory, sInfo.getNamePathResolver());
} catch (NameException e) {
throw new RepositoryException(e);
}
}
use of org.apache.jackrabbit.spi.commons.conversion.NameException in project jackrabbit by apache.
the class RepositoryServiceImpl method getQNodeTypeDefinitions.
/**
* {@inheritDoc}
*/
public Iterator<QNodeTypeDefinition> getQNodeTypeDefinitions(SessionInfo sessionInfo, Name[] nodetypeNames) throws RepositoryException {
SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
NodeTypeManager ntMgr = sInfo.getSession().getWorkspace().getNodeTypeManager();
List<QNodeTypeDefinition> defs = new ArrayList<QNodeTypeDefinition>();
for (Name nodetypeName : nodetypeNames) {
try {
String ntName = sInfo.getNamePathResolver().getJCRName(nodetypeName);
NodeType nt = ntMgr.getNodeType(ntName);
defs.add(new QNodeTypeDefinitionImpl(nt, sInfo.getNamePathResolver(), getQValueFactory()));
// in addition pack all supertypes into the return value
NodeType[] supertypes = nt.getSupertypes();
for (NodeType supertype : supertypes) {
defs.add(new QNodeTypeDefinitionImpl(supertype, sInfo.getNamePathResolver(), getQValueFactory()));
}
} catch (NameException e) {
throw new RepositoryException(e);
}
}
return defs.iterator();
}
use of org.apache.jackrabbit.spi.commons.conversion.NameException in project jackrabbit by apache.
the class AddNodeOperation method perform.
public Node perform(SessionContext context) throws RepositoryException {
ItemManager itemMgr = context.getItemManager();
// Get the canonical path of the new node
Path path;
try {
path = PathFactoryImpl.getInstance().create(node.getPrimaryPath(), context.getQPath(relPath), true);
} catch (NameException e) {
throw new RepositoryException("Failed to resolve path " + relPath + " relative to " + node, e);
}
// Check that the last path element is a simple name
if (!path.denotesName() || path.getIndex() != Path.INDEX_UNDEFINED) {
throw new RepositoryException("Invalid last path element for adding node " + relPath + " relative to " + node);
}
// Get the parent node instance
NodeImpl parentNode;
Path parentPath = path.getAncestor(1);
try {
parentNode = itemMgr.getNode(parentPath);
} catch (PathNotFoundException e) {
if (itemMgr.propertyExists(parentPath)) {
throw new ConstraintViolationException("Unable to add a child node to property " + context.getJCRPath(parentPath));
}
throw e;
} catch (AccessDeniedException ade) {
throw new PathNotFoundException("Failed to resolve path " + relPath + " relative to " + node);
}
// Resolve node type name (if any)
Name typeName = null;
if (nodeTypeName != null) {
typeName = context.getQName(nodeTypeName);
}
// Check that the given UUID (if any) does not already exist
NodeId id = null;
if (uuid != null) {
id = new NodeId(uuid);
if (itemMgr.itemExists(id)) {
throw new ItemExistsException("A node with this UUID already exists: " + uuid);
}
}
return parentNode.addNode(path.getName(), typeName, id);
}
use of org.apache.jackrabbit.spi.commons.conversion.NameException in project jackrabbit by apache.
the class ObservationManagerImpl method createEventFilter.
/**
* Creates an SPI event filter from the given list of constraints.
*
* @param eventTypes the event types.
* @param absPath an absolute path.
* @param isDeep whether to include events for descendant items of
* the node at absPath.
* @param uuids uuid filters.
* @param nodeTypeNames node type filters.
* @param noLocal whether to exclude changes from the local session.
* @return the SPI event filter instance.
* @throws RepositoryException if an error occurs while creating the event
* filter.
*/
private EventFilter createEventFilter(int eventTypes, String absPath, boolean isDeep, String[] uuids, String[] nodeTypeNames, boolean noLocal) throws RepositoryException {
Path path;
try {
path = resolver.getQPath(absPath).getCanonicalPath();
} catch (NameException e) {
throw new RepositoryException("Malformed path: " + absPath);
}
// create NodeType instances from names
Name[] qNodeTypeNames;
if (nodeTypeNames == null) {
qNodeTypeNames = null;
} else {
try {
qNodeTypeNames = new Name[nodeTypeNames.length];
for (int i = 0; i < nodeTypeNames.length; i++) {
Name ntName = resolver.getQName(nodeTypeNames[i]);
if (!ntRegistry.isRegistered(ntName)) {
throw new RepositoryException("unknown node type: " + nodeTypeNames[i]);
}
qNodeTypeNames[i] = ntName;
}
} catch (NameException e) {
throw new RepositoryException(e.getMessage());
}
}
return wspManager.createEventFilter(eventTypes, path, isDeep, uuids, qNodeTypeNames, noLocal);
}
Aggregations