use of org.apache.jackrabbit.spi.IdFactory in project jackrabbit by apache.
the class NodeEntryImpl method getDeepPropertyEntry.
/**
* @see NodeEntry#getDeepPropertyEntry(Path)
*/
public PropertyEntry getDeepPropertyEntry(Path path) throws PathNotFoundException, RepositoryException {
NodeEntryImpl entry = this;
Path.Element[] elems = path.getElements();
int i = 0;
for (; i < elems.length - 1; i++) {
Path.Element elem = elems[i];
if (elems[i].denotesRoot()) {
if (entry.getParent() != null) {
throw new RepositoryException("NodeEntry out of 'hierarchy' " + path.toString());
}
continue;
}
int index = elem.getNormalizedIndex();
Name name = elem.getName();
// first try to resolve to known node or property entry
NodeEntry cne = entry.getNodeEntry(name, index, false);
if (cne != null) {
entry = (NodeEntryImpl) cne;
} else {
// on the persistent layer.
if (entry.childNodeEntries.isComplete()) {
throw new PathNotFoundException(factory.saveGetJCRPath(path));
}
// -> check for moved child entry in node-attic
// -> check if child points to a removed/moved sns
List<NodeEntry> siblings = entry.childNodeEntries.get(name);
if (entry.containsAtticChild(siblings, name, index)) {
throw new PathNotFoundException(factory.saveGetJCRPath(path));
}
// break out of the loop and start deep loading the property
break;
}
}
int st = entry.getStatus();
PropertyEntry pe;
if (i == elems.length - 1 && Status.INVALIDATED != st && Status._UNDEFINED_ != st) {
// all node entries present in the hierarchy and the direct ancestor
// has already been resolved and isn't invalidated -> no need to
// retrieve property entry from SPI
pe = entry.properties.get(path.getName());
} else {
/*
* Unknown parent entry (not-existing or not yet loaded) or a parent
* entry that has been invalidated:
* Skip all intermediate entries and directly try to load the
* PropertyState (including building the intermediate entries. If that
* fails ItemNotFoundException is thrown.
*/
PathBuilder pb = new PathBuilder(getPathFactory());
for (int j = i; j < elems.length; j++) {
pb.addLast(elems[j]);
}
Path remainingPath = pb.getPath();
IdFactory idFactory = getIdFactory();
NodeId parentId = entry.getWorkspaceId();
if (remainingPath.getLength() != 1) {
parentId = idFactory.createNodeId(parentId, remainingPath.getAncestor(1));
}
PropertyId propId = idFactory.createPropertyId(parentId, remainingPath.getName());
pe = entry.loadPropertyEntry(propId);
}
if (pe == null) {
throw new PathNotFoundException(factory.saveGetJCRPath(path));
}
return pe;
}
use of org.apache.jackrabbit.spi.IdFactory in project jackrabbit by apache.
the class Spi2davRepositoryServiceFactory method createRepositoryService.
public RepositoryService createRepositoryService(Map<?, ?> parameters) throws RepositoryException {
if (parameters == null) {
throw new RepositoryException("Parameter " + PARAM_REPOSITORY_URI + " missing");
}
String uri;
if (parameters.get(PARAM_REPOSITORY_URI) == null) {
throw new RepositoryException("Parameter " + PARAM_REPOSITORY_URI + " missing");
} else {
uri = parameters.get(PARAM_REPOSITORY_URI).toString();
}
IdFactory idFactory;
Object param = parameters.get(PARAM_ID_FACTORY);
if (param != null && param instanceof IdFactory) {
idFactory = (IdFactory) param;
} else {
idFactory = IdFactoryImpl.getInstance();
}
NameFactory nameFactory;
param = parameters.get(PARAM_NAME_FACTORY);
if (param != null && param instanceof NameFactory) {
nameFactory = (NameFactory) param;
} else {
nameFactory = NameFactoryImpl.getInstance();
}
PathFactory pathFactory;
param = parameters.get(PARAM_PATH_FACTORY);
if (param != null && param instanceof PathFactory) {
pathFactory = (PathFactory) param;
} else {
pathFactory = PathFactoryImpl.getInstance();
}
QValueFactory vFactory;
param = parameters.get(PARAM_QVALUE_FACTORY);
if (param != null && param instanceof QValueFactory) {
vFactory = (QValueFactory) param;
} else {
vFactory = QValueFactoryImpl.getInstance();
}
int itemInfoCacheSize = ItemInfoCacheImpl.DEFAULT_CACHE_SIZE;
param = parameters.get(PARAM_ITEMINFO_CACHE_SIZE);
if (param != null) {
try {
itemInfoCacheSize = Integer.parseInt(param.toString());
} catch (NumberFormatException e) {
// ignore, use default
}
}
// max connections config
int maximumHttpConnections = 0;
param = parameters.get(PARAM_MAX_CONNECTIONS);
if (param != null) {
try {
maximumHttpConnections = Integer.parseInt(param.toString());
} catch (NumberFormatException e) {
// using default
}
}
if (maximumHttpConnections > 0) {
return new RepositoryServiceImpl(uri, idFactory, nameFactory, pathFactory, vFactory, itemInfoCacheSize, maximumHttpConnections);
} else {
return new RepositoryServiceImpl(uri, idFactory, nameFactory, pathFactory, vFactory, itemInfoCacheSize);
}
}
use of org.apache.jackrabbit.spi.IdFactory in project jackrabbit by apache.
the class ItemDefinitionProviderImpl method getRootNodeDefinition.
public QNodeDefinition getRootNodeDefinition() throws RepositoryException {
if (rootNodeDefinition == null) {
IdFactory idFactory = service.getIdFactory();
PathFactory pf = service.getPathFactory();
rootNodeDefinition = service.getNodeDefinition(sessionInfo, idFactory.createNodeId((String) null, pf.getRootPath()));
}
return rootNodeDefinition;
}
use of org.apache.jackrabbit.spi.IdFactory in project jackrabbit by apache.
the class NodeEntryImpl method getDeepNodeEntry.
/**
* @see NodeEntry#getDeepNodeEntry(Path)
*/
public NodeEntry getDeepNodeEntry(Path path) throws PathNotFoundException, RepositoryException {
NodeEntryImpl entry = this;
Path.Element[] elems = path.getElements();
for (int i = 0; i < elems.length; i++) {
Path.Element elem = elems[i];
// check for root element
if (elem.denotesRoot()) {
if (entry.getParent() != null) {
throw new RepositoryException("NodeEntry out of 'hierarchy' " + path.toString());
}
continue;
}
int index = elem.getNormalizedIndex();
Name name = elem.getName();
// first try to resolve to known node or property entry
NodeEntry cne = entry.getNodeEntry(name, index, false);
if (cne != null) {
entry = (NodeEntryImpl) cne;
} else {
// on the persistent layer.
if (entry.childNodeEntries.isComplete()) {
throw new PathNotFoundException(factory.saveGetJCRPath(path));
}
// -> check for moved child entry in node-attic
// -> check if child points to a removed/moved sns
List<NodeEntry> siblings = entry.childNodeEntries.get(name);
if (entry.containsAtticChild(siblings, name, index)) {
throw new PathNotFoundException(factory.saveGetJCRPath(path));
}
// elements -> hierarchy doesn't exist anyway.
if (entry.getStatus() == Status.NEW) {
throw new PathNotFoundException(factory.saveGetJCRPath(path));
}
/*
* Unknown entry (not-existing or not yet loaded):
* Skip all intermediate entries and directly try to load the ItemState
* (including building the intermediate entries. If that fails
* ItemNotFoundException is thrown.
*
* Since 'path' might be ambiguous (Node or Property):
* 1) first try Node
* 2) if the NameElement does not have SNS-index => try Property
* 3) else throw
*/
PathBuilder pb = new PathBuilder(getPathFactory());
for (int j = i; j < elems.length; j++) {
pb.addLast(elems[j]);
}
Path remainingPath = pb.getPath();
NodeId parentId = entry.getWorkspaceId();
IdFactory idFactory = factory.getIdFactory();
NodeId nodeId = idFactory.createNodeId(parentId, remainingPath);
NodeEntry ne = entry.loadNodeEntry(nodeId);
if (ne != null) {
return ne;
} else {
throw new PathNotFoundException(factory.saveGetJCRPath(path));
}
}
}
return entry;
}
use of org.apache.jackrabbit.spi.IdFactory in project jackrabbit by apache.
the class WorkspaceItemStateFactory method createRootState.
public NodeState createRootState(NodeEntry entry) throws ItemNotFoundException, RepositoryException {
IdFactory idFactory = service.getIdFactory();
PathFactory pf = service.getPathFactory();
return createNodeState(idFactory.createNodeId((String) null, pf.getRootPath()), entry);
}
Aggregations