Examples of UriHandler


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

     *
     * @param rUri the URI of the resource to set the workspace property
     * @param rNrd the NodeRevisionDescriptor to set the workspace property
     */
    public void setWorkspaceProperty( String rUri, NodeRevisionDescriptor rNrd ) {
        UriHandler rUh = UriHandler.getUriHandler( rUri );
        String wsUri = rUh.getAssociatedWorkspaceUri();
        if( wsUri != null ) {
            rNrd.setProperty(
                new NodeProperty(P_WORKSPACE, pHelp.createHrefValue(wsUri)) );
        }
        else {
View Full Code Here

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

     * @throws SlideException
     */
    public void mkworkspace( String resourcePath ) throws SlideException {
        Iterator i;
       
        UriHandler rUh = UriHandler.getUriHandler( resourcePath );
        NodeRevisionDescriptor rNrd = null;
        try {
            NodeRevisionDescriptors rNrds = content.retrieve( sToken, resourcePath );
            rNrd = content.retrieve( sToken, rNrds );
        }
        catch( ObjectNotFoundException e ) {}; // can be ignored here!
       
        ResourceKind rRk = AbstractResourceKind.determineResourceKind( nsaToken, resourcePath, rNrd );
       
        if( !(rRk instanceof DeltavCompliantUnmappedUrl) ) {
            throw new PreconditionViolationException(
                new ViolatedPrecondition(C_RESOURCE_MUST_BE_NULL, WebdavStatus.SC_CONFLICT), resourcePath);
        }
        if( !rUh.isWorkspaceUri() ) {
            throw new PreconditionViolationException(
                new ViolatedPrecondition(C_WORKSPACE_LOCATION_OK, WebdavStatus.SC_FORBIDDEN), resourcePath);
        }
        if( !rRk.isSupportedMethod(req.getMethod()) ) {
            throw new MethodNotAllowedException( rRk );
        }
       
        // Set initial ws properties
        String wsUri = String.valueOf(rUh);
        NodeRevisionDescriptor wsNrd =
            new NodeRevisionDescriptor(0);
        i = pHelp.createInitialProperties(WorkspaceImpl.getInstance()).iterator();
        while( i.hasNext() )
            wsNrd.setProperty( (NodeProperty)i.next() );
       
        // Set specific properties
        wsNrd.setProperty(
            new NodeProperty(P_WORKSPACE, pHelp.createHrefValue(wsUri)) );
        wsNrd.setLastModified( new Date() ); //P_GETLASTMODIFIED
        wsNrd.setContentLength( 0 ); // P_GETCONTENTLENGTH
        wsNrd.setETag( PropertyHelper.computeEtag(wsUri, wsNrd) ); // P_GETETAG
        if (!Configuration.useBinding(nsaToken.getUri(sToken, wsUri).getStore())) {
            wsNrd.setName( rUh.getWorkspaceName() ); // P_DISPLAYNAME
        }
        wsNrd.setCreationDate( new Date() ); // P_CREATIONDATE
        setCreationUser(wsNrd);
       
        // Create the ws resource
View Full Code Here

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

     * @throws PreconditionViolatedException
     */
    public String checkout( String resourcePath, boolean forkOk, boolean applyToVersion, boolean isAutoVersionCheckout )
        throws SlideException, JDOMException, IOException, PreconditionViolationException  {
       
        UriHandler rUh = UriHandler.getUriHandler( resourcePath );
        NodeRevisionDescriptors rNrds = content.retrieve( sToken, resourcePath );
        NodeRevisionDescriptor rNrd = content.retrieve( sToken, rNrds );
       
        if( rUh.isVersionUri() ) {
            NodeRevisionContent rNrc = content.retrieve( sToken, rNrds, rNrd );
            return checkout( rNrds, rNrd, rNrc, forkOk, null ); // autoUpdateUri=null
        }
        else {
            return checkout( rNrds, rNrd, forkOk, applyToVersion, isAutoVersionCheckout);
View Full Code Here

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

       
        if( rRk instanceof CheckedInVersionControlled ) {
            // get checked-in VR
            NodeProperty cinProp = rNrd.getProperty( P_CHECKED_IN );
            String cinHref = getElementValue((String)cinProp.getValue());
            UriHandler cinUriHandler = UriHandler.getUriHandler(cinHref);
            String cinhUri = cinUriHandler.getAssociatedHistoryUri();
            NodeRevisionNumber cinNrn = new NodeRevisionNumber(cinUriHandler.getVersionName());
            NodeRevisionDescriptors cinNrds = content.retrieve(sToken, cinhUri);
            NodeRevisionDescriptor cinNrd = content.retrieve(sToken, cinNrds, cinNrn);
           
            // working resource feature
            if( applyToVersion ) {
View Full Code Here

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

            throw new MethodNotAllowedException( rRk );
        }
       
        if( rRk instanceof Version ) {
           
            UriHandler rUh = UriHandler.getUriHandler( rUri );
            String vhUri = rUh.getAssociatedHistoryUri();
           
            ViolatedPrecondition violatedPrecondition = getCheckoutPreconditionViolation(rNrds, rNrd, forkOk);
            if (violatedPrecondition != null) {
                throw new PreconditionViolationException(violatedPrecondition, rNrds.getUri());
               
               
            }
           
            NodeRevisionDescriptors vhrNrds = content.retrieve(sToken, vhUri);
           
            // create the workingresource
            UriHandler wrUh = UriHandler.createNextWorkingresourceUri( sToken, nsaToken, rUh );
            String wrUri = String.valueOf( wrUh );
            SubjectNode wrNode = new SubjectNode();
            structure.create( sToken, wrNode, String.valueOf(wrUh) );
           
            // set WR props
            NodeRevisionDescriptor wrNrd = new NodeRevisionDescriptor();
            i = pHelp.createInitialProperties(WorkingImpl.getInstance()).iterator();
            while( i.hasNext() )
                wrNrd.setProperty( (NodeProperty)i.next() );
            //            content.create( sToken, wrUri, wrNrd, rNrc );
           
            // set specific live props
            wrNrd.setProperty(
                new NodeProperty(P_CHECKED_OUT, pHelp.createHrefValue(rUri)) );
            wrNrd.setProperty(
                new NodeProperty(P_PREDECESSOR_SET, pHelp.createHrefValue(rUri)) );
            NodeProperty coutfProp = rNrd.getProperty(P_CHECKOUT_FORK);
            if( coutfProp != null )
                wrNrd.setProperty( coutfProp );
            NodeProperty cinfProp = rNrd.getProperty(P_CHECKIN_FORK);
            if( cinfProp != null )
                wrNrd.setProperty( cinfProp );
            wrNrd.setContentType(rNrd.getContentType()); // P_GETCONTENTTYPE
            wrNrd.setContentLength( rNrd.getContentLength() ); // P_GETCONTENTLENGTH
            wrNrd.setContentLanguage(rNrd.getContentLanguage()); // P_GETCONTENTLANGUAGE
            wrNrd.setLastModified( new Date() ); //P_GETLASTMODIFIED
            wrNrd.setCreationDate( new Date() ); // P_CREATIONDATE
            setCreationUser(wrNrd);
            wrNrd.setETag( PropertyHelper.computeEtag(wrUri, wrNrd)  ); // P_GETETAG
           
            // set auto-update
            if( autoUpdateUri != null && autoUpdateUri.length() > 0 ) {
                UriHandler autoUpdateUh = new UriHandler( autoUpdateUri );
                wrNrd.setProperty(
                    new NodeProperty(P_AUTO_UPDATE, pHelp.createHrefValue(autoUpdateUri)) );
                wrNrd.setName( autoUpdateUh.getName() );
            }
            else {
                wrNrd.removeProperty( P_AUTO_UPDATE );
                wrNrd.setName( rNrd.getName() );
            }
View Full Code Here

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

        }
       
        // get checked-out VR
        NodeProperty coutProp = rNrd.getProperty( P_CHECKED_OUT );
        String coutHref = getElementValue((String)coutProp.getValue());
        UriHandler coutUriHandler = UriHandler.getUriHandler(coutHref);
        String coutUri = coutUriHandler.getAssociatedHistoryUri();
        NodeRevisionNumber coutNrn = new NodeRevisionNumber(coutUriHandler.getVersionName());
        NodeRevisionDescriptors coutNrds = content.retrieve(sToken, coutUri);
        NodeRevisionDescriptor coutNrd = content.retrieve(sToken, coutNrds, coutNrn);
        NodeRevisionContent coutNrc = content.retrieve( sToken, coutNrds, coutNrd );
       
        // update its DAV:checkout-set property
View Full Code Here

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

            }
           
            // Retrieve VHR
            Element coutElm = pHelp.parsePropertyValue( (String)coutProp.getValue() );
            String vrUriOld = coutElm.getTextTrim();
            UriHandler vrUhOld = UriHandler.getUriHandler( vrUriOld );
            NodeRevisionNumber vrNrnOld = new NodeRevisionNumber( vrUhOld.getVersionName() );
            String vhrUri = vrUhOld.getAssociatedHistoryUri();
            NodeRevisionDescriptors vhrNrds = content.retrieve( sToken, vhrUri );
            NodeRevisionDescriptor vhrNrd = content.retrieve( sToken, vhrNrds ); //vhrUri
            NodeProperty vSetProp = vhrNrd.getProperty( P_VERSION_SET );
           
            // Retrieve old VR
            NodeRevisionDescriptor vrNrdOld =
                content.retrieve( sToken, vhrNrds, vrNrnOld ); // vrUriOld
           
            // update the old VR's DAV:checkout-set property
            if (!PropertyHelper.removeHrefFromProperty(vrNrdOld, P_CHECKOUT_SET, rUri)) {
                StringBuffer b = new StringBuffer("Invalid path");
                PropertyHelper propertyHelper = PropertyHelper.getPropertyHelper(sToken, nsaToken, sConf);
                NodeProperty checkoutSetProp = propertyHelper.getProperty(P_CHECKOUT_SET, vhrNrds, vrNrdOld, req.getContextPath(), null);
                if( checkoutSetProp != null && checkoutSetProp.getValue() != null ) {
                    XMLValue checkoutSetValue = new XMLValue( checkoutSetProp.getValue().toString() );
                    if (checkoutSetValue.iterator().hasNext()) {
                        b.append(" - please use "+checkoutSetValue.getTextValue()+" instead");
                    }
                }
                throw new ConflictException(
                    rUri, new SlideException(b.toString()));
            }
            content.store(sToken, vhrNrds.getUri(), vrNrdOld, null);
           
            // check preconditions
            ViolatedPrecondition violatedPrecondition =
                getCheckinPreconditionViolation( predSetProp, vhrNrds, forkOk, autoUpdNrd );
            if (violatedPrecondition != null) {
                throw new PreconditionViolationException(violatedPrecondition, rUri);
            }
           
            // check forking
            String forkBranch = getForkBranch(predSetProp, vhrNrds, forkOk);
            NodeRevisionDescriptor vrNrdNew = null;
            if (forkBranch != null) {
                // Create a new branch
                NodeRevisionNumber branchedRevisionNumber =
                    content.fork(sToken, vhrNrds.getUri(), forkBranch, vrNrdOld);
                vhrNrds = content.retrieve( sToken, vhrUri );
                vrNrdNew = content.retrieve(sToken, vhrNrds, branchedRevisionNumber);
                vrNrdNew.setContentLength(rNrd.getContentLength());
            }
            else {
                // Create new VR in the MAIN branch
                vrNrdNew = new NodeRevisionDescriptor( rNrd.getContentLength() );
            }
           
            i = pHelp.createInitialProperties(VersionImpl.getInstance()).iterator();
            while( i.hasNext() )
                vrNrdNew.setProperty( (NodeProperty)i.next() );
           
            // Copy dead properties VCR --> VR-new
            j = rNrd.enumerateProperties();
            while( j.hasMoreElements() ) {
                NodeProperty p = (NodeProperty)j.nextElement();
                if( p.isLiveProperty() )
                    continue;
                if( !vrNrdNew.exists(p.getName()) )
                    vrNrdNew.setProperty( p );
            }
            // Copy specific live properties VCR/WR -> VR
            vrNrdNew.setContentType(rNrd.getContentType()); // P_GETCONTENTTYPE
            vrNrdNew.setContentLength(rNrd.getContentLength()); // P_GETCONTENTLENGTH
            vrNrdNew.setContentLanguage( rNrd.getContentLanguage() ); // P_GETCONTENTLANGUAGE
            String comment = (autoVersion ? "CREATED BY AUTO-VERSIONING. " : "");
            if( rNrd.exists(P_COMMENT) )
                comment += (String)rNrd.getProperty(P_COMMENT).getValue();
            vrNrdNew.setProperty(
                new NodeProperty(P_COMMENT, comment) );
           
            vrNrdNew.setProperty( rNrd.getProperty(P_CHECKOUT_FORK) );
            vrNrdNew.setProperty( rNrd.getProperty(P_CHECKIN_FORK) );
           
            NodeRevisionContent rNrc = content.retrieve( sToken, rNrds, rNrd );
           
            if (forkBranch != null) {
                content.store(sToken, vhrUri, vrNrdNew, rNrc);
            }
            else {
                String branch = vrNrdOld.getBranchName();
                content.create( sToken, vhrUri, branch, vrNrdNew, rNrc );
            }
           
            // create new VR node
            String vrUriNew = vhrUri+"/"+vrNrdNew.getRevisionNumber().toString();
            UriHandler vrUhNew = UriHandler.getUriHandler( vrUriNew );
            SubjectNode vrNodeNew = new SubjectNode();
            structure.create( sToken, vrNodeNew, vrUriNew );
           
            // set specific properties
            if( keepCheckedOut ) {
                rNrd.setProperty(
                    new NodeProperty(P_CHECKED_OUT, pHelp.createHrefValue(vrUriNew)) );
                rNrd.setProperty(
                    new NodeProperty(P_PREDECESSOR_SET, "") );
                PropertyHelper.addHrefToProperty(rNrd, P_PREDECESSOR_SET, vrUriNew);
                PropertyHelper.addHrefToProperty(vrNrdNew, P_CHECKOUT_SET, rUri);
            }
            else {
                if( !isWorkingResource ) {
                    rNrd.removeProperty( coutProp );
                    rNrd.setProperty(
                        new NodeProperty(P_CHECKED_IN, pHelp.createHrefValue(vrUriNew)) );
                    rNrd.removeProperty( I_CHECKIN_LOCKTOKEN , NamespaceCache.SLIDE_URI);
                    // retry with default (DAV:) namespace which was the
                    // former namespace of this property
                    rNrd.removeProperty( I_CHECKIN_LOCKTOKEN );
                    rNrd.removeProperty(P_PREDECESSOR_SET);
                    rNrd.removeProperty(P_CHECKOUT_FORK);
                    rNrd.removeProperty(P_CHECKIN_FORK);
                }
            }
           
            vhrNrd.setLastModified( new Date() ); // P_GETLASTMODIFIED
            vhrNrd.setProperty( new NodeProperty(
                                   P_VERSION_SET, ((String)vSetProp.getValue())+pHelp.createHrefValue(vrUriNew)) );
           
            vrNrdNew.setName( rNrd.getName() ); // P_DISPLAYNAME
            vrNrdNew.setCreationDate( new Date() ); // P_CREATIONDATE
            vrNrdNew.setLastModified( new Date() ); // P_GETLASTMODIFIED
            vrNrdNew.setETag( PropertyHelper.computeEtag(vrUriNew, vrNrdNew)  ); // P_GETETAG
            vrNrdNew.setProperty(
                new NodeProperty(P_VERSION_NAME, vrUhNew.getVersionName()) );
            vrNrdNew.setProperty(
                new NodeProperty(P_PREDECESSOR_SET, predSetProp.getValue()) );

            // Store changes
            if( keepCheckedOut || !isWorkingResource ) {
View Full Code Here

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

            Iterator iterator = predecessors.iterator();
            while (iterator.hasNext()) {
                String href = ((Element)iterator.next()).getTextTrim();
                if (href != null) {
                   
                    UriHandler predecessorUriHandler = UriHandler.getUriHandler( href);
                   
                    // check precondition C_VERSION_HISTORY_IS_TREE
                    if ( !predecessorUriHandler.isVersionUri() ||
                        !vhrNrds.getUri().equals(predecessorUriHandler.getAssociatedHistoryUri()) ) {
                        return new ViolatedPrecondition(C_VERSION_HISTORY_IS_TREE, WebdavStatus.SC_FORBIDDEN);
                    }
                   
                    // check precondition C_CHECKIN_FORK_FORBIDDEN
                    NodeRevisionNumber predecessorNrn = new NodeRevisionNumber(predecessorUriHandler.getVersionName());
                    NodeRevisionDescriptor predecessorNrd = content.retrieve(stok,
                                                                             vhrNrds,
                                                                             predecessorNrn);
                    NodeProperty predecessorCheckinForkProperty = predecessorNrd.getProperty(P_CHECKIN_FORK);
                    if (predecessorCheckinForkProperty != null) {
                       
                        Enumeration predecessorSuccessors = vhrNrds.getSuccessors(predecessorNrn);
                        if ( (predecessorSuccessors != null) &&
                                (predecessorSuccessors.hasMoreElements()) &&
                                (predecessorCheckinForkProperty.getValue() != null) ) {
                           
                            String checkinFork = getElementName(predecessorCheckinForkProperty.getValue().toString());
                           
                            if (E_FORBIDDEN.equals(checkinFork)) {
                                return new ViolatedPrecondition(C_CHECKIN_FORK_FORBIDDEN, WebdavStatus.SC_FORBIDDEN);
                            }
                               
                                // check precondition C_CHECKIN_FORK_DISCOURAGED
                            else if (E_DISCOURAGED.equals(checkinFork) && !isForkOk ) {
                                return new ViolatedPrecondition(C_CHECKIN_FORK_DISCOURAGED, WebdavStatus.SC_CONFLICT);
                            }
                        }
                    }
                   
                    // check precondition C_NO_OVERWRITE_BY_AUTO_UPDATE
                    if( autoUpdNrd != null ) {
                        NodeProperty cinProp = autoUpdNrd.getProperty( P_CHECKED_IN );
                        if( cinProp != null ) {
                            Element cinHrefElm = pHelp.parsePropertyValue( (String)cinProp.getValue() );
                            UriHandler cinUh = new UriHandler( cinHrefElm.getTextTrim() );
                            NodeRevisionNumber cinNrn = new NodeRevisionNumber( cinUh.getVersionName() );
                            if( !vhrNrds.getUri().equals(cinUh.getAssociatedHistoryUri()) ) {
                                // violation
                                return new ViolatedPrecondition(C_NO_OVERWRITE_BY_AUTO_UPDATE, WebdavStatus.SC_CONFLICT);
                            }
                            if( !vhrNrds.isAncestorDescendant(cinNrn, predecessorNrn) ) {
                                // violation
View Full Code Here

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

            Iterator iterator = predecessors.iterator();
            if (iterator.hasNext()) {
                String href = ((Element)iterator.next()).getTextTrim();
                if (href != null) {
                   
                    UriHandler predecessorUriHandler = UriHandler.getUriHandler( href);
                   
                    NodeRevisionNumber predecessorNrn = new NodeRevisionNumber(predecessorUriHandler.getVersionName());
                    NodeRevisionDescriptor predecessorNrd = content.retrieve(sToken,
                                                                             vhrNrds,
                                                                             predecessorNrn);
                    NodeProperty predecessorCheckinForkProperty = predecessorNrd.getProperty(P_CHECKIN_FORK);
                    if (predecessorCheckinForkProperty != null) {
View Full Code Here

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

            content.retrieve( sToken, revisionDescriptors);
        ResourceKind resourceKind = AbstractResourceKind.determineResourceKind( nsaToken, resourcePath, revisionDescriptor);
       
        if ( (resourceKind instanceof VersionControlled) && (label != null) ) {
            String vrUri = getUriOfAssociatedVR(nsaToken, sToken, content, revisionDescriptors.getUri());
            UriHandler vrUriHandler = UriHandler.getUriHandler(vrUri);
            String historyUri = vrUriHandler.getAssociatedHistoryUri();
            revisionDescriptors = content.retrieve(sToken, historyUri);
            revisionDescriptor = retrieveLabeledRevision(nsaToken, sToken, content, historyUri, label);
        }
        return getUri(nsaToken, sToken, content, revisionDescriptors, revisionDescriptor);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.