use of org.apache.jackrabbit.webdav.DavException in project jackrabbit by apache.
the class DavResourceImpl method alterProperty.
private void alterProperty(PropEntry prop) throws DavException {
if (isLocked(this)) {
throw new DavException(DavServletResponse.SC_LOCKED);
}
if (!exists()) {
throw new DavException(DavServletResponse.SC_NOT_FOUND);
}
try {
List<? extends PropEntry> list = Collections.singletonList(prop);
alterProperties(list);
Map<? extends PropEntry, ?> failure = config.getPropertyManager().alterProperties(getPropertyImportContext(list), isCollection());
if (failure.isEmpty()) {
node.save();
} else {
node.refresh(false);
// TODO: retrieve specific error from failure-map
throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR);
}
} catch (RepositoryException e) {
// revert any changes made so far
JcrDavException je = new JcrDavException(e);
try {
node.refresh(false);
} catch (RepositoryException re) {
// should not happen...
}
throw je;
}
}
use of org.apache.jackrabbit.webdav.DavException in project jackrabbit by apache.
the class RootCollection method getMembers.
/**
* Returns an iterator over the member resources, which are all
* workspace resources available.
*
* @return members of this collection
* @see org.apache.jackrabbit.webdav.DavResource#getMembers()
*/
@Override
public DavResourceIterator getMembers() {
List<DavResource> memberList = new ArrayList();
try {
String[] wsNames = getRepositorySession().getWorkspace().getAccessibleWorkspaceNames();
for (String wsName : wsNames) {
String wspPath = "/" + wsName;
DavResourceLocator childLoc = getLocator().getFactory().createResourceLocator(getLocator().getPrefix(), wspPath, wspPath);
memberList.add(createResourceFromLocator(childLoc));
}
} catch (RepositoryException e) {
log.error(e.getMessage());
} catch (DavException e) {
// should never occur
log.error(e.getMessage());
}
return new DavResourceIteratorImpl(memberList);
}
use of org.apache.jackrabbit.webdav.DavException in project jackrabbit by apache.
the class DavResourceImpl method removeMember.
/**
* @see DavResource#removeMember(DavResource)
*/
public void removeMember(DavResource member) throws DavException {
if (!exists() || !member.exists()) {
throw new DavException(DavServletResponse.SC_NOT_FOUND);
}
if (isLocked(this) || isLocked(member)) {
throw new DavException(DavServletResponse.SC_LOCKED);
}
// don't allow removal of nodes, that would be filtered out
if (isFilteredResource(member)) {
log.debug("Avoid removal of filtered resource: " + member.getDisplayName());
throw new DavException(DavServletResponse.SC_FORBIDDEN);
}
DeleteManager dm = config.getDeleteManager();
dm.delete(new DeleteContextImpl(getJcrSession()), member);
// make sure, non-jcr locks are removed, once the removal is completed
try {
if (!isJcrLockable()) {
ActiveLock lock = getLock(Type.WRITE, Scope.EXCLUSIVE);
if (lock != null) {
lockManager.releaseLock(lock.getToken(), member);
}
}
} catch (DavException e) {
// since check for 'locked' exception has been performed before
// ignore any error here
}
}
use of org.apache.jackrabbit.webdav.DavException in project jackrabbit by apache.
the class DeltaVResourceImpl method getReferenceResources.
/**
* Return an array of <code>DavResource</code> objects that are referenced
* by the property with the specified name.
*
* @param hrefPropertyName
* @return array of <code>DavResource</code>s
* @throws DavException
* @see DeltaVResource#getReferenceResources(org.apache.jackrabbit.webdav.property.DavPropertyName)
*/
public DavResource[] getReferenceResources(DavPropertyName hrefPropertyName) throws DavException {
DavProperty<?> prop = getProperty(hrefPropertyName);
List<DavResource> resources = new ArrayList<DavResource>();
if (prop != null && prop instanceof HrefProperty) {
HrefProperty hp = (HrefProperty) prop;
// process list of hrefs
for (String href : hp.getHrefs()) {
DavResourceLocator locator = getLocator().getFactory().createResourceLocator(getLocator().getPrefix(), href);
resources.add(createResourceFromLocator(locator));
}
} else {
throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR);
}
return resources.toArray(new DavResource[resources.size()]);
}
use of org.apache.jackrabbit.webdav.DavException in project jackrabbit by apache.
the class ResourceFactoryImpl method createResource.
/**
* Create a new <code>DavResource</code> from the given locator and webdav
* session.
*
* @param locator
* @param session
* @return
* @throws DavException
* @see DavResourceFactory#createResource(DavResourceLocator, DavSession)
*/
public DavResource createResource(DavResourceLocator locator, DavSession session) throws DavException {
try {
Node node = getNode(session, locator);
DavResource resource = createResource(node, locator, session);
resource.addLockManager(lockMgr);
return resource;
} catch (RepositoryException e) {
throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, e);
}
}
Aggregations