Package org.swordapp.server

Examples of org.swordapp.server.ServiceDocument


    // construct the ATOM collection generators that we might use
    AtomCollectionGenerator comGen = new CommunityCollectionGenerator();
    AtomCollectionGenerator colGen = new CollectionCollectionGenerator();

    // construct a new service document
    ServiceDocument service = new ServiceDocument();

    // set the max upload size
    service.setMaxUploadSize(swordConfig.getMaxUploadSize());

    if (url == null || urlManager.isBaseServiceDocumentUrl(url))
    {
      // we are dealing with the default service document

      // set the title of the workspace as per the name of the DSpace installation
      String ws = ConfigurationManager.getProperty("dspace.name");
      SwordWorkspace workspace = new SwordWorkspace();
      workspace.setTitle(ws);

      // next thing to do is determine whether the default is communities or collections
      boolean swordCommunities = ConfigurationManager.getBooleanProperty("swordv2-server", "expose-communities");

      if (swordCommunities)
      {
        List<Community> comms = swordAuth.getAllowedCommunities(context);
        for (Community comm : comms)
        {
          SwordCollection scol = comGen.buildCollection(context.getContext(), comm, swordConfig);
          workspace.addCollection(scol);
        }
      }
      else
      {
        List<Collection> cols = swordAuth.getAllowedCollections(context);
        for (Collection col : cols)
        {
            SwordCollection scol = colGen.buildCollection(context.getContext(), col, swordConfig);
          workspace.addCollection(scol);
        }
      }

          service.addWorkspace(workspace);
    }
    else
    {
      // we are dealing with a partial or sub-service document
      DSpaceObject dso = urlManager.extractDSpaceObject(url);
            if (dso == null)
            {
                throw new SwordError(404);
            }

      if (dso instanceof Community)
      {
        Community community = (Community) dso;
        SwordWorkspace workspace = new SwordWorkspace();
        workspace.setTitle(community.getMetadata("name"));

        List<Collection> collections = swordAuth.getAllowedCollections(context, community);
        for (Collection collection : collections)
        {
          SwordCollection scol = colGen.buildCollection(context.getContext(), collection, swordConfig);
          workspace.addCollection(scol);
        }

        List<Community> communities = swordAuth.getCommunities(context, community);
        for (Community comm : communities)
        {
          SwordCollection scol = comGen.buildCollection(context.getContext(), comm, swordConfig);
          workspace.addCollection(scol);
        }

        service.addWorkspace(workspace);
      }
    }

        return service;
  }
View Full Code Here

TOP

Related Classes of org.swordapp.server.ServiceDocument

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.