Package org.tmatesoft.svn.core.internal.server.dav

Examples of org.tmatesoft.svn.core.internal.server.dav.DAVException


  }


  @Test
  public void testHandleError() throws IOException {
    DAVException davE = new DAVException("Test Error", 404, 0);
    HttpServletResponse resp = new MockHttpServletResponse();
    SvnDavController.handleError(davE, resp);
  }
View Full Code Here


   */
  public static void handleError(DAVException error, HttpServletResponse servletResponse) throws IOException {
    SVNDebugLog.getDefaultLog().logFine(SVNLogType.NETWORK, error);
    DAVResponse response = error.getResponse();
    if (response == null) {
      DAVException stackErr = error;
      while (stackErr != null && stackErr.getTagName() == null) {
        stackErr = stackErr.getPreviousException();
      }

      if (stackErr != null && stackErr.getTagName() != null) {
        servletResponse.setContentType(XML_CONTENT_TYPE);
        servletResponse.setStatus(stackErr.getResponseCode());

        StringBuffer errorMessageBuffer = new StringBuffer();
        SVNXMLUtil.addXMLHeader(errorMessageBuffer);
        errorMessageBuffer.append('\n');
        errorMessageBuffer.append("<D:error xmlns:D=\"DAV:\"");

        if (stackErr.getMessage() != null) {
          errorMessageBuffer.append(" xmlns:m=\"http://apache.org/dav/xmlns\"");
        }

        if (stackErr.getNameSpace() != null) {
          errorMessageBuffer.append(" xmlns:C=\"");
          errorMessageBuffer.append(stackErr.getNameSpace());
          errorMessageBuffer.append("\">\n<C:");
          errorMessageBuffer.append(stackErr.getTagName());
          errorMessageBuffer.append("/>");
        } else {
          errorMessageBuffer.append(">\n<D:");
          errorMessageBuffer.append(stackErr.getTagName());
          errorMessageBuffer.append("/>");
        }

        if (stackErr.getMessage() != null) {
          errorMessageBuffer.append("<m:human-readable errcode=\"");
          errorMessageBuffer.append(stackErr.getErrorID());
          errorMessageBuffer.append("\">\n");
          errorMessageBuffer.append(SVNEncodingUtil.xmlEncodeCDATA(stackErr.getMessage()));
          errorMessageBuffer.append('\n');
          errorMessageBuffer.append("</m:human-readable>\n");
        }
        errorMessageBuffer.append("</D:error>\n");
        servletResponse.getWriter().print(errorMessageBuffer.toString());
View Full Code Here

        DAVXMLUtil.beginMultiStatus(getHttpServletResponse(), SC_MULTISTATUS, getNamespaces(), myResponseBuffer);
       
        int walkType = DAVResourceWalker.DAV_WALKTYPE_NORMAL | DAVResourceWalker.DAV_WALKTYPE_AUTH | DAVResourceWalker.DAV_WALKTYPE_LOCKNULL;
       
        DAVResourceWalker walker = new DAVResourceWalker();
        DAVException error = null;
        try {
            walker.walk(myLocksProvider, resource, null, 0, null, walkType, this, depth);
        } catch (DAVException dave) {
            error = dave;
        }

        if (error != null) {
            throw new DAVException("Provider encountered an error while streaming", error.getResponseCode(), error, 0);
        }
       
        SVNXMLUtil.closeXMLTag(SVNXMLUtil.DAV_NAMESPACE_PREFIX, DAVElement.MULTISTATUS.getName(), myResponseBuffer);
        String responseBody = myResponseBuffer.toString();
View Full Code Here

            if (myLocksProvider != null) {
                DAVLock lock = null;
                try {
                    lock = myLocksProvider.getLock(resource);
                } catch (DAVException dave) {
                    throw new DAVException("DAV:lockdiscovery could not be determined due to a problem fetching the locks for this resource.",
                            dave.getResponseCode(), dave, 0);
                }
               
                if (lock == null) {
                    value = "";
View Full Code Here

            invalidXMLRoot();
        }
    }

    protected void invalidXMLRoot() throws SVNException {
        throw new DAVException("The request body does not contain a \"propertyupdate\" element.", null, HttpServletResponse.SC_BAD_REQUEST,
                null, SVNLogType.NETWORK, Level.FINE, null, null, null, 0, null);
    }
View Full Code Here

    }

    public static DAVPropertiesProvider createPropertiesProvider(DAVResource resource, ServletDAVHandler owner) throws DAVException {
        DAVResourceURI resourceURI = resource.getResourceURI();
        if (resourceURI.getURI() == null) {
            throw new DAVException("INTERNAL DESIGN ERROR: resource must define its URI.", HttpServletResponse.SC_INTERNAL_SERVER_ERROR, 0);
        }
       
        DAVPropertiesProvider provider = new DAVPropertiesProvider(true, owner, resource);
        return provider;
    }
View Full Code Here

    public void open(boolean readOnly) throws DAVException {
        myIsDeferred = false;
        try {
            doOpen(readOnly);
        } catch (DAVException dave) {
            throw new DAVException("Could not open the property database.", HttpServletResponse.SC_INTERNAL_SERVER_ERROR, DAVErrorCode.PROP_OPENING);
        }
    }
View Full Code Here

                    if (ServletDAVHandler.BASE64_ENCODING.equals(encodingType)) {
                        byte[] buffer = new byte[propValue.length()];
                        int length = SVNBase64.base64ToByteArray(new StringBuffer(propValue), buffer);
                        value = SVNPropertyValue.create(reposPropName, buffer, 0, length);
                    } else {
                        throw new DAVException("Unknown property encoding", HttpServletResponse.SC_INTERNAL_SERVER_ERROR, 0);
                    }
                    break;
                }
            }
        }
View Full Code Here

        if (reposPropName == null) {
            DAVConfig config = myResource.getRepositoryManager().getDAVConfig();
            if (config.isAutoVersioning()) {
                reposPropName = propName.getName();
            } else {
                throw new DAVException("Properties may only be defined in the {0} and {1} namespaces.",
                        new Object[] { DAVElement.SVN_SVN_PROPERTY_NAMESPACE, DAVElement.SVN_CUSTOM_PROPERTY_NAMESPACE },
                        HttpServletResponse.SC_CONFLICT, 0);
            }
        }
   
View Full Code Here

            return;
        }
       
        if (!readOnly && resType != DAVResourceType.WORKING) {
            if (!(myResource.isBaseLined() && resType == DAVResourceType.VERSION)) {
                throw new DAVException("Properties may only be changed on working resources.", HttpServletResponse.SC_CONFLICT, 0);
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.tmatesoft.svn.core.internal.server.dav.DAVException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.