Examples of ServiceDocument


Examples of org.purl.sword.base.ServiceDocument

  throws SWORDClientException, MalformedURLException
  {
    String href = options.getHref();
    initialiseServer(href, options.getUsername(), options.getPassword());

    ServiceDocument document = client.getServiceDocument(href, options.getOnBehalfOf());
    Status status = client.getStatus();
    System.out.println("The status is: " + status);

    if (status.getCode() == 200)
    {
      log.debug("message is: " + document.marshall());
     
      System.out.println("\nThe following Details were retrieved: ");
      System.out.println("SWORD Version: "
          + document.getService().getVersion());
      System.out.println("Supports NoOp? " + document.getService().isNoOp());
      System.out.println("Supports Verbose? "
          + document.getService().isVerbose());
      System.out.println("Max Upload File Size "
          + document.getService().getMaxUploadSize() +" kB");

      Iterator<Workspace> workspaces = document.getService().getWorkspaces();
      for (; workspaces.hasNext();)
      {
        Workspace workspace = workspaces.next();
        System.out.println("\nWorkspace Title: '"
            + workspace.getTitle() + "'");
View Full Code Here

Examples of org.purl.sword.base.ServiceDocument

        FlowResult result = new FlowResult();
        result.setContinue(false);

        // Get all our request parameters
        String location = request.getParameter("location");
        ServiceDocument serviceDoc = (ServiceDocument) request.getAttribute("serviceDoc");

        log.info("Collection selected is " + location);
        log.info("Service Doc reference is " + serviceDoc);

        // Set the target collection.
View Full Code Here

Examples of org.purl.sword.base.ServiceDocument

        Division main = body.addDivision("main");
        main.setHead(T_main_head.parameterize(handle));

        Request request = ObjectModelHelper.getRequest(objectModel);
        ServiceDocument serviceDoc = (ServiceDocument) request.getAttribute("serviceDoc");

        java.util.List<Collection> collections = ServiceDocumentHelper.getCollections(serviceDoc);
        for (Collection collection : collections)
        {
            Division collectionDiv = main.addInteractiveDivision("collection", contextPath + "/swordclient", Division.METHOD_POST, "");
View Full Code Here

Examples of org.purl.sword.base.ServiceDocument

        {
            try
            {
                DSClient.setRemoteServer(chosenUrl);
                DSClient.setCredentials(username, password, onBehalfOf);
                ServiceDocument serviceDoc = DSClient.getServiceDocument();
                result.setParameter("serviceDoc", serviceDoc);
                result.setContinue(true);
                result.setOutcome(true);
            }
            catch (MalformedURLException e)
View Full Code Here

Examples of org.purl.sword.base.ServiceDocument

           if (result.getErrors() == null)
           {
               try
               {
                   DSClient.setRemoteServer(url);
                   ServiceDocument serviceDoc = DSClient.getServiceDocument();
                   result.setParameter("serviceDoc", serviceDoc);
                   result.setOutcome(true);
               }
               catch (MalformedURLException e)
               {
View Full Code Here

Examples of org.purl.sword.base.ServiceDocument

    public void addBody(Body body) throws SAXException, WingException, UIException, SQLException, IOException, AuthorizeException {
        String handle = parameters.getParameter("handle", null);

        Request request = ObjectModelHelper.getRequest(objectModel);

        ServiceDocument serviceDoc = (ServiceDocument) request.getAttribute("serviceDoc");
        String location = (String) request.getAttribute("location");
        String[] fileTypes = (String[]) request.getAttribute("fileTypes");
        String[] packageFormats = (String[]) request.getAttribute("packageFormats");

        Collection collection = ServiceDocumentHelper.getCollection(serviceDoc, location);
View Full Code Here

Examples of org.purl.sword.base.ServiceDocument

      log.debug("Setting userAgent: " + userAgent);
      httpget.addHeader(HttpHeaders.USER_AGENT, userAgent);
            properties.put(HttpHeaders.USER_AGENT, userAgent);
    }

    ServiceDocument doc = null;

    try {
      HttpResponse response = client.execute(httpget);
            StatusLine statusLine = response.getStatusLine();
            int statusCode = statusLine.getStatusCode();
      // store the status code
      status = new Status(statusCode, statusLine.getReasonPhrase());

      if (status.getCode() == HttpStatus.SC_OK) {
        String message = readResponse(response.getEntity().getContent());
        log.debug("returned message is: " + message);
        doc = new ServiceDocument();
        lastUnmarshallInfo = doc.unmarshall(message, properties);
      } else {
        throw new SWORDClientException(
            "Received error from service document request: "
                + status);
      }
View Full Code Here

Examples of org.purl.sword.base.ServiceDocument

    if (useProxy) {
      client.setProxy(pHost, pPort);
    }

    try {
      ServiceDocument sd = client.getServiceDocument(theUrl,
      request.getParameter("obo"));

      // Set the status
      Status status = client.getStatus();
      request.setAttribute("status", status.toString());
      if (status.getCode() == 200) {
        // Set the debug response
        String xml = sd.marshall();

                String validateXml = xml;
                validateXml = validateXml.replaceAll("&", "&amp;");
                validateXml = validateXml.replaceAll("<", "&lt;");
                validateXml = validateXml.replaceAll(">", "&gt;");
View Full Code Here

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
Copyright © 2018 www.massapi.com. 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.