Package org.dspace.app.webui.util

Examples of org.dspace.app.webui.util.FileUploadRequest


    private void processBasicInfo(Context context, HttpServletRequest request,
            HttpServletResponse response) throws SQLException,
            ServletException, IOException, AuthorizeException
    {
        // Wrap multipart request to get the submission info
        FileUploadRequest wrapper = new FileUploadRequest(request);

        Collection collection = Collection.find(context, UIUtil
                .getIntParameter(wrapper, "collection_id"));

        if (collection == null)
        {
            log.warn(LogManager.getHeader(context, "integrity_error", UIUtil
                    .getRequestLogInfo(wrapper)));
            JSPManager.showIntegrityError(request, response);

            return;
        }

        // Get metadata
        collection.setMetadata("name", wrapper.getParameter("name"));
        collection.setMetadata("short_description", wrapper
                .getParameter("short_description"));
        collection.setMetadata("introductory_text", wrapper
                .getParameter("introductory_text"));
        collection.setMetadata("copyright_text", wrapper
                .getParameter("copyright_text"));
        collection.setMetadata("side_bar_text", wrapper
                .getParameter("side_bar_text"));
        collection.setMetadata("provenance_description", wrapper
                .getParameter("provenance_description"));

        // Need to be more careful about license -- make sure it's null if
        // nothing was entered
        String license = wrapper.getParameter("license");

        if ((license != null) || "".equals(license))
        {
            collection.setLicense(license);
        }

        File temp = wrapper.getFile("file");

        if (temp != null)
        {
            // Read the temp file as logo
            InputStream is = new BufferedInputStream(new FileInputStream(temp));
            Bitstream logoBS = collection.setLogo(is);

            // Strip all but the last filename. It would be nice
            // to know which OS the file came from.
            String noPath = wrapper.getFilesystemName("file");

            while (noPath.indexOf('/') > -1)
            {
                noPath = noPath.substring(noPath.indexOf('/') + 1);
            }

            while (noPath.indexOf('\\') > -1)
            {
                noPath = noPath.substring(noPath.indexOf('\\') + 1);
            }

            logoBS.setName(noPath);
            logoBS.setSource(wrapper.getFilesystemName("file"));

            // Identify the format
            BitstreamFormat bf = FormatIdentifier.guessFormat(context, logoBS);
            logoBS.setFormat(bf);
            AuthorizeManager.addPolicy(context, logoBS, Constants.WRITE, context
View Full Code Here


     */
    private ArrayList<BulkEditChange> processUpload(Context context,
                                                    HttpServletRequest request) throws Exception
    {
        // Wrap multipart request to get the submission info
        FileUploadRequest wrapper = new FileUploadRequest(request);
        File f = wrapper.getFile("file");

        // Run the import
        DSpaceCSV csv = new DSpaceCSV(f);
        MetadataImport mImport = new MetadataImport(context, csv.getCSVLines());
        ArrayList<BulkEditChange> changes = mImport.runImport(false, false, false, false);
View Full Code Here

            HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException, SQLException,
            AuthorizeException
    {
        // Wrap multipart request to get the submission info
        FileUploadRequest wrapper = new FileUploadRequest(request);
        Bitstream b = null;

        Item item = Item.find(context, UIUtil.getIntParameter(wrapper,
                "item_id"));

        File temp = wrapper.getFile("file");

        // Read the temp file as logo
        InputStream is = new BufferedInputStream(new FileInputStream(temp));

        // now check to see if person can edit item
        checkEditAuthorization(context, item);

        // do we already have an ORIGINAL bundle?
        Bundle[] bundles = item.getBundles("ORIGINAL");

        if (bundles.length < 1)
        {
            // set bundle's name to ORIGINAL
            b = item.createSingleBitstream(is, "ORIGINAL");
           
            // set the permission as defined in the owning collection
            Collection owningCollection = item.getOwningCollection();
            if (owningCollection != null)
            {
                Bundle bnd = b.getBundles()[0];
                bnd.inheritCollectionDefaultPolicies(owningCollection);
            }
        }
        else
        {
            // we have a bundle already, just add bitstream
            b = bundles[0].createBitstream(is);
        }

        // Strip all but the last filename. It would be nice
        // to know which OS the file came from.
        String noPath = wrapper.getFilesystemName("file");

        while (noPath.indexOf('/') > -1)
        {
            noPath = noPath.substring(noPath.indexOf('/') + 1);
        }

        while (noPath.indexOf('\\') > -1)
        {
            noPath = noPath.substring(noPath.indexOf('\\') + 1);
        }

        b.setName(noPath);
        b.setSource(wrapper.getFilesystemName("file"));

        // Identify the format
        BitstreamFormat bf = FormatIdentifier.guessFormat(context, b);
        b.setFormat(bf);
        b.update();
View Full Code Here

    private void processUploadLogo(Context context, HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException,
            SQLException, AuthorizeException
    {
        // Wrap multipart request to get the submission info
        FileUploadRequest wrapper = new FileUploadRequest(request);

        Community community = Community.find(context, UIUtil.getIntParameter(
                wrapper, "community_id"));
        Collection collection = Collection.find(context, UIUtil
                .getIntParameter(wrapper, "collection_id"));

        File temp = wrapper.getFile("file");

        // Read the temp file as logo
        InputStream is = new BufferedInputStream(new FileInputStream(temp));
        Bitstream logoBS;

        if (collection == null)
        {
            logoBS = community.setLogo(is);
        }
        else
        {
            logoBS = collection.setLogo(is);
        }

        // Strip all but the last filename. It would be nice
        // to know which OS the file came from.
        String noPath = wrapper.getFilesystemName("file");

        while (noPath.indexOf('/') > -1)
        {
            noPath = noPath.substring(noPath.indexOf('/') + 1);
        }

        while (noPath.indexOf('\\') > -1)
        {
            noPath = noPath.substring(noPath.indexOf('\\') + 1);
        }

        logoBS.setName(noPath);
        logoBS.setSource(wrapper.getFilesystemName("file"));

        // Identify the format
        BitstreamFormat bf = FormatIdentifier.guessFormat(context, logoBS);
        logoBS.setFormat(bf);
        AuthorizeManager.addPolicy(context, logoBS, Constants.WRITE, context
View Full Code Here

            // Now, if the request was a multi-part (file upload), we need to
            // get the original request back out, as the wrapper causes problems
            // further down the line.
            if (request instanceof FileUploadRequest)
            {
                FileUploadRequest fur = (FileUploadRequest) request;
                request = fur.getOriginalRequest();
            }

            int currStep = currentStepConfig.getStepNumber();
            int currPage = AbstractProcessingStep.getCurrentPage(request);
            double currStepAndPage = Float
View Full Code Here

            // if not already wrapped
            if (!Class.forName("org.dspace.app.webui.util.FileUploadRequest")
                    .isInstance(request))
            {
                // Wrap multipart request
                wrappedRequest = new FileUploadRequest(request);

                return (HttpServletRequest) wrappedRequest;
            }
            else
            { // already wrapped
View Full Code Here

     *            current servlet request object
     */
    public void uploadFiles(Context context, HttpServletRequest request)
            throws ServletException
    {
        FileUploadRequest wrapper = null;
        String filePath = null;
        InputStream fileInputStream = null;

        try
        {
            // if we already have a FileUploadRequest, use it
            if (Class.forName("org.dspace.app.webui.util.FileUploadRequest")
                    .isInstance(request))
            {
                wrapper = (FileUploadRequest) request;
            }
            else
            {
                // Wrap multipart request to get the submission info
                wrapper = new FileUploadRequest(request);
            }
           
            Enumeration fileParams = wrapper.getFileParameterNames();
            while(fileParams.hasMoreElements())
            {
                String fileName = (String) fileParams.nextElement();
               
                File temp = wrapper.getFile(fileName);
               
                //if file exists and has a size greater than zero
                if (temp != null && temp.length() > 0)
                {
                    // Read the temp file into an inputstream
                    fileInputStream = new BufferedInputStream(
                            new FileInputStream(temp));

                    filePath = wrapper.getFilesystemName(fileName);
               
                    // cleanup our temp file
                    temp.delete();
                   
                    //save this file's info to request (for UploadStep class)
                    request.setAttribute(fileName + "-path", filePath);
                    request.setAttribute(fileName + "-inputstream", fileInputStream);
                    request.setAttribute(fileName + "-description", wrapper.getParameter("description"));
                }        
            }
        }
        catch (Exception e)
        {
View Full Code Here

     */
    private List<BulkEditChange> processUpload(Context context,
                                                    HttpServletRequest request) throws Exception
    {
        // Wrap multipart request to get the submission info
        FileUploadRequest wrapper = new FileUploadRequest(request);
        File f = wrapper.getFile("file");

        // Run the import
        DSpaceCSV csv = new DSpaceCSV(f, context);
        MetadataImport mImport = new MetadataImport(context, csv);
        List<BulkEditChange> changes = mImport.runImport(false, false, false, false);
View Full Code Here

            HttpServletResponse response) throws ServletException, IOException,
            SQLException, AuthorizeException
    {
        try {
            // Wrap multipart request to get the submission info
            FileUploadRequest wrapper = new FileUploadRequest(request);
            Community community = Community.find(context, UIUtil.getIntParameter(wrapper, "community_id"));
            Collection collection = Collection.find(context, UIUtil.getIntParameter(wrapper, "collection_id"));
            File temp = wrapper.getFile("file");

            // Read the temp file as logo
            InputStream is = new BufferedInputStream(new FileInputStream(temp));
            Bitstream logoBS;

            if (collection == null)
            {
                logoBS = community.setLogo(is);
            }
            else
            {
                logoBS = collection.setLogo(is);
            }

            // Strip all but the last filename. It would be nice
            // to know which OS the file came from.
            String noPath = wrapper.getFilesystemName("file");

            while (noPath.indexOf('/') > -1)
            {
                noPath = noPath.substring(noPath.indexOf('/') + 1);
            }

            while (noPath.indexOf('\\') > -1)
            {
                noPath = noPath.substring(noPath.indexOf('\\') + 1);
            }

            logoBS.setName(noPath);
            logoBS.setSource(wrapper.getFilesystemName("file"));

            // Identify the format
            BitstreamFormat bf = FormatIdentifier.guessFormat(context, logoBS);
            logoBS.setFormat(bf);
            AuthorizeManager.addPolicy(context, logoBS, Constants.WRITE, context.getCurrentUser());
View Full Code Here

            // Now, if the request was a multi-part (file upload), we need to
            // get the original request back out, as the wrapper causes problems
            // further down the line.
            if (request instanceof FileUploadRequest)
            {
                FileUploadRequest fur = (FileUploadRequest) request;
                request = fur.getOriginalRequest();
            }

            int currStep = currentStepConfig.getStepNumber();
            int currPage = AbstractProcessingStep.getCurrentPage(request);
            double currStepAndPage = Double.parseDouble(currStep + "." + currPage);
View Full Code Here

TOP

Related Classes of org.dspace.app.webui.util.FileUploadRequest

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.