Package org.dspace.app.xmlui.aspect.administrative

Examples of org.dspace.app.xmlui.aspect.administrative.FlowResult


{
    private static final Message T_packageFormat_error = new Message("default", "xmlui.swordclient.SelectPackagingFormat.packageFormat_error");

    public FlowResult processSelectPackaging(Context context, Request request, DSpaceSwordClient DSClient)
    {
        FlowResult result = new FlowResult();
        result.setContinue(false);

        // Get all our request parameters
        String fileType = request.getParameter("fileType");
        String packageFormat = request.getParameter("packageFormat");

        DSClient.setFileType(fileType);

        try
        {
            DSClient.setPackageFormat(packageFormat);
            result.setContinue(true);
            result.setOutcome(true);
        }
        catch (PackageFormatException e)
        {
            // This exception should never actually happen since the user selects from a drop down list but...
            result.setOutcome(false);
            result.setMessage(T_packageFormat_error);
        }


        return result;
    }
View Full Code Here


{
    private static Logger log = Logger.getLogger(SelectCollectionAction.class);

    public FlowResult processSelectCollection(Context context, Request request, DSpaceSwordClient DSClient)
    {
        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.
        DSClient.setCollection(location);

        //Collection collection = ServiceDocumentHelper.getCollection(serviceDoc, location);

        // Find out what file types and package formats are available and return them to let the user select.
        String[] fileTypes = ServiceDocumentHelper.getCommonFileTypes(serviceDoc, location);
        String[] packageFormats = ServiceDocumentHelper.getCommonPackageFormats(serviceDoc, location);

        result.setParameter("location", location);
        result.setParameter("serviceDoc", serviceDoc);
        result.setParameter("fileTypes", fileTypes);
        result.setParameter("packageFormats", packageFormats);
        result.setContinue(true);
        result.setOutcome(true);

        return result;
    }
View Full Code Here

    private static Logger log = Logger.getLogger(SelectTargetAction.class);


    public FlowResult processSelectTarget(Context context, Request request, DSpaceSwordClient DSClient)
    {
        FlowResult result = new FlowResult();
        result.setContinue(false);

        // Get all our request parameters
        String url = request.getParameter("url").trim();
        String otherUrl = request.getParameter("otherUrl").trim();
        String username = request.getParameter("username").trim();
        String password = request.getParameter("password").trim();
        String onBehalfOf = request.getParameter("onBehalfOf").trim();

        // If we have errors, the form needs to be resubmitted to fix those problems

        String chosenUrl = "";

        if (!StringUtils.isEmpty(otherUrl))
        {
            // If otherUrl has been entered then it will take precedence.
            try
            {
                new URL(otherUrl);
                chosenUrl = otherUrl;
            }
            catch (MalformedURLException e)
            {
                result.addError("otherUrl");
            }
        }
        else
        {
            if (!StringUtils.isEmpty(url))
            {
                chosenUrl = url;
            }
            else
            {
                result.addError("url");
            }
        }

        if (StringUtils.isEmpty(username))
        {
            result.addError("username");
        }
        if (StringUtils.isEmpty(password))
        {
            result.addError("password");
        }

        // No errors, the input parameters look healthy.
        if (result.getErrors() == null)
        {
            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)
            {
                log.error("Malformed URL : " + chosenUrl);
                result.setOutcome(false);
          result.setMessage(T_url_error);
            }
            catch (HttpException e)
            {
                log.error("HttpException encountered", e);
                result.setOutcome(false);
          result.setMessage(T_serviceDoc_error.parameterize(e.getMessage()));
            }
            catch (SWORDClientException e)
            {
                log.error("SwordClientException : " + e.getMessage(), e);
                result.setOutcome(false);
          result.setMessage(T_serviceDoc_error.parameterize(e.getMessage()));
            }

        }

        return result;
View Full Code Here

        return result;
    }

    public FlowResult processSelectSubTarget(Context context, Request request, DSpaceSwordClient DSClient)
       {
           FlowResult result = new FlowResult();
           result.setContinue(false);


           // Get all our request parameters.
           String url = request.getParameter("sub-service").trim();

           log.info("target selected is : " + url);

           if (StringUtils.isEmpty(url))
           {
               // Note : this shouldn't ever happen since the user doesn't enter it manually.
               result.addError("sub-service");
           }

           // No errors, the input parameters look healthy.
           if (result.getErrors() == null)
           {
               try
               {
                   DSClient.setRemoteServer(url);
                   ServiceDocument serviceDoc = DSClient.getServiceDocument();
                   result.setParameter("serviceDoc", serviceDoc);
                   result.setOutcome(true);
               }
               catch (MalformedURLException e)
               {
                   log.error("Malformed URL : " + url);
                   result.setOutcome(false);
                   result.setMessage(T_url_error);
               }
               catch (HttpException e)
               {
                   log.error("HttpException encountered", e);
                   result.setOutcome(false);
                   result.setMessage(T_serviceDoc_error.parameterize(e.getMessage()));
               }
               catch (SWORDClientException e)
               {
                   log.error("SwordClientException : " + e.getMessage(), e);
                   result.setOutcome(false);
                   result.setMessage(T_serviceDoc_error.parameterize(e.getMessage()));
               }

           }

           return result;
View Full Code Here

    private static Logger log = Logger.getLogger(DepositAction.class);

    public FlowResult processDeposit(Context context, String handle, DSpaceSwordClient DSClient)
    {
        FlowResult result = new FlowResult();
        result.setContinue(false);

        try
        {
            DSClient.deposit(context, handle);
            result.setContinue(true);
            result.setOutcome(true);
            result.setMessage(T_success);
        }
        catch (PackageFormatException e)
        {
            log.error("Package Format Exception", e);
            result.setOutcome(false);
            result.setMessage(T_package_format_error);
        }
        catch (InvalidHandleException e)
        {
            log.error("Invalid handle Exception", e);
            result.setOutcome(false);
            result.setMessage(T_invalid_handle);
        }
        catch (PackagerException e)
        {
            log.error("Packager Exception", e);
            result.setOutcome(false);
            result.setMessage(T_package_error);
        }
        catch (SWORDClientException e)
        {
            log.error("SWORDClientException encountered " + e.getMessage(), e);
            result.setOutcome(false);
            result.setMessage(T_error.parameterize(e.getMessage()));
        }
        catch (HttpException e)
        {
            log.error("HttpException encountered " + e.getMessage(), e);
            result.setOutcome(false);
            result.setMessage(T_error.parameterize(e.getMessage()));
        }


        return result;
    }
View Full Code Here

     * @param itemID  The id of the to-be-versioned item
     * @return A result object
     */
    // Versioning
    public static FlowResult processCreateNewVersion(Context context, int itemID, String summary) throws SQLException, AuthorizeException, IOException {
        FlowResult result = new FlowResult();
        try {
            result.setContinue(false);

            Item item = Item.find(context, itemID);

            if (AuthorizeManager.isAdmin(context, item) || item.canEdit()) {
                VersioningService versioningService = new DSpace().getSingletonService(VersioningService.class);
                Version version = versioningService.createNewVersion(context, itemID, summary);
                WorkspaceItem wsi = WorkspaceItem.findByItem(context, version.getItem());

                context.commit();

                result.setParameter("wsid", wsi.getID());
                result.setOutcome(true);
                result.setContinue(true);
                result.setMessage(T_version_created);
                result.setParameter("summary", summary);
            }
        } catch (Exception ex) {
            context.abort();
            throw new RuntimeException(ex);
        }
View Full Code Here

     * @return A result object
     */
    // Versioning
    public static FlowResult processUpdateVersion(Context context, int itemID, String summary) throws SQLException, AuthorizeException, IOException {

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

            Item item = Item.find(context, itemID);

            if (AuthorizeManager.isAdmin(context, item)) {
                VersioningService versioningService = new DSpace().getSingletonService(VersioningService.class);
                versioningService.updateVersion(context, itemID, summary);

                context.commit();

                result.setOutcome(true);
                result.setContinue(true);
                result.setMessage(T_version_updated);
                result.setParameter("summary", summary);
            }
        } catch (Exception ex) {
            context.abort();
            throw new RuntimeException(ex);
        }
View Full Code Here

     * @param context   The DSpace context
     * @return A result object
     */
    // Versioning
    public static FlowResult processRestoreVersion(Context context, int versionID, String summary) throws SQLException, AuthorizeException, IOException {
        FlowResult result = new FlowResult();
        try {
            result.setContinue(false);

            VersioningService versioningService = new DSpace().getSingletonService(VersioningService.class);
            versioningService.restoreVersion(context, versionID, summary);

            context.commit();

            result.setOutcome(true);
            result.setContinue(true);
            result.setMessage(T_version_restored);
        } catch (Exception ex) {
            context.abort();
            throw new RuntimeException(ex);
        }
        return result;
View Full Code Here

     * @param versionIDs list of versionIDs to delete
     * @return A result object
     */
    // Versioning
    public static FlowResult processDeleteVersions(Context context, int itemId, String[] versionIDs) throws SQLException, AuthorizeException, IOException, UIException {
        FlowResult result = new FlowResult();
        try {
            result.setContinue(false);

            VersioningService versioningService = new DSpace().getSingletonService(VersioningService.class);

            VersionHistory versionHistory = versioningService.findVersionHistory(context, itemId);

            for (String id : versionIDs) {
                versioningService.removeVersion(context, Integer.parseInt(id));
            }
            context.commit();

            //Retrieve the latest version of our history (IF any is even present)
            Version latestVersion = versionHistory.getLatestVersion();
            if(latestVersion == null){
                result.setParameter("itemID", null);
            }else{
                result.setParameter("itemID", latestVersion.getItemID());
            }
            result.setContinue(true);
            result.setOutcome(true);
            result.setMessage(T_version_delete);

        } catch (Exception ex) {
            context.abort();
            throw new RuntimeException(ex);
        }
View Full Code Here

TOP

Related Classes of org.dspace.app.xmlui.aspect.administrative.FlowResult

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.