Package org.apache.slide.common

Examples of org.apache.slide.common.Uri


        lockHelper.checkLock(token, associatedObject,
                             namespaceConfig.getModifyRevisionContentAction());
       
        setDefaultProperties(associatedObject, revisionDescriptor);
       
        Uri objectUri = namespace.getUri(token, strUri);
       
        // Retrieve the revision table
        NodeRevisionDescriptors revisionDescriptors =
            objectUri.getStore().retrieveRevisionDescriptors(objectUri);
        NodeRevisionDescriptor oldRevisionDescriptor =
            objectUri.getStore().retrieveRevisionDescriptor
            (objectUri, revisionDescriptor.getRevisionNumber());
       
        // Invoke interceptors
        invokeInterceptors(token, revisionDescriptors, revisionDescriptor,
                           revisionContent, PRE_STORE);
       
        if (revisionContent != null) {
            try {
                // Removed retrieveContent call [pnever, 25-APR-2003].
                // Reasons:
                // - it is not necessary to check existence because storeRevisionContent also throws RevisionNotFoundException
                // - it is harmful for filesystem-based stores, as the input streams created by retrieveRevisionContent never are closed
                // Simple scenario:
                // Use the FileContentStore, create a file, update it and then try to delete it.
                // It will not be deleted from the filesystem.
                //
                //                objectUri.getStore().retrieveRevisionContent
                //                    (objectUri, revisionDescriptor);
                objectUri.getStore().storeRevisionContent
                    (objectUri, revisionDescriptor, revisionContent);
            } catch (RevisionNotFoundException e) {
                try {
                    objectUri.getStore().createRevisionContent
                        (objectUri, revisionDescriptor, revisionContent);
                } catch (RevisionAlreadyExistException ex) {
                    // Should never happen
                    ex.printStackTrace();
                }
            }
        }
        revisionDescriptor.setModificationDate(new Date());
        revisionDescriptor.setModificationUser(
            securityHelper.getPrincipal(token).getPath().lastSegment());
        objectUri.getStore().storeRevisionDescriptor
            (objectUri, revisionDescriptor);
       
        // Invoke interceptors
        invokeInterceptors(token, revisionDescriptors, revisionDescriptor,
                           revisionContent, POST_STORE);
View Full Code Here


            (token, associatedObject,
             namespaceConfig.getRemoveRevisionContentAction());
        lockHelper.checkLock(token, associatedObject,
                             namespaceConfig.getRemoveRevisionContentAction());
       
        Uri objectUri = namespace.getUri(token, revisionDescriptors.getUri());
        objectUri.getStore().removeRevisionDescriptors(objectUri);
       
        // Invoke interceptors
        invokeInterceptors(token, revisionDescriptors, null, null,
                           POST_REMOVE);
    }
View Full Code Here

            (token, associatedObject,
             namespaceConfig.getRemoveRevisionContentAction());
        lockHelper.checkLock(token, associatedObject,
                             namespaceConfig.getRemoveRevisionContentAction());
       
        Uri objectUri = namespace.getUri(token, strUri);
       
        NodeRevisionDescriptor revisionDescriptor =
            objectUri.getStore().retrieveRevisionDescriptor
            (objectUri, revisionNumber);
       
        // Invoke interceptors
        invokeInterceptors(token, null, revisionDescriptor, null, PRE_REMOVE);
       
        objectUri.getStore().removeRevisionContent
            (objectUri, revisionDescriptor);
        objectUri.getStore()
            .removeRevisionDescriptor(objectUri, revisionNumber);
       
        // Invoke interceptors
        invokeInterceptors(token, null, revisionDescriptor, null, POST_REMOVE);
    }
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);
        }
       
        // Retrieve the old revision descriptor, just to make sure that the old
        //  revision we base the new one upon really exists
        NodeRevisionDescriptor realOldRevisionDescriptor =
            objectUri.getStore().retrieveRevisionDescriptor
            (objectUri, basedOnRevisionNumber);
       
        // We check that the old revision doesn't have successors, that is we :
        // - check to see if it's the latest revision in a branch
        // - store that information for later use
        NodeRevisionNumber latestNumberInBranch =
            revisionDescriptors.getLatestRevision
            (realOldRevisionDescriptor.getBranchName());
        if (!realOldRevisionDescriptor.getRevisionNumber()
            .equals(latestNumberInBranch)) {
            throw new RevisionAlreadyExistException
                (objectUri.toString(), new NodeRevisionNumber
                     (basedOnRevisionNumber));
        }
       
        // Next, generate the new revision's number
        newRevisionDescriptor.setRevisionNumber
            (new NodeRevisionNumber(basedOnRevisionNumber));
        // Set the creation date
        newRevisionDescriptor.setCreationDate(new Date());
       
        // Set the creation user
        setCreationUser(token, newRevisionDescriptor);
       
        // Initialize the branch name in the new descriptor
        newRevisionDescriptor.setBranchName
            (realOldRevisionDescriptor.getBranchName());
       
        // Invoke interceptors
        invokeInterceptors(token, revisionDescriptors, newRevisionDescriptor,
                           revisionContent, PRE_STORE);
       
        // Update the revision graph in the revision descriptors
        revisionDescriptors
            .addSuccessor(revisionDescriptors.getLatestRevision(newRevisionDescriptor.getBranchName()),
                          newRevisionDescriptor.getRevisionNumber());
        revisionDescriptors
            .setSuccessors(newRevisionDescriptor.getRevisionNumber(), new Vector());
        revisionDescriptors
            .setLatestRevision(newRevisionDescriptor.getBranchName(),
                               newRevisionDescriptor.getRevisionNumber());
        if (revisionContent != null) {
            // Storing the new revision contents
            objectUri.getStore()
                .createRevisionContent(objectUri, newRevisionDescriptor,
                                       revisionContent);
        }
        // Now creating the revision desriptor in the store
        newRevisionDescriptor.setModificationDate(newRevisionDescriptor.getCreationDate());
        newRevisionDescriptor.setModificationUser(
            securityHelper.getPrincipal(token).getPath().lastSegment());
        objectUri.getStore()
            .createRevisionDescriptor(objectUri, newRevisionDescriptor);
       
        // We now store the updated revision descriptors
        try {
            objectUri.getStore()
                .storeRevisionDescriptors(objectUri, revisionDescriptors);
        } catch (RevisionDescriptorNotFoundException e) {
            // Problem ...
            e.printStackTrace();
        }
View Full Code Here

        lockHelper.checkLock(token, associatedObject,
                             namespaceConfig.getCreateRevisionContentAction());
       
        setDefaultProperties(associatedObject, revisionDescriptor);
       
        Uri objectUri = namespace.getUri(token, strUri);
       
        // Retrieve the revision table
        NodeRevisionDescriptors revisionDescriptors =
            objectUri.getStore()
            .retrieveRevisionDescriptors(objectUri);
       
        // Set the creation date
        revisionDescriptor.setCreationDate(new Date());
       
        // Set the creation user
        setCreationUser(token, revisionDescriptor);
       
        // Initialize the branch name in the new descriptor
        String branchName = "backup";
        NodeProperty rootVersionProperty = revisionDescriptor.getProperty("version-set");
        if (rootVersionProperty != null) {
            branchName = "version-history";
        }
        revisionDescriptor.setBranchName(branchName);
       
        // Invoke interceptors
        invokeInterceptors(token, revisionDescriptors, revisionDescriptor,
                           null, PRE_STORE);
       
        // Now creating the revision desriptor in the store
        revisionDescriptor.setModificationDate(revisionDescriptor.getCreationDate());
        revisionDescriptor.setModificationUser(
            securityHelper.getPrincipal(token).getPath().lastSegment());
        objectUri.getStore()
            .createRevisionDescriptor(objectUri, revisionDescriptor);
       
        // We now store the updated revision descriptors
        try {
            objectUri.getStore()
                .storeRevisionDescriptors(objectUri, revisionDescriptors);
        } catch (RevisionDescriptorNotFoundException e) {
            // Problem ...
            e.printStackTrace();
        }
View Full Code Here

        boolean denied = false;
        boolean rootObjectReached = false;
       
        ObjectNode courObject = object;
       
        Uri subjectUri = namespace.getUri(subject.getUri());
        Uri actionUri = namespace.getUri(action.getUri());
       
        // check if allready granded
       
        while (!granted && !denied && !rootObjectReached) {
           
            Uri courUri = namespace.getUri(courObject.getUri());
            Enumeration permissions = courUri.getStore()
                .enumeratePermissions(courUri);
           
            while (!granted && !denied && permissions.hasMoreElements()) {
               
                boolean oldGranted = granted;
                boolean oldDenied = denied;
               
                NodePermission permission =
                    (NodePermission) permissions.nextElement();
                String permissionSubject = permission.getSubjectUri();

                if (permissionSubject == SubjectNode.SELF_URI) {
                    boolean check;
                    check = object.getUri().equals(subjectUri.toString());
                    if (permission.isInheritable()) {
                        String subjectUriString = subjectUri.toString();
                        if(!subjectUriString.endsWith("/"))
                            subjectUriString = subjectUriString + "/";
                       
                        check |= object.getUri().startsWith(subjectUriString);
                    }
                   
                    // Self permission
                    granted = (!permission.isNegative())
                        && (check)
                        && (actionUri.toString()
                                .startsWith(permission.getActionUri()));
                    denied = (permission.isNegative())
                        && (check)
                        && (actionUri.toString()
                                .startsWith(permission.getActionUri()));
                   
                } else if (permission.isInheritable()
                           || permission.getObjectUri().equals(object.getUri())) {
                   
                    if (permissionSubject.startsWith("/") || permissionSubject == SubjectNode.ALL_URI) {
                       
                        // Node permission
                        String permSubj = permission.getSubjectUri();
                        String permActn = permission.getActionUri();
                        boolean match = false;
                        if (permSubj == SubjectNode.ALL_URI) {
                            match = true;
                        }
                        else {
                            if(!permSubj.endsWith("/"))
                                permSubj = permSubj + "/";
                            match = subjectUri.toString().
                                equals(permission.getSubjectUri()) ||
                                subjectUri.toString().startsWith(permSubj);
                        }
                        if (permActn == ActionNode.ALL_URI) {
                            match &= true;
                        }
                        else {
                            match &= actionUri.toString().
                                startsWith(permActn);
                        }
                       
                        granted = (!permission.isNegative()) && match;
                        denied = permission.isNegative() && match;
                       
                    } else if (permissionSubject.startsWith("+")) {
                       
                        // Permission group which needs to be expanded
                        Uri permissionSubjectUri =
                            namespace.getUri(permissionSubject.substring(1));
                        ObjectNode group;
                        try {
                            group = permissionSubjectUri.getStore().retrieveObject(permissionSubjectUri);
                        } catch (ObjectNotFoundException onfe) {
                            namespace.getLogger().log(
                                "Gracefully ignoring permission of dangling subject " + permissionSubjectUri,
                                onfe,
                                LOG_CHANNEL,
                                Logger.WARNING);
                            // as a fix of bug #27018, gracefully ignore permissions having dangling subjects
                            continue;
                        }
                        // if the node is a GroupNode, expand it out to
                        // normal permissions
                        if (group instanceof
                            org.apache.slide.structure.GroupNode ) {
                            if (group.hasChildren()) {
                                Enumeration groupMembers =
                                    group.enumerateChildren();
                                // parse thru the children of the group and
                                // check permissions on each
                                while (groupMembers.hasMoreElements()) {
                                   
                                    oldGranted = granted;
                                    oldDenied = denied;
                                   
                                    Uri childUri =
                                        namespace.getUri
                                        ((String) groupMembers.nextElement());
                                    ObjectNode childNode;
                                    try {
                                        childNode = childUri.getStore().retrieveObject(childUri);
                                    } catch (ObjectNotFoundException onfe) {
                                        namespace.getLogger().log(
                                            "Gracefully ignoring permission of dangling subject "
                                                + childUri,
                                            onfe,
                                            LOG_CHANNEL,
                                            Logger.WARNING);
                                        // as a fix of bug #27018, gracefully ignore permissions having dangling subjects
                                        continue;
                                    }
                                    String childSubjectUri = childNode
                                        instanceof LinkNode ?
                                        ((LinkNode) childNode)
                                        .getLinkedUri() :
                                        childNode.getUri() ;
                                   
                                    String testUri;
                                    if(!childSubjectUri.endsWith("/"))
                                        testUri = childSubjectUri+"/";
                                    else
                                        testUri = childSubjectUri;
                                   
                                    boolean match = subjectUri.toString().
                                        equals(childSubjectUri) ||
                                        subjectUri.toString().
                                        startsWith(testUri);
                                    match &= actionUri.toString().
                                        startsWith(permission.getActionUri());
                                   
                                    granted = (!permission.isNegative()) &&
                                        match;
                                    denied = permission.isNegative() && match;
                                   
                                    granted = granted | oldGranted;
                                    denied = denied | oldDenied;
                                   
                                }
                            }
                        }
                       
                    } else {
                       
                        // Role permission
                        granted = (!permission.isNegative())
                            && (hasRole(subject, permissionSubject))
                            && (actionUri.toString()
                                    .startsWith(permission.getActionUri()));
                        denied = (permission.isNegative())
                            && (hasRole(subject, permissionSubject))
                            && (actionUri.toString()
                                    .startsWith(permission.getActionUri()));
                       
                    }
                   
                }
               
                granted = granted | oldGranted;
                denied = denied | oldDenied;
               
            }
           
            Uri parentUri = courUri.getParentUri();
           
            if (parentUri != null) {
                courObject = parentUri.getStore()
                    .retrieveObject(parentUri);
            } else {
                rootObjectReached = true;
            }
        }
View Full Code Here

     * @throws   ServiceAccessException
     * @throws   ObjectNotFoundException
     */
    public Enumeration getRoles(SlideToken token, SubjectNode subjectNode) throws ServiceAccessException, ObjectNotFoundException {
        // check the principal exists
        Uri subjectUri = namespace.getUri(token, subjectNode.getUri());
        subjectUri.getStore().retrieveObject(subjectUri);
       
        Vector result = new Vector();
        Uri rolesUri = null;
        ObjectNode rolesNode = null;
        if (namespaceConfig.getRolesPath() != null && namespaceConfig.getRolesPath().length() != 0) {
            rolesUri = namespace.getUri(token, namespaceConfig.getRolesPath());
            try {
                rolesNode = rolesUri.getStore().retrieveObject(rolesUri);
            } catch (ObjectNotFoundException e) {}
            if (rolesNode != null) {
                Enumeration rolesEnum = rolesNode.enumerateBindings();
                while (rolesEnum.hasMoreElements()) {
                    ObjectNode.Binding b = (ObjectNode.Binding)rolesEnum.nextElement();
                    String role = b.getName();
                    if (hasRole(token, subjectNode, role)) {
                        result.add(role);
                    }
                }
            }
        }
        Uri groupsUri = null;
        ObjectNode groupsNode = null;
        if (namespaceConfig.getGroupsPath() != null && namespaceConfig.getGroupsPath().length() != 0) {
            groupsUri = namespace.getUri(token, namespaceConfig.getGroupsPath());
            groupsNode = groupsUri.getStore().retrieveObject(groupsUri);
            if (groupsNode != null) {
                Enumeration groupsEnum = groupsNode.enumerateBindings();
                while (groupsEnum.hasMoreElements()) {
                    ObjectNode.Binding b = (ObjectNode.Binding)groupsEnum.nextElement();
                    String group = b.getName();
View Full Code Here

     * @throws   ServiceAccessException
     * @throws   ObjectNotFoundException
     */
    public Enumeration getGroupMembership(SlideToken token, SubjectNode subjectNode) throws ServiceAccessException, ObjectNotFoundException {
        // check the principal exists
        Uri subjectUri = namespace.getUri(token, subjectNode.getUri());
        subjectUri.getStore().retrieveObject(subjectUri);
       
        Vector result = new Vector();
        Uri rolesUri = null;
        ObjectNode rolesNode = null;
        if (namespaceConfig.getRolesPath() != null && namespaceConfig.getRolesPath().length() != 0) {
            rolesUri = namespace.getUri(token, namespaceConfig.getRolesPath());
            try {
                rolesNode = rolesUri.getStore().retrieveObject(rolesUri);
            } catch (ObjectNotFoundException e) {}
            if (rolesNode != null) {
                Enumeration rolesEnum = rolesNode.enumerateBindings();
                while (rolesEnum.hasMoreElements()) {
                    ObjectNode.Binding b = (ObjectNode.Binding)rolesEnum.nextElement();
                    String role = b.getName();
                    Uri roleUri = namespace.getUri(token, namespaceConfig.getRolesPath()+"/"+role);
                    try {
                        NodeRevisionDescriptor nrd =
                            roleUri.getStore().retrieveRevisionDescriptor(roleUri, new NodeRevisionNumber());
                        NodeProperty membersetProp = nrd.getProperty("group-member-set");
                        if (membersetProp != null && membersetProp.getValue() != null) {
                            XMLValue xmlVal = new XMLValue((String)membersetProp.getValue());
                            List memberNodes = xmlVal.getHrefNodes();
                            if (memberNodes.contains(subjectNode)) {
                                result.add(roleUri.toString());
                            }
                        }
                    } catch (RevisionDescriptorNotFoundException e) {
                    } catch (JDOMException e) {}
                }
            }
        }
        Uri groupsUri = null;
        ObjectNode groupsNode = null;
        if (namespaceConfig.getGroupsPath() != null && namespaceConfig.getGroupsPath().length() != 0) {
            groupsUri = namespace.getUri(token, namespaceConfig.getGroupsPath());
            try {
                groupsNode = groupsUri.getStore().retrieveObject(groupsUri);
            } catch (ObjectNotFoundException e) {}
            if (groupsNode != null) {
                Enumeration rolesEnum = groupsNode.enumerateBindings();
                while (rolesEnum.hasMoreElements()) {
                    ObjectNode.Binding b = (ObjectNode.Binding)rolesEnum.nextElement();
                    String group = b.getName();
                    Uri roleUri = namespace.getUri(token, namespaceConfig.getGroupsPath()+"/"+group);
                    try {
                        NodeRevisionDescriptor nrd =
                            roleUri.getStore().retrieveRevisionDescriptor(roleUri, new NodeRevisionNumber());
                        NodeProperty membersetProp = nrd.getProperty("group-member-set");
                        if (membersetProp != null && membersetProp.getValue() != null) {
                            XMLValue xmlVal = new XMLValue((String)membersetProp.getValue());
                            List memberNodes = xmlVal.getHrefNodes();
                            if (memberNodes.contains(subjectNode)) {
                                result.add(roleUri.toString());
                            }
                        }
                    } catch (RevisionDescriptorNotFoundException e) {
                    } catch (JDOMException e) {}
                }
View Full Code Here

            return matchPrincipal(token, checkSubject, permSubject);
        }
    }
   
    private boolean matchOwner(SlideToken token, ObjectNode objectNode, SubjectNode checkSubject) throws ServiceAccessException {
        Uri objectUri = namespace.getUri(token, objectNode.getUri());
        try {
            NodeRevisionDescriptor nrd =
                objectUri.getStore().retrieveRevisionDescriptor(objectUri, new NodeRevisionNumber());
            NodeProperty ownerProp = nrd.getProperty("owner");
            if (ownerProp != null && ownerProp.getValue() != null) {
                String usersPath = namespace.getConfig().getUsersPath();
                SubjectNode ownerSubject = SubjectNode.getSubjectNode(usersPath+"/"+ownerProp.getValue());
                return ownerSubject.equals(checkSubject);
View Full Code Here

   
    public ObjectNode getParent(SlideToken token, ObjectNode object)
        throws ServiceAccessException, ObjectNotFoundException,
        LinkedObjectNotFoundException, AccessDeniedException {
        String objectUriStr = object.getUri();
        Uri parentUri = namespace.getUri(token, objectUriStr).getParentUri();
        if (parentUri == null) {
            return null;
        }
        String parentUriStr = parentUri.toString();
        ObjectNode parent = retrieve(token, parentUriStr);
        return parent;
    }
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.