use of org.apache.jackrabbit.spi.Name in project jackrabbit by apache.
the class InternalVersionManagerBase method internalCreateActivity.
/**
* Creates a new activity.
*
* @param title title of the new activity
* @return the id of the newly created activity
* @throws RepositoryException if an error occurs
*/
NodeStateEx internalCreateActivity(String title) throws RepositoryException {
WriteOperation operation = startWriteOperation();
try {
// create deep path
NodeId activityId = nodeIdFactory.newNodeId();
NodeStateEx parent = getParentNode(getActivitiesRoot(), activityId.toString(), NameConstants.REP_ACTIVITIES);
Name name = getName(activityId.toString());
// create new activity node in the persistent state
NodeStateEx pNode = InternalActivityImpl.create(parent, name, activityId, title);
// end update
operation.save();
log.debug("Created new activity " + activityId + " with title " + title + ".");
return pNode;
} catch (ItemStateException e) {
throw new RepositoryException(e);
} finally {
operation.close();
}
}
use of org.apache.jackrabbit.spi.Name in project jackrabbit by apache.
the class NodeStateEx method getProperties.
/**
* Returns the properties of this node
*
* @return the properties of this node
* @throws ItemStateException if an error occurs
*/
public PropertyState[] getProperties() throws ItemStateException {
Set<Name> set = nodeState.getPropertyNames();
PropertyState[] props = new PropertyState[set.size()];
int i = 0;
for (Name propName : set) {
PropertyId propId = new PropertyId(nodeState.getNodeId(), propName);
props[i++] = (PropertyState) stateMgr.getItemState(propId);
}
return props;
}
use of org.apache.jackrabbit.spi.Name in project jackrabbit by apache.
the class NodeStateEx method removeNode.
/**
* removes recursively the node with the given id
*
* @param id node id
* @throws ItemStateException if an error occurs
*/
private void removeNode(NodeId id) throws ItemStateException {
NodeState state = (NodeState) stateMgr.getItemState(id);
// remove properties
for (Name name : state.getPropertyNames()) {
PropertyId propId = new PropertyId(id, name);
PropertyState propState = (PropertyState) stateMgr.getItemState(propId);
stateMgr.destroy(propState);
}
state.removeAllPropertyNames();
// remove child nodes
for (ChildNodeEntry entry : state.getChildNodeEntries()) {
removeNode(entry.getId());
}
state.removeAllChildNodeEntries();
// destroy the state itself
stateMgr.destroy(state);
}
use of org.apache.jackrabbit.spi.Name in project jackrabbit by apache.
the class InternalVersionManagerBase method getVersionHistoryOfNode.
/**
* {@inheritDoc}
*/
public InternalVersionHistory getVersionHistoryOfNode(NodeId id) throws RepositoryException {
VersioningLock.ReadLock lock = acquireReadLock();
try {
String uuid = id.toString();
Name name = getName(uuid);
NodeStateEx parent = getParentNode(getHistoryRoot(), uuid, null);
if (parent != null && parent.hasNode(name)) {
NodeStateEx history = parent.getNode(name, 1);
if (history == null) {
throw new InconsistentVersioningState("Unexpected failure to get child node " + name + " on parent node" + parent.getNodeId());
}
return getVersionHistory(history.getNodeId());
} else {
throw new ItemNotFoundException("Version history of node " + id + " not found.");
}
} finally {
lock.release();
}
}
use of org.apache.jackrabbit.spi.Name in project jackrabbit by apache.
the class InternalVersionManagerBase method internalCreateVersionHistory.
/**
* Creates a new Version History.
*
* @param node the node for which the version history is to be initialized
* @param copiedFrom node id for the jcr:copiedFrom parameter
* @return the identifiers of the newly created version history and root version
* @throws RepositoryException if an error occurs
*/
NodeStateEx internalCreateVersionHistory(NodeState node, NodeId copiedFrom) throws RepositoryException {
WriteOperation operation = startWriteOperation();
try {
// create deep path
String uuid = node.getNodeId().toString();
NodeStateEx parent = getParentNode(getHistoryRoot(), uuid, NameConstants.REP_VERSIONSTORAGE);
Name name = getName(uuid);
if (parent.hasNode(name)) {
// already exists
return null;
}
// create new history node in the persistent state
NodeStateEx history = InternalVersionHistoryImpl.create(this, parent, name, node, copiedFrom);
// end update
operation.save();
log.debug("Created new version history " + history.getNodeId() + " for " + node + ".");
return history;
} catch (ItemStateException e) {
throw new RepositoryException(e);
} finally {
operation.close();
}
}
Aggregations