Package org.apache.slide.common

Examples of org.apache.slide.common.Uri


        throws ObjectNotFoundException, AccessDeniedException,
        LinkedObjectNotFoundException, ServiceAccessException,
        RevisionDescriptorNotFoundException, ObjectLockedException {
       
        NodeRevisionDescriptor result;
        Uri objectUri = namespace.getUri(token, revisionDescriptors.getUri());
        NodeRevisionNumber latestNrn =
            redirectLatestRevisionNumber( revisionDescriptors.getOriginalUri() );
       
        NodeRevisionDescriptors realRevisionDescriptors = objectUri.getStore()
            .retrieveRevisionDescriptors(objectUri);
       
        if( latestNrn == null ) {
            result = retrieve( token, revisionDescriptors,
                              realRevisionDescriptors.getLatestRevision());
View Full Code Here


            (token, associatedObject,
             namespaceConfig.getReadRevisionContentAction());
        lockHelper.checkLock(token, associatedObject,
                             namespaceConfig.getReadRevisionContentAction());
       
        Uri objectUri = namespace.getUri(token, strUri);
        NodeRevisionContent revisionContent =
            objectUri.getStore().retrieveRevisionContent(objectUri,
                                                         revisionDescriptor);
       
        // Invoke interceptors
        invokeInterceptors(token, null, revisionDescriptor,
                           revisionContent, POST_RETRIEVE);
View Full Code Here

            lockHelper.checkLock
                (token, associatedObject,
                 namespaceConfig.getCreateRevisionContentAction());
        }
       
        Uri objectUri = namespace.getUri(token, strUri);
       
        NodeRevisionDescriptors revisionDescriptors =
            new NodeRevisionDescriptors(isVersioned);
        revisionDescriptors.setUri(strUri);
        objectUri.getStore()
            .createRevisionDescriptors(objectUri, revisionDescriptors);
       
    }
View Full Code Here

            if (revisionDescriptor.getName() == null || revisionDescriptor.getName().length() == 0) {
                revisionDescriptor.setName(new UriPath(strUri).lastSegment());
            }
        }
       
        Uri objectUri = namespace.getUri(token, strUri);
       
        NodeRevisionDescriptors revisionDescriptors = null;
        try {
            revisionDescriptors = objectUri.getStore()
                .retrieveRevisionDescriptors(objectUri);
        } catch (RevisionDescriptorNotFoundException e) {
            // No revision descriptors. We have to create some.
            revisionDescriptors = new NodeRevisionDescriptors();
            revisionDescriptors.setUri(objectUri.toString());
            objectUri.getStore()
                .createRevisionDescriptors(objectUri, revisionDescriptors);
        }
       
        // Retrieve the latest revision from the descriptor,
        // unless there is no revisions. We generate a new revision number,
        // basing on an existing revision, if any.
        NodeRevisionNumber newRevisionNumber = null;
        if (revisionDescriptors.isVersioned()) {
           
            if (revisionDescriptors.hasRevisions()) {
                newRevisionNumber = new NodeRevisionNumber
                    (revisionDescriptors.getLatestRevision());
                revisionDescriptors
                    .addSuccessor(revisionDescriptors.getLatestRevision(),
                                  newRevisionNumber);
                revisionDescriptors
                    .setSuccessors(newRevisionNumber, new Vector());
            } else {
                newRevisionNumber = new NodeRevisionNumber();
                revisionDescriptors
                    .setSuccessors(newRevisionNumber, new Vector());
            }
            // We now set the newly created revision as the latest revison
            revisionDescriptors.setLatestRevision(newRevisionNumber);
           
            // We update the descriptor
            revisionDescriptor.setRevisionNumber(newRevisionNumber);
           
            // Invoke interceptors
            invokeInterceptors(token, revisionDescriptors, revisionDescriptor,
                               revisionContent, PRE_STORE);
           
            if (revisionContent != null) {
                // Storing the new revision contents
                objectUri.getStore()
                    .createRevisionContent(objectUri, revisionDescriptor,
                                           revisionContent);
            }
            // Now creating the revision desriptor in the store
            revisionDescriptor.setModificationDate(revisionDescriptor.getCreationDate());
            revisionDescriptor.setModificationUser(
                securityHelper.getPrincipal(token).getPath().lastSegment());
            objectUri.getStore()
                .createRevisionDescriptor(objectUri, revisionDescriptor);
           
        } else {
            // We don't use versioning for this object.
            // Two options :
            // - The object already has one (and only one) revision,
            //   so we update it
            // - The object dooesn't have any revisions right now, so we create
            //   the initial revision
            newRevisionNumber = new NodeRevisionNumber();
            revisionDescriptor.setRevisionNumber(newRevisionNumber);
           
            if (!revisionDescriptors.hasRevisions()) {
               
                // Invoke interceptors
                invokeInterceptors(token, revisionDescriptors,
                                   revisionDescriptor,
                                   revisionContent, PRE_STORE);
               
                if (revisionContent != null) {
                    // Storing the new revision contents
                    objectUri.getStore()
                        .createRevisionContent(objectUri, revisionDescriptor,
                                               revisionContent);
                }
                // Now creating the revision desriptor in the store
                revisionDescriptor.setModificationDate(revisionDescriptor.getCreationDate());
                revisionDescriptor.setModificationUser(
                    securityHelper.getPrincipal(token).getPath().lastSegment());
                objectUri.getStore()
                    .createRevisionDescriptor(objectUri, revisionDescriptor);
               
            } else {
               
                try { {
                        // merge the new received properties into the
                        // revisionDescriptor
                       
                        // We update the descriptor's properties
                        NodeRevisionDescriptor oldRevisionDescriptor =
                            objectUri.getStore()
                            .retrieveRevisionDescriptor
                            (objectUri, newRevisionNumber);
                        Enumeration newPropertiesList =
                            revisionDescriptor.enumerateProperties();
                        while (newPropertiesList.hasMoreElements()) {
                            oldRevisionDescriptor
                                .setProperty((NodeProperty) newPropertiesList
                                                 .nextElement() );
                        }
                       
                        // now use the merged revision descriptor
                        revisionDescriptor = oldRevisionDescriptor;
                    } // end of merge
                   
                    // Invoke interceptors
                    invokeInterceptors(token, revisionDescriptors,
                                       revisionDescriptor,
                                       revisionContent, PRE_STORE);
                   
                    if (revisionContent != null) {
                        // Storing the new revision contents
                        try {
                            objectUri.getStore()
                                .storeRevisionContent(objectUri,
                                                      revisionDescriptor,
                                                      revisionContent);
                        } catch (RevisionNotFoundException e) {
                            objectUri.getStore()
                                .createRevisionContent(objectUri,
                                                       revisionDescriptor,
                                                       revisionContent);
                        }
                    }
                   
                    revisionDescriptor.setModificationDate(revisionDescriptor.getCreationDate());
                    revisionDescriptor.setModificationUser(
                        securityHelper.getPrincipal(token).getPath().lastSegment());
                    objectUri.getStore()
                        .storeRevisionDescriptor
                        (objectUri, revisionDescriptor);
                   
                } catch (RevisionDescriptorNotFoundException e) {
                    // Should NEVER happen.
                    // Basically, it would mean that there is no initial
                    // revision, which is incorrect since the object
                    // HAS revisions.
                   
                    // Invoke interceptors
                    invokeInterceptors(token, revisionDescriptors,
                                       revisionDescriptor,
                                       revisionContent, PRE_STORE);
                   
                    revisionDescriptor.setModificationDate(revisionDescriptor.getCreationDate());
                    revisionDescriptor.setModificationUser(
                        securityHelper.getPrincipal(token).getPath().lastSegment());
                    objectUri.getStore()
                        .createRevisionDescriptor(objectUri,
                                                  revisionDescriptor);
                }
            }
            // Updating the descriptors object
            revisionDescriptors
                .setSuccessors(newRevisionNumber, new Vector());
            revisionDescriptors.setLatestRevision(newRevisionNumber);
        }
       
        // We now store the updated revision descriptors
        try {
            objectUri.getStore()
                .storeRevisionDescriptors(objectUri, revisionDescriptors);
        } catch (RevisionDescriptorNotFoundException e) {
            // Problem ...
            e.printStackTrace();
        }
View Full Code Here

        BranchNotFoundException {
       
        // Check parent exists and is not lock-null
        checkParentExists(strUri, token);
       
        Uri objectUri = namespace.getUri(token, strUri);
       
        NodeRevisionDescriptors revisionDescriptors = objectUri.getStore()
            .retrieveRevisionDescriptors(objectUri);
       
        if( branch != null ) {
            // Retrieving latest revision numbers
            NodeRevisionNumber branchLatestRevisionNumber =
View Full Code Here

            (token, associatedObject,
             namespaceConfig.getCreateRevisionContentAction());
        lockHelper.checkLock(token, associatedObject,
                             namespaceConfig.getCreateRevisionContentAction());
       
        Uri objectUri = namespace.getUri(token, strUri);
       
        // Retrieve the revision table
        NodeRevisionDescriptors revisionDescriptors =
            objectUri.getStore()
            .retrieveRevisionDescriptors(objectUri);
       
        if (!revisionDescriptors.isVersioned()) {
            // Invalid function call : we try to create a revision, but the
            // descriptors won't allow it
            throw new NodeNotVersionedException(strUri);
        }
       
        // Retrieving the revision on which the new branch is based.
        NodeRevisionDescriptor basedOnRevisionDescriptor =
            objectUri.getStore().retrieveRevisionDescriptor
            (objectUri, basedOnRevisionNumber);
        NodeRevisionContent basedOnRevisionContent = null;
        try {
            basedOnRevisionContent =
                objectUri.getStore().retrieveRevisionContent
                (objectUri,
                 basedOnRevisionDescriptor);
        } catch (RevisionNotFoundException e) {
        }
       
        // Create a revision number suited for the new branch
        NodeRevisionNumber branchedRevisionNumber =
            new NodeRevisionNumber(basedOnRevisionNumber, true);
       
        basedOnRevisionDescriptor.setRevisionNumber(branchedRevisionNumber);
        basedOnRevisionDescriptor.setBranchName(branchName);
       
        revisionDescriptors.setUri(strUri);
        revisionDescriptors.setLatestRevision
            (branchName, branchedRevisionNumber);
        revisionDescriptors.addSuccessor
            (basedOnRevisionNumber, branchedRevisionNumber);
       
        // Invoke interceptors
        invokeInterceptors(token, revisionDescriptors,
                           basedOnRevisionDescriptor,
                           basedOnRevisionContent, PRE_STORE);
       
        // Storing back everything
        // TODO: setModificationDate
        //       clone of NRD required??
        if (basedOnRevisionContent != null) {
            objectUri.getStore().createRevisionContent
                (objectUri, basedOnRevisionDescriptor, basedOnRevisionContent);
        }
        objectUri.getStore().createRevisionDescriptor
            (objectUri, basedOnRevisionDescriptor);
        objectUri.getStore().storeRevisionDescriptors
            (objectUri, revisionDescriptors);
       
        // Invoke interceptors
        invokeInterceptors(token, revisionDescriptors,
                           basedOnRevisionDescriptor,
View Full Code Here

        throws SlideRuntimeException
    {
        BasicQueryImpl query = null;
       
//      Uri uri = new Uri (namespace, slideScope);
        Uri uri = namespace.getUri(token.getSlideToken(), slideScope);
       
       
        AbstractStore store = (AbstractStore)uri.getStore();
        String className = (String)store.getParameter
            (BasicSearchLanguage.BASIC_QUERY_CLASS);
       
        if (className != null) {
            try {
View Full Code Here

        lockHelper.checkLock(token, associatedObject,
                             namespaceConfig.getCreateRevisionContentAction());
       
        setDefaultProperties(associatedObject, newRevisionDescriptor);
       
        Uri objectUri = namespace.getUri(token, strUri);
       
        // Retrieve the revision table
        NodeRevisionDescriptors revisionDescriptors =
            objectUri.getStore().retrieveRevisionDescriptors(objectUri);
       
        if (!revisionDescriptors.isVersioned()) {
            // Invalid function call : we try to create a revision, but the
            // descriptors won't allow it
            throw new NodeNotVersionedException(strUri);
        }
       
        // Retrieving latest revision numbers
        NodeRevisionNumber mainBranchLatestRevisionNumber =
            revisionDescriptors.getLatestRevision(mainBranch);
        NodeRevisionNumber branchLatestRevisionNumber =
            revisionDescriptors.getLatestRevision(branch);
       
        if (mainBranchLatestRevisionNumber == null) {
            throw new BranchNotFoundException(strUri, mainBranch);
        }
        if (branchLatestRevisionNumber == null) {
            throw new BranchNotFoundException(strUri, branch);
        }
       
        NodeRevisionNumber newRevisionNumber =
            new NodeRevisionNumber(mainBranchLatestRevisionNumber);
       
        newRevisionDescriptor.setRevisionNumber(newRevisionNumber);
        newRevisionDescriptor.setBranchName(branch);
       
        revisionDescriptors.addSuccessor
            (mainBranchLatestRevisionNumber, newRevisionNumber);
        revisionDescriptors.addSuccessor
            (branchLatestRevisionNumber, newRevisionNumber);
        revisionDescriptors.setLatestRevision(mainBranch, newRevisionNumber);
       
        // Invoke interceptors
        invokeInterceptors(token, revisionDescriptors, newRevisionDescriptor,
                           revisionContent, PRE_STORE);
       
        // Storing back everything
        if (revisionContent != null) {
            objectUri.getStore().createRevisionContent
                (objectUri, newRevisionDescriptor, revisionContent);
        }
        newRevisionDescriptor.setModificationDate(newRevisionDescriptor.getCreationDate());
        newRevisionDescriptor.setModificationUser(
            securityHelper.getPrincipal(token).getPath().lastSegment());
        objectUri.getStore().createRevisionDescriptor
            (objectUri, newRevisionDescriptor);
        objectUri.getStore().storeRevisionDescriptors
            (objectUri, revisionDescriptors);
       
        // Invoke interceptors
        invokeInterceptors(token, revisionDescriptors, newRevisionDescriptor,
                           revisionContent, POST_STORE);
View Full Code Here

    public void setPermissions(SlideToken token, String object,
                               Enumeration permissions)
        throws ServiceAccessException, ObjectNotFoundException,
        AccessDeniedException {
       
        Uri objectUri = namespace.getUri(token, object);
        ObjectNode objectNode = objectUri.getStore().retrieveObject(objectUri);
       
        checkCredentials(token, objectNode,
                         namespaceConfig.getGrantPermissionAction());
        checkCredentials(token, objectNode,
                         namespaceConfig.getRevokePermissionAction());
       
        objectUri.getStore().revokePermissions(objectUri);
       
        while (permissions.hasMoreElements()) {
            NodePermission permission =
                (NodePermission) permissions.nextElement();
            objectUri.getStore().grantPermission(objectUri, permission);
        }
       
    }
View Full Code Here

     */
    public void grantPermission(SlideToken token,
                                NodePermission permission)
        throws ServiceAccessException, ObjectNotFoundException,
        AccessDeniedException {
        Uri objectUri = namespace.getUri(token, permission.getObjectUri());
        ObjectNode object = objectUri.getStore()
            .retrieveObject(objectUri);
       
        // Checking if the permission is already present
        Enumeration permissions = enumeratePermissions(token, object);
        boolean alreadyPresent = false;
        while (permissions.hasMoreElements() && !alreadyPresent) {
            if (permission.equals(permissions.nextElement())) {
                alreadyPresent = true;
            }
        }
       
        if (!alreadyPresent) {
            checkCredentials(token, object,
                             namespaceConfig.getGrantPermissionAction());
            objectUri.getStore().grantPermission(objectUri, permission);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.slide.common.Uri

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.