Package org.apache.slide.webdav.util

Examples of org.apache.slide.webdav.util.UriHandler


   
    /**
     * Factory method.
     */
    static public ResourceKind determineResourceKind( NamespaceAccessToken nsaToken, String resourcePath, NodeRevisionDescriptor nrd ) {
        UriHandler uh = UriHandler.getUriHandler( resourcePath );
        NamespaceConfig config = nsaToken.getNamespaceConfig();
       
        if( nrd == null ) {
            return DeltavCompliantUnmappedUrlImpl.getInstance();
        }
        else if( uh.isHistoryUri() ) {
            return VersionHistoryImpl.getInstance();
        }
        else if( uh.isVersionUri() ) {
            return VersionImpl.getInstance();
        }
        else if( uh.isWorkspaceUri() ) {
            return WorkspaceImpl.getInstance();
        }
        else if( uh.isWorkingresourceUri() ) {
            return WorkingImpl.getInstance();
        }
        else if( nrd.exists(P_CHECKED_IN) ) {
            return CheckedInVersionControlledImpl.getInstance();
        }
View Full Code Here


                    }
                }
            }
           
            // check precondition DAV:cannot-modify-version
            UriHandler uriHandler = UriHandler.getUriHandler(resourcePath);
            if (uriHandler.isVersionUri()) {
                return new ViolatedPrecondition(C_CANNOT_MODIFY_VERSION,
                                                WebdavStatus.SC_FORBIDDEN);
            }
        }
       
View Full Code Here

                throw new SlideException("Could not parse DAV:version-set: "+nrds.getUri());
            }
            Iterator hrefIterator = xmlValue.iterator();
           
            NodeRevisionNumber currentNrn= null;
            UriHandler currentUh = null;
            String currentPath = null;
           
            while (hrefIterator.hasNext()) {
                currentPath = ((Element)hrefIterator.next()).getText();
                currentUh = UriHandler.getUriHandler(currentPath);
                currentNrn = new NodeRevisionNumber(currentUh.getVersionName());
                multistatusElm.addContent(getResponseElement(slideToken, currentPath, currentNrn, getRequestedVersionTreeProperties()));
            }
        }
    }
View Full Code Here

        resp.addHeader("MS-Author-Via", "DAV");
       
        // build response body if needed
        if( responseBodyNeeded ) {
            resp.setContentType( TEXT_XML_UTF_8 );
            UriHandler uh = UriHandler.getUriHandler( resourceUri );
            String storeName = uh.getAssociatedBaseStoreName(token.getName());
            UriHandler hpath = HistoryPathHandler.getHistoryPathHandler();
            UriHandler wspath = WorkspacePathHandler.getWorkspacePathHandler();
            Element ore =
                new Element( E_OPTIONS_RESPONSE, DNSP );
            if( versionHistoryCollectionSetRequested ) {
                Element vhcse =
                    new Element( E_VERSION_HISTORY_COLLECTION_SET, DNSP );
View Full Code Here

            revisionDescriptor =
                new NodeRevisionDescriptor(0);
        }
       
        // check destination URI
        UriHandler destinationUriHandler = UriHandler.getUriHandler(colName);
        if (destinationUriHandler.isRestrictedUri()) {
            int statusCode = WebdavStatus.SC_FORBIDDEN;
            sendError( statusCode, getClass().getName()+".restrictedDestinationUri", new Object[]{colName} );
            throw new WebdavException( statusCode );
        }
       
View Full Code Here

       
        this.versionHistorySet =
            new XMLValue(versionHistorySetElm.getChildren(E_HREF, DNSP));
       
        // check DAV:must-be-version-history
        UriHandler uriHandler = null;
        String href = null;
        boolean isVersionHistory = false;
        Iterator iterator = versionHistorySet.getHrefStrings().iterator();
        while (iterator.hasNext()) {
            href = (String)iterator.next();
            uriHandler = UriHandler.getUriHandler(WebdavUtils.getSlidePath(href, contextPath));
            isVersionHistory = uriHandler.isHistoryUri();
            if (!isVersionHistory) {
                break;
            }
        }
        if (!isVersionHistory) {
View Full Code Here

            try {
                XMLValue xmlValue = new XMLValue(property.getValue().toString());
                Iterator iterator = xmlValue.iterator();
                if (iterator.hasNext()) {
                    String vrUri = ((Element)iterator.next()).getText();
                    UriHandler uriHandler = UriHandler.getUriHandler(vrUri);
                    if (uriHandler.isVersionUri()) {
                        historyUri = uriHandler.getAssociatedHistoryUri();
                    }
                }
            }
            catch (JDOMException e) {}
        }
View Full Code Here

            }
        }

        String associatedVrUri = versioningHelper.getUriOfAssociatedVR(resourcePath);
        String vcrHistoryUri = UriHandler.getUriHandler(associatedVrUri).getAssociatedHistoryUri();
        UriHandler vrUriHandler = UriHandler.getUriHandler(updateSourcePath);
        boolean isVersionOfVcrHistory = false;
        if (vrUriHandler.isVersionUri() &&
            vcrHistoryUri.equals(vrUriHandler.getAssociatedHistoryUri()) ) {

            NodeRevisionDescriptors vrDescriptors =
                content.retrieve(stoken, updateSourcePath);
            try {
                NodeRevisionDescriptor vrDescriptor =
View Full Code Here

    private void checkPreconditions() throws PreconditionViolationException, ServiceAccessException {
        // use a non-blocking slide token.
        SlideToken stoken = readonlySlideToken();
       
        resp.setStatus( WebdavStatus.SC_CREATED );
        UriHandler sourceUh = UriHandler.getUriHandler(sourceUri);
        UriHandler sourceParentUh = sourceUh.getParentUriHandler();
        sourceSegment = sourceUh.getName();
        if (sourceParentUh != null) {
            sourceParentUri = sourceUh.getParentUriHandler().toString();
        }
View Full Code Here

     *
     * @param resourcePath the URI of the resource to version-control
     * @throws SlideException
     */
    public void versionControl( String resourcePath ) throws SlideException {
        UriHandler rUh = UriHandler.getUriHandler( resourcePath );
        Iterator i;
        Enumeration j;
       
        NodeRevisionDescriptors rNrds = content.retrieve( sToken, resourcePath );
        NodeRevisionDescriptor rNrd = content.retrieve( sToken, rNrds );
        ResourceKind rRk = AbstractResourceKind.determineResourceKind( nsaToken, resourcePath, rNrd );
        if( !rRk.isSupportedMethod(req.getMethod()) ) {
            throw new MethodNotAllowedException( rRk );
        }
       
        // Check for rRk = K_VERSION_CONTROLLED*
        if( rRk instanceof VersionControlled ) {
            // nothing to do
            return;
        }
       
        // Set initial VR properties
        NodeRevisionDescriptor vrNrd =
            new NodeRevisionDescriptor(req.getContentLength());
        i = pHelp.createInitialProperties(VersionImpl.getInstance()).iterator();
        while( i.hasNext() )
            vrNrd.setProperty( (NodeProperty)i.next() );
       
        // Copy dead properties VCR -> VR
        j = rNrd.enumerateProperties();
        while( j.hasMoreElements() ) {
            NodeProperty p = (NodeProperty)j.nextElement();
            if( p.isLiveProperty() )
                continue;
            if( !vrNrd.exists(p.getName()) )
                vrNrd.setProperty( p );
        }
       
        // Copy properties VCR->VR
        NodeRevisionContent rNrc = content.retrieve( sToken, rNrds, rNrd );
        vrNrd.setContentType(rNrd.getContentType()); // P_GETCONTENTTYPE
        vrNrd.setContentLength(rNrd.getContentLength()); // P_GETCONTENTLENGTH
        vrNrd.setContentLanguage(rNrd.getContentLanguage()); // P_GETCONTENTLANGUAGE
        String comment = "INITIAL VERSION. ";
        if( rNrd.exists(P_COMMENT) )
            comment += (String)rNrd.getProperty(P_COMMENT).getValue();
        vrNrd.setProperty(
            new NodeProperty(P_COMMENT, comment) );
       
        // Set initial VHR properties
        Vector vhrLabels = new Vector();
        Hashtable vhrProps = new Hashtable();
        String vhrBranch = NodeRevisionDescriptors.MAIN_BRANCH;
        NodeRevisionDescriptor vhrNrd =
            new NodeRevisionDescriptor( NodeRevisionNumber.HIDDEN_0_0, vhrBranch, vhrLabels, vhrProps );
        i = pHelp.createInitialProperties(VersionHistoryImpl.getInstance()).iterator();
        while( i.hasNext() )
            vhrNrd.setProperty( (NodeProperty)i.next() );
       
        // Set initial VCR properties (do not overwrite existing!!)
        i = pHelp.createInitialProperties(VersionControlledImpl.getInstance()).iterator();
        while( i.hasNext() ) {
            NodeProperty p = (NodeProperty)i.next();
            if( !rNrd.exists(p.getName()) )
                rNrd.setProperty( p );
        }
       
        // Create VHR/VR
        UriHandler vhrUh = UriHandler.createNextHistoryUri( sToken, nsaToken, rUh );
        String vhrUri = String.valueOf( vhrUh );
        SubjectNode vhrNode = new SubjectNode();
        structure.create( sToken, vhrNode, String.valueOf(vhrUh) );
        content.create( sToken, vhrUri, true ); //isVersioned=true
        content.create( sToken, vhrUri, vrNrd, rNrc );
        NodeRevisionDescriptors vhrNrds =
            content.retrieve( sToken, vhrUri );
        content.create(
            sToken, vhrUri, null, vhrNrd, null ); //branch=null, revisionContent=null
       
        // Create VR node
        NodeRevisionNumber vrVersion = vrNrd.getRevisionNumber();
        SubjectNode vrNode = new SubjectNode();
        UriHandler vrUh =
            UriHandler.createVersionUri( vhrUh, String.valueOf(vrVersion) );
        String vrUri = String.valueOf( vrUh );
        structure.create( sToken, vrNode, String.valueOf(vrUh) );
       
        // Set specific properties
        vrNrd.setName(rUh.getName()); // P_DISPLAYNAME
        rNrd.setProperty(
            new NodeProperty(P_CHECKED_IN, pHelp.createHrefValue(vrUri)) );
        vhrNrd.setCreationDate( new Date() ); // P_CREATIONDATE
        setCreationUser(vhrNrd);
        vhrNrd.setLastModified( new Date() ); // P_GETLASTMODIFIED
        vhrNrd.setContentLength( 0 ); // P_GETCONTENTLENGTH
        vhrNrd.setETag( PropertyHelper.computeEtag(vhrUri, vhrNrd) ); // P_GETETAG
        vhrNrd.setName( vhrUh.getHistoryName() ); // P_DISPLAYNAME
        vhrNrd.setProperty(
            new NodeProperty(P_VERSION_SET, pHelp.createHrefValue(vrUri)) );
        vrNrd.setCreationDate( new Date() ); // P_CREATIONDATE
        setCreationUser(vrNrd);
        vrNrd.setLastModified( new Date() ); // P_GETLASTMODIFIED
        vrNrd.setETag( PropertyHelper.computeEtag(vrUri, vrNrd)); // P_GETETAG
        vrNrd.setProperty(
            new NodeProperty(P_VERSION_NAME, vrUh.getVersionName()) );
       
        // Store changes
        content.store( sToken, resourcePath, rNrd, null ); //revisionContent=null
        content.store( sToken, vhrUri, vhrNrd, null ); //revisionContent=null
        content.store( sToken, vhrUri, vrNrd, null ); //revisionContent=null
View Full Code Here

TOP

Related Classes of org.apache.slide.webdav.util.UriHandler

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.