Package org.apache.slide.structure

Examples of org.apache.slide.structure.ObjectNode$ParentBinding


            catch (SlideException e) {
                return getErrorResponse(resourceUri, getErrorCode(e), null);
            }
        }
       
        ObjectNode object = null;
        try {
            object = structure.retrieve(lightSToken, resourceUri);
        }
        catch (SlideException e) {
            return getErrorResponse(resourceUri, getErrorCode(e), null);
        }
       
        Element responseElement = new Element(E_RESPONSE, DNSP);
       
        String status = new String(HTTP_VERSION + WebdavStatus.SC_OK + " "
                                       + WebdavStatus.getStatusText
                                       (WebdavStatus.SC_OK));
        NodeRevisionDescriptors revisionDescriptors = null;
        NodeRevisionDescriptor revisionDescriptor = null;
       
        boolean isCollection = false;
       
        NodeLock objectLockToken = null;
       
        try {
            Element hrefElement = new Element(E_HREF, DNSP);
           
            VersioningHelper vHelp =  VersioningHelper.getVersioningHelper(
                lightSToken, token, req, resp, getConfig() );
            String resourcePath = object.getUri();
           
            revisionDescriptors =
                content.retrieve(lightSToken, resourcePath);
           
            try {
                revisionDescriptor = content.retrieve(lightSToken,
                                                      revisionDescriptors);
               
                isCollection = WebdavUtils.isCollection(revisionDescriptor);
               
                hrefElement.setText(
                    WebdavUtils.getAbsolutePath(object.getUri(), req,
                                                getConfig()));
               
            } catch (RevisionDescriptorNotFoundException e) {
               
                // The object doesn't have any revision, we create a dummy
                // NodeRevisionDescriptor object
                isCollection = true;
                revisionDescriptor = new NodeRevisionDescriptor(0);
               
                if (!Configuration.useBinding(token.getUri(lightSToken, object.getUri()).getStore())) {
                    revisionDescriptor.setName(new UriPath(object.getUri()).lastSegment());
                }
               
                hrefElement.setText(
                    WebdavUtils.getAbsolutePath(object.getUri(), req,
                                                getConfig()));
            }
           
            responseElement.addContent(hrefElement);
           
            Enumeration lockTokens = lock.enumerateLocks(lightSToken, object.getUri(), true);
           
            if (lockTokens.hasMoreElements()) {
                objectLockToken = (NodeLock) lockTokens.nextElement();
            }
           
        } catch (AccessDeniedException e) {
            if (revisionDescriptor == null) {
                revisionDescriptor = new NodeRevisionDescriptor(0);
            }
        } catch (Exception e) {
            int statusCode = getErrorCode( e );
            sendError( statusCode, e );
            throw new WebdavException( statusCode );
        }
       
        Vector propertiesParser = null;
        PropertyRetrieverImpl propertyRetriever = new PropertyRetrieverImpl(token, lightSToken, getConfig());
       
        switch (propFindType) {
            case FIND_ALL_PROP :
            case FIND_BY_PROPERTY :
                try {
                    List propstatList= propertyRetriever.getPropertiesOfObject(requestedProperties, revisionDescriptors, revisionDescriptor, req.getContextPath(), req.getServletPath(), extendedAllprop);
                    Iterator iterator = propstatList.iterator();
                    while (iterator.hasNext()) {
                        responseElement.addContent((Element)iterator.next());
                    }
                } catch (ServiceAccessException e) {
                    int statusCode = WebdavStatus.SC_FORBIDDEN;
                    sendError( statusCode, e );
                    throw new WebdavException( statusCode );
                } catch (Exception e) {
                    int statusCode = getErrorCode( e );
                    sendError( statusCode, e );
                    throw new WebdavException( statusCode );
                }
                break;
            case FIND_PROPERTY_NAMES :
               
                try {
                    status = new String("HTTP/1.1 " + WebdavStatus.SC_OK
                                            + " " + WebdavStatus.getStatusText
                                            (WebdavStatus.SC_OK));
                   
                    Element propstatElement = new Element(E_PROPSTAT, DNSP);
                    Element propElement = new Element(E_PROP, DNSP);
                    RequestedProperties propnames =
                        propertyRetriever.getAllPropertyNames(object.getUri(), true);
                    Iterator iterator = propnames.getRequestedProperties();
                    while (iterator.hasNext()) {
                        RequestedProperty p = (RequestedProperty)iterator.next();
                        Namespace nsp = DNSP.getURI().equals(p.getNamespace())
                            ? DNSP
View Full Code Here


        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();
                    if (hasRole(token, subjectNode, group)) {
                        result.add(group);
View Full Code Here

        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 {
View Full Code Here

     */
    private void writeLock(SlideToken token, String uri, boolean recursive) throws SlideException {
        if (!token.isForceStoreEnlistment()) {
            token = new SlideTokenWrapper(token, true);
        }
        ObjectNode onode = structureHelper.retrieve(token, uri);
        if (onode != null && recursive) {
            Iterator i = onode.getChildren().iterator();
            while (i.hasNext()) {
                writeLock( token, (String)i.next(), true );
            }
           
        }
View Full Code Here

        }
        //----------------
       
        UriHandler destinationUh = new UriHandler(destinationUri);
        UriHandler destinationParentUh = destinationUh.getParent();
        ObjectNode destinationParentNode = null;
        String destinationSegment = destinationUh.getLastSegment();
        UriHandler sourceUh = new UriHandler(sourceUri);
        UriHandler sourceParentUh = sourceUh.getParent();
        ObjectNode sourceParentNode = null;
        String sourceSegment = sourceUh.getLastSegment();
        ObjectNode sourceNode = null;
       
        try {
            try {
                destinationParentNode =
                    structureHelper.retrieve(token, destinationParentUh.toString(), false );
View Full Code Here

                // skip
                return;
            }
           
            // Remember children of orginal source
            ObjectNode sourceNode =
                structureHelper.retrieve(token, sourceUri, false);
            Enumeration sourceNodeChildren = sourceNode.enumerateChildren();
            ObjectNode destinationNode = null;
           
            // now let the client redirect
            if (copyRedirector != null) {  // TODO: dump re-directing
                CopyRoute copyRoute = new CopyRoute(sourceUri, destinationUri);
                copyRoute = copyRedirector.getRedirectedCopyRoute(copyRoute);
                sourceUri = copyRoute.getSourceUri();
                destinationUri = copyRoute.getDestinationUri();
                sourceNode = structureHelper.retrieve(token, sourceUri, false);
                // note that childrenList is *not* re-assigned. This might be a bug ...
            }
           
            // notify CopyListener
            if (copyListener != null) {
                copyListener.beforeCopy(sourceUri, destinationUri, isRootOfCopy );
            }
           
            // delete target if it is the root of the copied tree
            if (isRootOfCopy && parameters.isDeleteCreate()) {
                try {
                    // We make sure the object we want to overwrite exists
                    structureHelper.retrieve(token, destinationUri);
                    if (parameters.getParameter(PARENT_BINDINGS) != null) {
                        Map parentBindings = (Map)parameters.getParameter(PARENT_BINDINGS);
                        Iterator i = parentBindings.entrySet().iterator();
                        while (i.hasNext()) {
                            Map.Entry me = (Map.Entry)i.next();
                            String uriToDelete = (String)me.getKey()+"/"+(String)me.getValue();
                            delete(token, uriToDelete, deleteRedirector, deleteListener);
                        }
                    }
                    else {
                        delete(token, destinationUri, deleteRedirector, deleteListener);
                    }
                } catch(ObjectNotFoundException onf) {
                    // Silent catch, the target doesn't exist
                } catch(DeleteMacroException s) {
                    Enumeration en = s.enumerateExceptions();
                    if (en.hasMoreElements()) {
                        throw (SlideException)en.nextElement();
                    }
                }
            }
           
            boolean destinationExists = destinationExists(token, destinationUri);
           
            // Creating the copy
            if (parameters.isDeleteCreate() || !destinationExists) {
                try {
                    Map alreadyCopied = (Map)parameters.getParameter( ALREADY_COPIED );
                   
                    if (alreadyCopied.containsKey(sourceNode.getUuri())) {
                        // If a COPY request would cause a new resource to be created
                        // as a copy of an existing resource, and that COPY request
                        // has already created a copy of that existing resource,
                        // the COPY request instead creates another binding to the
                        // previous copy, instead of creating a new resource.
                        UriHandler destinationUh = new UriHandler(destinationUri);
                        UriHandler destinationParentUh = destinationUh.getParent();
                        String segment = destinationUh.getLastSegment();
                        destinationNode = structureHelper.retrieve( token, (String)alreadyCopied.get(sourceNode.getUuri()) );
                        ObjectNode destinationParentNode = structureHelper.retrieve( token, destinationParentUh.toString() );
                        structureHelper.addBinding( token, destinationParentNode, segment, destinationNode );
                    }
                    else {
                        structureHelper.create(token, sourceNode.copyObject(),
                                               destinationUri);
View Full Code Here

                              DeleteTargetRedirector deleteRedirector, DeleteListener deleteListener) {
       
        Domain.debug("Delete object : " + targetUri);
       
        try {
            ObjectNode currentObject =
                structureHelper.retrieve(token, targetUri, false);
           
            if (!Configuration.useBinding(namespace.getUri(token, targetUri).getStore()) || currentObject.numberOfParentBindings() < 2) {
                // Removing children objects
                if (currentObject.hasChildren()) {
                    Enumeration children = currentObject.enumerateChildren();
                    while (children.hasMoreElements()) {
                        String childUri = (String)children.nextElement();
                        deleteObject(token, childUri, e, deleteRedirector, deleteListener);
                    }
                }

        // Removing links objects
        if (currentObject.hasLinks()) {
          Enumeration links = currentObject.enumerateLinks();
          while (links.hasMoreElements()) {
            String linkUri = (String)links.nextElement();
            deleteObject(token, linkUri, e, deleteRedirector, deleteListener);
          }
        }
               
               
                // now let the client redirect
                if (deleteRedirector != null) {
                    targetUri = deleteRedirector.getRedirectedTargetUri(targetUri);
                    currentObject =  structureHelper.retrieve(token, targetUri, false);
                }
               
                // notify DeleteListener
                if (deleteListener != null) {
                    deleteListener.beforeDelete(targetUri);
                }
               
                NodeRevisionDescriptors revisionDescriptors =
                    contentHelper.retrieve(token, currentObject.getUri());
              
                // remove the associated locks
                Enumeration locks = lockHelper.enumerateLocks
                    (token, currentObject.getUri(), false);
                while (locks.hasMoreElements()) {
                    lockHelper.unlock(token, (NodeLock) locks.nextElement());
                }
                // remove the associated security
                Enumeration permissions = securityHelper.enumeratePermissions
                    (token, currentObject);
                while (permissions.hasMoreElements()) {
                    NodePermission permission =
                        (NodePermission) permissions.nextElement();
                    securityHelper.revokePermission(token, permission);
                }
               
                // remove all revisions
                if( !revisionDescriptors.isRedirected() ) {
                    Enumeration revisionNumberEnum =
                        revisionDescriptors.enumerateRevisionNumbers();
                    if (revisionNumberEnum != null) {
                        while (revisionNumberEnum.hasMoreElements()) {
                            contentHelper.remove
                                (token, currentObject.getUri(),
                                     (NodeRevisionNumber)revisionNumberEnum.nextElement());
                        }
                    }
                    removeHiddenRevisions( token, targetUri );
                   
View Full Code Here

    public void execute(String resourcePath, Element multistatusElm, int depth) throws SlideException, IOException {
        if (depth < 0) {
            return;
        }
        writeReport(resourcePath, multistatusElm);
        ObjectNode onode = structure.retrieve(slideToken, resourcePath);
        Enumeration childrenEnum = structure.getChildren(slideToken, onode);
        while  (childrenEnum.hasMoreElements()) {
            ObjectNode cnode = (ObjectNode)childrenEnum.nextElement();
            execute(cnode.getUri(), multistatusElm, depth-1);
        }
    }
View Full Code Here

    public void execute(String resourcePath, Element multistatusElm, int depth) throws SlideException, IOException {
        if (depth < 0) {
            return;
        }
        writeReport( resourcePath, multistatusElm, propertyElmList );
        ObjectNode onode = structure.retrieve( slideToken, resourcePath );
        Enumeration childrenEnum = structure.getChildren( slideToken, onode );
        while( childrenEnum.hasMoreElements() ) {
            ObjectNode cnode = (ObjectNode)childrenEnum.nextElement();
            execute(cnode.getUri(), multistatusElm, depth-1);
        }
    }
View Full Code Here

        }
    }

    public ObjectNode retrieveObject(Connection connection, Uri uri)
        throws ServiceAccessException, ObjectNotFoundException {
        ObjectNode result = null;
        try {
            PreparedStatement statement = null;
            ResultSet res = null;
            String className;
            Vector children = new Vector();
            Vector parents = new Vector();
            Vector links = new Vector();
            try {
                statement =
                    connection.prepareStatement(
                        "select o.CLASS_NAME from OBJECT o, URI u where o.URI_ID = u.URI_ID and u.URI_STRING = ?");
                statement.setString(1, uri.toString());
                res = statement.executeQuery();
                if (res.next()) {
                    className = res.getString(1);
                } else {
                    throw new ObjectNotFoundException(uri);
                }
            } finally {
                close(statement, res);
            }

            try {
                statement =
                    connection.prepareStatement(
                        "SELECT c.NAME, cu.URI_STRING FROM URI u, URI cu, BINDING c WHERE cu.URI_ID = c.CHILD_UURI_ID AND c.URI_ID = u.URI_ID and u.URI_STRING = ?");
                statement.setString(1, uri.toString());
                res = statement.executeQuery();
                while (res.next()) {
                    children.addElement(new ObjectNode.Binding(res.getString(1), res.getString(2)));
                }
            } finally {
                close(statement, res);
            }

            try {
                statement =
                    connection.prepareStatement(
                        "SELECT c.NAME, cu.URI_STRING FROM URI u, URI cu, PARENT_BINDING c WHERE cu.URI_ID = c.PARENT_UURI_ID AND c.URI_ID = u.URI_ID and u.URI_STRING = ?");
                statement.setString(1, uri.toString());
                res = statement.executeQuery();
                while (res.next()) {
                    parents.addElement(new ObjectNode.ParentBinding(res.getString(1), res.getString(2)));
                }
            } finally {
                close(statement, res);
            }

            try {
                statement =
                    connection.prepareStatement(
                        "SELECT lu.URI_STRING FROM URI u, URI lu, LINKS l WHERE lu.URI_ID = l.URI_ID AND l.LINK_TO_ID = u.URI_ID and u.URI_STRING = ?");
                statement.setString(1, uri.toString());
                res = statement.executeQuery();
                while (res.next()) {
                    links.addElement(res.getString(1));
                }
            } finally {
                close(statement, res);
            }
            if (className.equals(LinkNode.class.toString())) {
                try {
                    statement =
                        connection.prepareStatement(
                            "SELECT lu.URI_STRING FROM URI u, URI lu, LINKS l WHERE lu.URI_ID = l.LINK_TO_ID AND l.URI_ID = u.URI_ID and u.URI_STRING = ?");
                    statement.setString(1, uri.toString());
                    res = statement.executeQuery();
                    if (res.next()) {
                        String linkTarget = res.getString(1);
                        result = new LinkNode(uri.toString(), children, links, linkTarget);
                    } else {
                        result = new LinkNode(uri.toString(), children, links);
                    }
                } finally {
                    close(statement, res);
                }
            } else {
                try {
                    Class objclass = Class.forName(className);
                    Class argClasses[] = { String.class, Vector.class, Vector.class, Vector.class };
                    Object arguments[] = { uri.toString(), children, parents, links };
                    Constructor constructor = objclass.getConstructor(argClasses);
                    result = (ObjectNode) constructor.newInstance(arguments);
                    result.setUri(result.getUuri());
                } catch (Exception e) {
                    throw new ServiceAccessException(service, e);
                }
            }
        } catch (SQLException e) {
View Full Code Here

TOP

Related Classes of org.apache.slide.structure.ObjectNode$ParentBinding

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.