use of javax.jcr.RepositoryException in project jackrabbit by apache.
the class WorkspaceImpl method internalClone.
/**
* Handles a clone inside the same workspace, which is supported with
* shareable nodes.
*
* @see {@link #clone()}
*
* @param srcAbsPath source path
* @param destAbsPath destination path
* @return the path of the node at its new position
* @throws ConstraintViolationException
* @throws AccessDeniedException
* @throws VersionException
* @throws PathNotFoundException
* @throws ItemExistsException
* @throws LockException
* @throws RepositoryException
*/
private String internalClone(String srcAbsPath, String destAbsPath) throws ConstraintViolationException, AccessDeniedException, VersionException, PathNotFoundException, ItemExistsException, LockException, RepositoryException {
Path srcPath;
try {
srcPath = context.getQPath(srcAbsPath).getNormalizedPath();
} catch (NameException e) {
String msg = "invalid path: " + srcAbsPath;
log.debug(msg);
throw new RepositoryException(msg, e);
}
if (!srcPath.isAbsolute()) {
throw new RepositoryException("not an absolute path: " + srcAbsPath);
}
Path destPath;
try {
destPath = context.getQPath(destAbsPath).getNormalizedPath();
} catch (NameException e) {
String msg = "invalid path: " + destAbsPath;
log.debug(msg);
throw new RepositoryException(msg, e);
}
if (!destPath.isAbsolute()) {
throw new RepositoryException("not an absolute path: " + destAbsPath);
}
BatchedItemOperations ops = new BatchedItemOperations(stateMgr, context);
try {
ops.edit();
} catch (IllegalStateException e) {
String msg = "unable to start edit operation";
log.debug(msg);
throw new RepositoryException(msg, e);
}
boolean succeeded = false;
try {
ItemId id = ops.clone(srcPath, destPath);
ops.update();
succeeded = true;
return context.getJCRPath(hierMgr.getPath(id));
} finally {
if (!succeeded) {
// update operation failed, cancel all modifications
ops.cancel();
}
}
}
use of javax.jcr.RepositoryException in project jackrabbit by apache.
the class WorkspaceImpl method getQueryManager.
/**
* {@inheritDoc}
*/
public synchronized QueryManager getQueryManager() throws RepositoryException {
// check state of this instance
sanityCheck();
if (queryManager == null) {
SearchManager searchManager;
try {
searchManager = context.getRepository().getSearchManager(wspConfig.getName());
if (searchManager == null) {
String msg = "no search manager configured for this workspace";
log.debug(msg);
throw new RepositoryException(msg);
}
} catch (NoSuchWorkspaceException nswe) {
// should never get here
String msg = "internal error: failed to instantiate query manager";
log.debug(msg);
throw new RepositoryException(msg, nswe);
}
queryManager = new QueryManagerImpl(context, searchManager);
}
return queryManager;
}
use of javax.jcr.RepositoryException in project jackrabbit by apache.
the class WorkspaceImpl method move.
/**
* {@inheritDoc}
*/
public void move(String srcAbsPath, String destAbsPath) throws ConstraintViolationException, VersionException, AccessDeniedException, PathNotFoundException, ItemExistsException, LockException, RepositoryException {
// check state of this instance
sanityCheck();
// intra-workspace move...
Path srcPath;
try {
srcPath = context.getQPath(srcAbsPath).getNormalizedPath();
} catch (NameException e) {
String msg = "invalid path: " + srcAbsPath;
log.debug(msg);
throw new RepositoryException(msg, e);
}
if (!srcPath.isAbsolute()) {
throw new RepositoryException("not an absolute path: " + srcAbsPath);
}
Path destPath;
try {
destPath = context.getQPath(destAbsPath).getNormalizedPath();
} catch (NameException e) {
String msg = "invalid path: " + destAbsPath;
log.debug(msg);
throw new RepositoryException(msg, e);
}
if (!destPath.isAbsolute()) {
throw new RepositoryException("not an absolute path: " + destAbsPath);
}
BatchedItemOperations ops = new BatchedItemOperations(stateMgr, context);
try {
ops.edit();
} catch (IllegalStateException e) {
String msg = "unable to start edit operation";
log.debug(msg);
throw new RepositoryException(msg, e);
}
boolean succeeded = false;
try {
ops.move(srcPath, destPath);
ops.update();
succeeded = true;
} finally {
if (!succeeded) {
// update operation failed, cancel all modifications
ops.cancel();
}
}
}
use of javax.jcr.RepositoryException in project jackrabbit by apache.
the class ClusterNode method process.
public void process(WorkspaceRecord record) {
if (createWorkspaceListener == null) {
String msg = "Create Workspace listener unavailable.";
log.error(msg);
return;
}
try {
if (record.getActionType() == WorkspaceRecord.CREATE_WORKSPACE_ACTION_TYPE) {
CreateWorkspaceAction action = record.getCreateWorkspaceAction();
createWorkspaceListener.externalWorkspaceCreated(record.getWorkspace(), action.getInputSource());
}
} catch (RepositoryException e) {
String msg = "Unable to create workspace: " + e.getMessage();
log.error(msg);
}
}
use of javax.jcr.RepositoryException in project jackrabbit by apache.
the class ClusterNode method init.
/**
* Initialize this cluster node (overridable).
*
* @throws ClusterException if an error occurs
*/
protected void init() throws ClusterException {
ClusterConfig cc = clusterContext.getClusterConfig();
clusterNodeId = cc.getId();
syncDelay = cc.getSyncDelay();
stopDelay = cc.getStopDelay();
try {
journal = cc.getJournal(clusterContext.getNamespaceResolver());
instanceRevision = journal.getInstanceRevision();
journal.register(this);
producer = journal.getProducer(PRODUCER_ID);
} catch (RepositoryException e) {
throw new ClusterException("Cluster initialization failed: " + this, e);
} catch (JournalException e) {
throw new ClusterException("Journal initialization failed: " + this, e);
}
}
Aggregations