You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by pn...@apache.org on 2002/04/05 18:10:49 UTC
cvs commit: jakarta-slide/src/webdav/server/org/apache/slide/webdav/util WorkspacePathHandler.java
pnever 02/04/05 08:10:49
Added: src/webdav/server/org/apache/slide/webdav/method
MkworkspaceMethod.java
src/webdav/server/org/apache/slide/webdav/util
WorkspacePathHandler.java
Log:
Initial version
Revision Changes Path
1.1 jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/MkworkspaceMethod.java
Index: MkworkspaceMethod.java
===================================================================
/*
* $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/MkworkspaceMethod.java,v 1.1 2002/04/05 16:10:49 pnever Exp $
* $Revision: 1.1 $
* $Date: 2002/04/05 16:10:49 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package org.apache.slide.webdav.method;
import java.io.*;
import java.util.*;
import javax.xml.parsers.ParserConfigurationException ;
import org.xml.sax.SAXException;
import org.jdom.Element;
import org.jdom.Document;
import org.jdom.Namespace;
import org.jdom.JDOMException;
import org.jdom.output.XMLOutputter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.slide.common.SlideException;
import org.apache.slide.common.SlideToken;
import org.apache.slide.common.NamespaceAccessToken;
import org.apache.slide.content.Content;
import org.apache.slide.content.NodeProperty;
import org.apache.slide.content.NodeRevisionContent;
import org.apache.slide.content.NodeRevisionDescriptor;
import org.apache.slide.content.NodeRevisionDescriptors;
import org.apache.slide.structure.Structure;
import org.apache.slide.structure.SubjectNode;
import org.apache.slide.structure.ObjectNotFoundException;
import org.apache.slide.structure.LinkedObjectNotFoundException;
import org.apache.slide.webdav.WebdavException;
import org.apache.slide.webdav.WebdavServletConfig;
import org.apache.slide.webdav.util.PropertyHelper;
import org.apache.slide.webdav.util.VersioningHelper;
import org.apache.slide.webdav.util.UriHandler;
import org.apache.slide.webdav.util.DeltavConstants;
import org.apache.slide.webdav.util.ViolatedPrecondition;
import org.apache.slide.webdav.util.PreconditionViolationException;
import org.apache.slide.webdav.util.resourcekind.*;
import org.apache.util.WebdavStatus;
/**
* MKWORKSPACE method.
*
* @author <a href="mailto:peter.nevermann@softwareag.com">Peter Nevermann</a>
*/
public class MkworkspaceMethod extends WebdavMethod
implements DeltavConstants {
/**
* Resource to be created.
*/
private String resourcePath;
/**
* MKWORKSPACE method constructor.
*
* @param token Namespace access token
* @param req HTTP request
* @param resp HTTP response
*/
public MkworkspaceMethod( NamespaceAccessToken token,
HttpServletRequest req,
HttpServletResponse resp,
WebdavServletConfig config)
{
super(token, req, resp, config);
}
/**
* Parse WebDAV XML query.
*
* @exception WebdavException
*/
protected void parseRequest() throws WebdavException, IOException {
resourcePath = requestUri;
if (resourcePath == null) {
resourcePath = "/";
}
}
/**
* Execute the request.
*
* @exception WebdavException
*/
protected void executeRequest() throws WebdavException, IOException {
// Prevent dirty reads
slideToken.setForceStoreEnlistment(true);
try {
VersioningHelper vh = VersioningHelper.getVersioningHelper(
slideToken, token, req, resp, getConfig() );
vh.mkworkspace( resourcePath );
}
catch (PreconditionViolationException e) {
sendPreconditionViolation(e.getViolatedPrecondition());
throw e;
}
catch (Exception e) {
e.printStackTrace();
resp.setStatus( getErrorCode(e) ); // special handling needed
throw new WebdavException( WebdavStatus.SC_ACCEPTED, false ); // abort the TA
}
}
/**
* Sends a precondition vilolation response.
*
* @param violatedPrecondition the precondition that has been violated.
*/
protected void sendPreconditionViolation(ViolatedPrecondition violatedPrecondition) throws IOException {
if (violatedPrecondition != null) {
resp.setStatus(violatedPrecondition.getStatusCode());
resp.setContentType(TEXT_XML);
Element errorElement = new Element(E_ERROR, Namespace.getNamespace(DEFAULT_NAMESPACE));
Element preconditionElement = new Element(violatedPrecondition.getPrecondition(), Namespace.getNamespace(DEFAULT_NAMESPACE));
errorElement.addContent(preconditionElement);
new XMLOutputter().output(errorElement, resp.getWriter());
}
}
}
1.1 jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/WorkspacePathHandler.java
Index: WorkspacePathHandler.java
===================================================================
/*
* $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/WorkspacePathHandler.java,v 1.1 2002/04/05 16:10:49 pnever Exp $
* $Revision: 1.1 $
* $Date: 2002/04/05 16:10:49 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package org.apache.slide.webdav.util;
import org.apache.slide.common.NamespaceAccessToken;
public class WorkspacePathHandler extends UriHandler {
/**
* Factory method.
*/
public static UriHandler
getWorkspacePathHandler( NamespaceAccessToken nsaToken ) {
String nsName = nsaToken.getName();
UriHandler result = (UriHandler)wspathHandlers.get( nsName );
if( result == null ) {
String wspath = nsaToken.getNamespaceConfig().getWorkspacePath();
if( wspath == null || wspath.length() == 0 )
throw new IllegalStateException(
"No workspace path defined in namespace "+nsName+"; either "+
"define it in domain.xml or disable versioning in slide.properties"
);
result = new WorkspacePathHandler( nsName, wspath );
wspathHandlers.put( nsName, result );
}
return result;
}
/**
* Protected constructor
*/
protected WorkspacePathHandler( String nsName, String uri ) {
super( nsName, uri );
}
/**
* TODO: methods to resolve parametrized workspace paths
*/
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>