Java Code Examples for org.apache.jackrabbit.webdav.DavServletResponse#SC_FORBIDDEN
The following examples show how to use
org.apache.jackrabbit.webdav.DavServletResponse#SC_FORBIDDEN .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ArchivaDavResource.java From archiva with Apache License 2.0 | 5 votes |
@Override public void copy( DavResource destination, boolean shallow ) throws DavException { if ( !exists() ) { throw new DavException( HttpServletResponse.SC_NOT_FOUND, "Resource to copy does not exist." ); } if ( shallow && isCollection() ) { throw new DavException( DavServletResponse.SC_FORBIDDEN, "Unable to perform shallow copy for collection" ); } try { ArchivaDavResource resource = checkDavResourceIsArchivaDavResource( destination ); if ( isCollection() ) { repositoryStorage.copyAsset( asset, destination.getResourcePath() ); triggerAuditEvent( remoteAddr, locator.getRepositoryId(), logicalResource, AuditEvent.COPY_DIRECTORY ); } else { repositoryStorage.copyAsset( asset, destination.getResourcePath() ); triggerAuditEvent( remoteAddr, locator.getRepositoryId(), logicalResource, AuditEvent.COPY_FILE ); } log.debug( "{}{}' copied to '{}' (current user '{}')", ( isCollection() ? "Directory '" : "File '" ), asset.getPath(), destination, this.principal ); } catch ( IOException e ) { throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e ); } }
Example 2
Source File: ResourceServiceImpl.java From document-management-software with GNU Lesser General Public License v3.0 | 5 votes |
public Resource move(Resource source, Resource destination, DavSession session) throws DavException { String sid = (String) session.getObject("sid"); if (source.isWorkspace()) { throw new DavException(DavServletResponse.SC_FORBIDDEN, "Cannot move a workspace"); } else if (source.isFolder()) { return folderRenameOrMove(source, destination, session, sid); } else { return fileRenameOrMove(source, destination, session, sid); } }
Example 3
Source File: AbstractWebdavServlet.java From document-management-software with GNU Lesser General Public License v3.0 | 5 votes |
/** * Validate the given destination resource and return the proper status * code: Any return value greater/equal than * {@link DavServletResponse#SC_NO_CONTENT} indicates an error. * * @param destResource destination resource to be validated. * @param request the HTTP request * * @return status code indicating whether the destination is valid. */ private int validateDestination(DavResource destResource, WebdavRequest request) throws DavException { String destHeader = request.getHeader(HEADER_DESTINATION); if (destHeader == null || "".equals(destHeader)) { return DavServletResponse.SC_BAD_REQUEST; } if (destResource.getLocator().equals(request.getRequestLocator())) { return DavServletResponse.SC_FORBIDDEN; } int status; if (destResource.exists()) { if (request.isOverwrite()) { // matching if-header required for existing resources if (!request.matchesIfHeader(destResource)) { return DavServletResponse.SC_PRECONDITION_FAILED; } else { // overwrite existing resource destResource.getCollection().removeMember(destResource); status = DavServletResponse.SC_NO_CONTENT; } } else { // cannot copy/move to an existing item, if overwrite is not // forced return DavServletResponse.SC_PRECONDITION_FAILED; } } else { // destination does not exist >> copy/move can be performed status = DavServletResponse.SC_CREATED; } return status; }
Example 4
Source File: VersionHistoryResourceImpl.java From document-management-software with GNU Lesser General Public License v3.0 | 4 votes |
public MultiStatusResponse alterProperties(DavPropertySet setProperties, DavPropertyNameSet removePropertyNames) throws DavException { throw new DavException(DavServletResponse.SC_FORBIDDEN); }
Example 5
Source File: VersionResourceImpl.java From document-management-software with GNU Lesser General Public License v3.0 | 4 votes |
@SuppressWarnings("rawtypes") public MultiStatusResponse alterProperties(List changeList) throws DavException { throw new DavException(DavServletResponse.SC_FORBIDDEN); }
Example 6
Source File: VersionResourceImpl.java From document-management-software with GNU Lesser General Public License v3.0 | 4 votes |
public MultiStatusResponse alterProperties(DavPropertySet setProperties, DavPropertyNameSet removePropertyNames) throws DavException { throw new DavException(DavServletResponse.SC_FORBIDDEN); }
Example 7
Source File: VersionResourceImpl.java From document-management-software with GNU Lesser General Public License v3.0 | 4 votes |
public void removeProperty(DavPropertyName propertyName) throws DavException { throw new DavException(DavServletResponse.SC_FORBIDDEN); }
Example 8
Source File: VersionResourceImpl.java From document-management-software with GNU Lesser General Public License v3.0 | 4 votes |
public void setProperty(DavProperty property) throws DavException { throw new DavException(DavServletResponse.SC_FORBIDDEN); }
Example 9
Source File: VersionResourceImpl.java From document-management-software with GNU Lesser General Public License v3.0 | 4 votes |
public void removeMember(DavResource member) throws DavException { throw new DavException(DavServletResponse.SC_FORBIDDEN); }
Example 10
Source File: VersionResourceImpl.java From document-management-software with GNU Lesser General Public License v3.0 | 4 votes |
public void addMember(DavResource member, InputContext inputContext) throws DavException { throw new DavException(DavServletResponse.SC_FORBIDDEN); }
Example 11
Source File: VersionHistoryResourceImpl.java From document-management-software with GNU Lesser General Public License v3.0 | 4 votes |
@SuppressWarnings("rawtypes") public MultiStatusResponse alterProperties(List changeList) throws DavException { throw new DavException(DavServletResponse.SC_FORBIDDEN); }
Example 12
Source File: VersionHistoryResourceImpl.java From document-management-software with GNU Lesser General Public License v3.0 | 4 votes |
public void removeProperty(DavPropertyName propertyName) throws DavException { throw new DavException(DavServletResponse.SC_FORBIDDEN); }
Example 13
Source File: VersionHistoryResourceImpl.java From document-management-software with GNU Lesser General Public License v3.0 | 4 votes |
public void setProperty(DavProperty property) throws DavException { throw new DavException(DavServletResponse.SC_FORBIDDEN); }
Example 14
Source File: VersionHistoryResourceImpl.java From document-management-software with GNU Lesser General Public License v3.0 | 4 votes |
public void addMember(DavResource member, InputContext inputContext) throws DavException { throw new DavException(DavServletResponse.SC_FORBIDDEN); }
Example 15
Source File: DeltaVResourceImpl.java From document-management-software with GNU Lesser General Public License v3.0 | 4 votes |
public void addWorkspace(DavResource workspace) throws DavException { throw new DavException(DavServletResponse.SC_FORBIDDEN); }
Example 16
Source File: ResourceServiceImpl.java From document-management-software with GNU Lesser General Public License v3.0 | 4 votes |
public void copyResource(Resource destinationResource, Resource resource, DavSession session) throws DavException { String sid = (String) session.getObject("sid"); User user = userDAO.findById(resource.getRequestedPerson()); long rootId = folderDAO.findRoot(user.getTenantId()).getId(); /* * Cannot write in the root */ if (destinationResource.isFolder() && Long.parseLong(destinationResource.getID()) == rootId) throw new DavException(DavServletResponse.SC_FORBIDDEN, "Cannot write in the root"); if (resource.isFolder() == true) { throw new RuntimeException("FolderCopy not supported"); } else { try { boolean writeEnabled = destinationResource.isWriteEnabled(); if (!writeEnabled) throw new DavException(DavServletResponse.SC_FORBIDDEN, "No rights to write resource."); Document document = documentDAO.findById(Long.parseLong(resource.getID())); Folder folder = folderDAO.findById(Long.parseLong(destinationResource.getID())); if (document.getImmutable() == 1 && !user.isMemberOf("admin")) throw new DavException(DavServletResponse.SC_FORBIDDEN, "The document is immutable"); // Create the document history event DocumentHistory transaction = new DocumentHistory(); transaction.setSessionId(sid); transaction.setEvent(DocumentEvent.STORED.toString()); transaction.setComment(""); transaction.setUser(user); if (document.getDocRef() != null) { document = documentDAO.findById(document.getDocRef()); documentManager.createAlias(document, folder, document.getDocRefType(), transaction); } else { documentManager.copyToFolder(document, folder, transaction); } } catch (DavException de) { log.info(de.getMessage(), de); throw de; } catch (Exception e) { log.error(e.getMessage(), e); throw new RuntimeException(e); } } }
Example 17
Source File: ResourceServiceImpl.java From document-management-software with GNU Lesser General Public License v3.0 | 4 votes |
public Resource getResource(String requestPath, DavSession session) throws DavException { log.trace("Find DAV resource: {}", requestPath); long userId = 0; String currentStablePath = ""; String name = ""; try { userId = (Long) session.getObject("id"); if (requestPath == null) requestPath = "/"; requestPath = requestPath.replace("/store", ""); if (requestPath.length() > 0 && requestPath.substring(0, 1).equals("/")) requestPath = requestPath.substring(1); String path = "/" + requestPath; currentStablePath = path; name = null; int lastidx = path.lastIndexOf("/"); if (lastidx > -1) { name = path.substring(lastidx + 1, path.length()); path = path.substring(0, lastidx + 1); } Folder folder = null; if (path.equals("/") && name.equals("")) { folder = folderDAO.findRoot(session.getTenantId()); } else folder = folderDAO.findByPathExtended(path + "/" + name, session.getTenantId()); // if this resource request is a folder if (folder != null) return marshallFolder(folder, userId, session); } catch (Exception e) { } Resource parentFolder = this.getParentResource(currentStablePath, userId, session); Collection<Document> docs = documentDAO.findByFileNameAndParentFolderId(Long.parseLong(parentFolder.getID()), name, null, session.getTenantId(), null); if (docs.isEmpty()) return null; Document document = docs.iterator().next(); boolean hasAccess = folderDAO.isReadEnabled(document.getFolder().getId(), userId); if (hasAccess == false) throw new DavException(DavServletResponse.SC_FORBIDDEN, "You have no appropriated rights to read this document"); User user = userDAO.findById(userId); userDAO.initialize(user); checkPublished(user, document); return marshallDocument(document, session); }