Package org.purl.sword.base

Examples of org.purl.sword.base.Service


    {
      throw new DSpaceSWORDException("The SWORD Context is null; please set it before calling getServiceDocument");
    }

    // construct a new service document
    Service service = new Service(SWORDProperties.VERSION, swordConfig.isNoOp(), swordConfig.isVerbose());

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

        // Set the generator
        this.addGenerator(service);

    //
    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");
      Workspace workspace = new Workspace();
      workspace.setTitle(ws);

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

      if (swordCommunities)
      {
        List<Community> comms = swordAuth.getAllowedCommunities(swordContext);
        for (Community comm : comms)
        {
          org.purl.sword.base.Collection scol = comGen.buildCollection(comm);
          workspace.addCollection(scol);
        }
      }
      else
      {
        List<Collection> cols = swordAuth.getAllowedCollections(swordContext);
        for (Collection col : cols)
        {
          org.purl.sword.base.Collection scol = colGen.buildCollection(col);
          workspace.addCollection(scol);
        }
      }

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

      if (dso instanceof Collection)
      {
        Collection collection = (Collection) dso;
        Workspace workspace = new Workspace();
        workspace.setTitle(collection.getMetadata("name"));

        List<Item> items = swordAuth.getAllowedItems(swordContext, collection);
        for (Item item : items)
        {
          org.purl.sword.base.Collection scol = itemGen.buildCollection(item);
          workspace.addCollection(scol);
        }

        service.addWorkspace(workspace);
      }
      else if (dso instanceof Community)
      {
        Community community = (Community) dso;
        Workspace workspace = new Workspace();
        workspace.setTitle(community.getMetadata("name"));

        List<Collection> collections = swordAuth.getAllowedCollections(swordContext, community);
        for (Collection collection : collections)
        {
          org.purl.sword.base.Collection scol = colGen.buildCollection(collection);
          workspace.addCollection(scol);
        }

        List<Community> communities = swordAuth.getCommunities(swordContext, community);
        for (Community comm : communities)
        {
          org.purl.sword.base.Collection scol = comGen.buildCollection(comm);
          workspace.addCollection(scol);
        }

        service.addWorkspace(workspace);
      }
    }

    ServiceDocument sd = new ServiceDocument(service);
    return sd;
View Full Code Here


      throw new SWORDErrorException(ErrorCodes.MEDIATION_NOT_ALLOWED, "Mediated deposits not allowed");
    }
   
    // Create and return a dummy ServiceDocument
    ServiceDocument document = new ServiceDocument();
    Service service = new Service("1.3", true, true);
    document.setService(service);
        log.debug("sdr.getLocation() is: " + sdr.getLocation());
    String location = sdr.getLocation().substring(0, sdr.getLocation().length() - 16);
    log.debug("location is: " + location);
       
      if (sdr.getLocation().contains("?nested=")) {
        Workspace workspace = new Workspace();
        workspace.setTitle("Nested service document workspace");
        Collection collection = new Collection();
        collection.setTitle("Nested collection: " + sdr.getLocation().substring(sdr.getLocation().indexOf('?') + 1));
        collection.setLocation(location + "/deposit/nested");
        collection.addAcceptPackaging("http://purl.org/net/sword-types/METSDSpaceSIP");
        collection.addAcceptPackaging("http://purl.org/net/sword-types/bagit");
        collection.addAccepts("application/zip");
        collection.addAccepts("application/xml");
        collection.setAbstract("A nested collection that users can deposit into");
        collection.setTreatment("This is a dummy server");
        collection.setCollectionPolicy("No guarantee of service, or that deposits will be retained for any length of time.");
        workspace.addCollection(collection);
        service.addWorkspace(workspace);
      } else {
        Workspace workspace = new Workspace();
        workspace.setTitle("Anonymous submitters workspace");
        Collection collection = new Collection();
        collection.setTitle("Anonymous submitters collection");
        collection.setLocation(location + "/deposit/anon");
        collection.addAcceptPackaging("http://purl.org/net/sword-types/METSDSpaceSIP");
        collection.addAcceptPackaging("http://purl.org/net/sword-types/bagit");
        collection.addAccepts("application/zip");
        collection.addAccepts("application/xml");
        collection.setAbstract("A collection that anonymous users can deposit into");
        collection.setTreatment("This is a dummy server");
        collection.setCollectionPolicy("No guarantee of service, or that deposits will be retained for any length of time.");
        collection.setService(location + "/client/servicedocument?nested=anon");
        workspace.addCollection(collection);
        collection = new Collection();
        collection.setTitle("Anonymous submitters other collection");
        collection.setLocation(location + "/deposit/anonymous");
        collection.addAcceptPackaging("http://purl.org/net/sword-types/METSDSpaceSIP");
        collection.addAcceptPackaging("http://purl.org/net/sword-types/bagit");
        collection.addAccepts("application/zip");
        collection.addAccepts("application/xml");
        collection.setAbstract("Another collection that anonymous users can deposit into");
        collection.setTreatment("This is a dummy server");
        collection.setCollectionPolicy("No guarantee of service, or that deposits will be retained for any length of time.");
        workspace.addCollection(collection);
        service.addWorkspace(workspace);
       
        if (sdr.getUsername() != null) {
          workspace = new Workspace();
          workspace.setTitle("Authenticated workspace for " + username);
          collection = new Collection();
          collection.setTitle("Authenticated collection for " + username);
          collection.setLocation(location + "/deposit/" + username);
          collection.addAccepts("application/zip");
          collection.addAccepts("application/xml");
          collection.addAcceptPackaging("http://purl.org/net/sword-types/METSDSpaceSIP");
          collection.addAcceptPackaging("http://purl.org/net/sword-types/bagit", 0.8f);
          collection.setAbstract("A collection that " + username + " can deposit into");
          collection.setTreatment("This is a dummy server");
          collection.setCollectionPolicy("No guarantee of service, or that deposits will be retained for any length of time.");
          collection.setService(location + "/client/servicedocument?nested=authenticated");
          workspace.addCollection(collection);
          collection = new Collection();
          collection.setTitle("Second authenticated collection for " + username);
          collection.setLocation(location + "/deposit/" + username + "-2");
          collection.addAccepts("application/zip");
          collection.addAccepts("application/xml");
          collection.addAcceptPackaging("http://purl.org/net/sword-types/bagit", 0.123f);
          collection.addAcceptPackaging("http://purl.org/net/sword-types/METSDSpaceSIP");
          collection.setAbstract("A collection that " + username + " can deposit into");
          collection.setTreatment("This is a dummy server");
          collection.setCollectionPolicy("No guarantee of service, or that deposits will be retained for any length of time.");
          workspace.addCollection(collection);
        }
        service.addWorkspace(workspace);
      }
     
      String onBehalfOf = sdr.getOnBehalfOf();
      if ((onBehalfOf != null) && (!onBehalfOf.equals(""))) {
        Workspace workspace = new Workspace();
        workspace.setTitle("Personal workspace for " + onBehalfOf);
        Collection collection = new Collection();
        collection.setTitle("Personal collection for " + onBehalfOf);
        collection.setLocation(location + "/deposit?user=" + onBehalfOf);
        collection.addAccepts("application/zip");
        collection.addAccepts("application/xml");
        collection.addAcceptPackaging("http://purl.org/net/sword-types/METSDSpaceSIP");
        collection.addAcceptPackaging("http://purl.org/net/sword-types/bagit", 0.8f);
        collection.setAbstract("An abstract goes in here");
        collection.setCollectionPolicy("A collection policy");
        collection.setMediation(true);
        collection.setTreatment("treatment in here too");
        workspace.addCollection(collection);
        service.addWorkspace(workspace);
      }
     
      return document;
  }
View Full Code Here

   public void processServiceDocument(String url,
                                      ServiceDocument doc)
   {
      TreeNodeWrapper wrapper = null;

      Service service = doc.getService();
      wrapper = new TreeNodeWrapper(url, service);
      DefaultMutableTreeNode serviceNode = new DefaultMutableTreeNode(wrapper);
      treeModel.insertNodeInto(serviceNode, top, top.getChildCount());
      services.scrollPathToVisible(new TreePath(serviceNode.getPath()));

      // process the workspaces
      DefaultMutableTreeNode workspaceNode = null;

      Iterator<Workspace> workspaces = service.getWorkspaces();
      for (; workspaces.hasNext();)
      {
         Workspace workspace = workspaces.next();
         wrapper = new TreeNodeWrapper(workspace.getTitle(), workspace);
         workspaceNode = new DefaultMutableTreeNode(wrapper);
View Full Code Here

    {
      throw new DSpaceSWORDException("The SWORD Context is null; please set it before calling getServiceDocument");
    }

    // construct a new service document
    Service service = new Service(SWORDProperties.VERSION, swordConfig.isNoOp(), swordConfig.isVerbose());

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

        // Set the generator
        this.addGenerator(service);

    //
    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");
      Workspace workspace = new Workspace();
      workspace.setTitle(ws);

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

      if (swordCommunities)
      {
        List<Community> comms = swordAuth.getAllowedCommunities(swordContext);
        for (Community comm : comms)
        {
          org.purl.sword.base.Collection scol = comGen.buildCollection(comm);
          workspace.addCollection(scol);
        }
      }
      else
      {
        List<Collection> cols = swordAuth.getAllowedCollections(swordContext);
        for (Collection col : cols)
        {
          org.purl.sword.base.Collection scol = colGen.buildCollection(col);
          workspace.addCollection(scol);
        }
      }

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

      if (dso instanceof Collection)
      {
        Collection collection = (Collection) dso;
        Workspace workspace = new Workspace();
        workspace.setTitle(collection.getMetadata("name"));

        List<Item> items = swordAuth.getAllowedItems(swordContext, collection);
        for (Item item : items)
        {
          org.purl.sword.base.Collection scol = itemGen.buildCollection(item);
          workspace.addCollection(scol);
        }

        service.addWorkspace(workspace);
      }
      else if (dso instanceof Community)
      {
        Community community = (Community) dso;
        Workspace workspace = new Workspace();
        workspace.setTitle(community.getMetadata("name"));

        List<Collection> collections = swordAuth.getAllowedCollections(swordContext, community);
        for (Collection collection : collections)
        {
          org.purl.sword.base.Collection scol = colGen.buildCollection(collection);
          workspace.addCollection(scol);
        }

        List<Community> communities = swordAuth.getCommunities(swordContext, community);
        for (Community comm : communities)
        {
          org.purl.sword.base.Collection scol = comGen.buildCollection(comm);
          workspace.addCollection(scol);
        }

        service.addWorkspace(workspace);
      }
    }

        return new ServiceDocument(service);
  }
View Full Code Here

      throw new SWORDErrorException(ErrorCodes.MEDIATION_NOT_ALLOWED, "Mediated deposits not allowed");
    }
   
    // Create and return a dummy ServiceDocument
    ServiceDocument document = new ServiceDocument();
    Service service = new Service("1.3", true, true);
    document.setService(service);
        log.debug("sdr.getLocation() is: " + sdr.getLocation());
    String location = sdr.getLocation().substring(0, sdr.getLocation().length() - 16);
    log.debug("location is: " + location);
       
      if (sdr.getLocation().contains("?nested=")) {
        Workspace workspace = new Workspace();
        workspace.setTitle("Nested service document workspace");
        Collection collection = new Collection();
        collection.setTitle("Nested collection: " + sdr.getLocation().substring(sdr.getLocation().indexOf('?') + 1));
        collection.setLocation(location + "/deposit/nested");
        collection.addAcceptPackaging("http://purl.org/net/sword-types/METSDSpaceSIP");
        collection.addAcceptPackaging("http://purl.org/net/sword-types/bagit");
        collection.addAccepts("application/zip");
        collection.addAccepts("application/xml");
        collection.setAbstract("A nested collection that users can deposit into");
        collection.setTreatment("This is a dummy server");
        collection.setCollectionPolicy("No guarantee of service, or that deposits will be retained for any length of time.");
        workspace.addCollection(collection);
        service.addWorkspace(workspace);
      } else {
        Workspace workspace = new Workspace();
        workspace.setTitle("Anonymous submitters workspace");
        Collection collection = new Collection();
        collection.setTitle("Anonymous submitters collection");
        collection.setLocation(location + "/deposit/anon");
        collection.addAcceptPackaging("http://purl.org/net/sword-types/METSDSpaceSIP");
        collection.addAcceptPackaging("http://purl.org/net/sword-types/bagit");
        collection.addAccepts("application/zip");
        collection.addAccepts("application/xml");
        collection.setAbstract("A collection that anonymous users can deposit into");
        collection.setTreatment("This is a dummy server");
        collection.setCollectionPolicy("No guarantee of service, or that deposits will be retained for any length of time.");
        collection.setService(location + "/client/servicedocument?nested=anon");
        workspace.addCollection(collection);
        collection = new Collection();
        collection.setTitle("Anonymous submitters other collection");
        collection.setLocation(location + "/deposit/anonymous");
        collection.addAcceptPackaging("http://purl.org/net/sword-types/METSDSpaceSIP");
        collection.addAcceptPackaging("http://purl.org/net/sword-types/bagit");
        collection.addAccepts("application/zip");
        collection.addAccepts("application/xml");
        collection.setAbstract("Another collection that anonymous users can deposit into");
        collection.setTreatment("This is a dummy server");
        collection.setCollectionPolicy("No guarantee of service, or that deposits will be retained for any length of time.");
        workspace.addCollection(collection);
        service.addWorkspace(workspace);
       
        if (sdr.getUsername() != null) {
          workspace = new Workspace();
          workspace.setTitle("Authenticated workspace for " + username);
          collection = new Collection();
          collection.setTitle("Authenticated collection for " + username);
          collection.setLocation(location + "/deposit/" + username);
          collection.addAccepts("application/zip");
          collection.addAccepts("application/xml");
          collection.addAcceptPackaging("http://purl.org/net/sword-types/METSDSpaceSIP");
          collection.addAcceptPackaging("http://purl.org/net/sword-types/bagit", 0.8f);
          collection.setAbstract("A collection that " + username + " can deposit into");
          collection.setTreatment("This is a dummy server");
          collection.setCollectionPolicy("No guarantee of service, or that deposits will be retained for any length of time.");
          collection.setService(location + "/client/servicedocument?nested=authenticated");
          workspace.addCollection(collection);
          collection = new Collection();
          collection.setTitle("Second authenticated collection for " + username);
          collection.setLocation(location + "/deposit/" + username + "-2");
          collection.addAccepts("application/zip");
          collection.addAccepts("application/xml");
          collection.addAcceptPackaging("http://purl.org/net/sword-types/bagit", 0.123f);
          collection.addAcceptPackaging("http://purl.org/net/sword-types/METSDSpaceSIP");
          collection.setAbstract("A collection that " + username + " can deposit into");
          collection.setTreatment("This is a dummy server");
          collection.setCollectionPolicy("No guarantee of service, or that deposits will be retained for any length of time.");
          workspace.addCollection(collection);
        }
        service.addWorkspace(workspace);
      }
     
      String onBehalfOf = sdr.getOnBehalfOf();
      if ((onBehalfOf != null) && (!onBehalfOf.equals(""))) {
        Workspace workspace = new Workspace();
        workspace.setTitle("Personal workspace for " + onBehalfOf);
        Collection collection = new Collection();
        collection.setTitle("Personal collection for " + onBehalfOf);
        collection.setLocation(location + "/deposit?user=" + onBehalfOf);
        collection.addAccepts("application/zip");
        collection.addAccepts("application/xml");
        collection.addAcceptPackaging("http://purl.org/net/sword-types/METSDSpaceSIP");
        collection.addAcceptPackaging("http://purl.org/net/sword-types/bagit", 0.8f);
        collection.setAbstract("An abstract goes in here");
        collection.setCollectionPolicy("A collection policy");
        collection.setMediation(true);
        collection.setTreatment("treatment in here too");
        workspace.addCollection(collection);
        service.addWorkspace(workspace);
      }
     
      return document;
  }
View Full Code Here

TOP

Related Classes of org.purl.sword.base.Service

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.