Package org.dspace.app.itemimport

Examples of org.dspace.app.itemimport.ItemImport


        in.close();
        outStream.close();
      }
      else if (buttonPressed.equals("submit_delete")){
        ItemImport itemImport = new ItemImport();
        try {
        itemImport.deleteBatchUpload(context, uploadId);
        showMainPage(context, request, response);
       
      } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
View Full Code Here


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

                // Process CSV without import
                ItemImport itemImport = new ItemImport();

                String collectionHandle = String.valueOf(request.get("collectionHandle"));
                if (StringUtils.isEmpty(collectionHandle) || !collectionHandle.contains("/")) {
                    //fail
                    log.error("UIBatchImport failed due to no collection.");
                    result.setContinue(false);
                    result.setOutcome(false);
                    result.setMessage(T_failed_no_collection);
                    return result;
                }

                Collection[] collections = new Collection[1];

                try {
                    Collection collection = (Collection) HandleManager.resolveToObject(context, collectionHandle);
                    collections[0] = collection;
                } catch (SQLException e) {
                    log.error("UIBatchImport failed due to collection not existing.", e);
                    result.setContinue(false);
                    result.setOutcome(false);
                    result.setMessage(T_failed_no_collection);
                    return result;
                }

                File mapFile = null;
                try {
                    mapFile = File.createTempFile(file.getName(), ".map", ItemImport.getTempWorkDirFile());
                } catch (IOException e) {
                    log.error("BatchImportUI Unable to create mapfile", e);
                    result.setContinue(false);
                    result.setOutcome(false);
                    result.setMessage(T_import_failed);
                    return result;
                }


                log.info("Attempt UIBatchImport to collection: " + collections[0].getName()
                        + ", zip: " + file.getName()
                        + ", map: " + mapFile.getAbsolutePath());

            /*
             // equivalent command-line would be:
             import -a -e <email> -c <collection/handle> -s <parent-dir-of-zip> -z <filename-of-zip> -m <mapfile> --template

             -c,--collection <arg>   destination collection(s) Handle or database ID
             -e,--eperson <arg>      email of eperson doing importing
             -m,--mapfile <arg>      mapfile items in mapfile
             -n,--notify             if sending submissions through the workflow, send
                                     notification emails
             -p,--template           apply template
             -q,--quiet              don't display metadata

             -s,--source <arg>       source of items (directory)
             -t,--test               test run - do not actually import items
             -w,--workflow           send submission through collection's workflow
             -z,--zip <arg>          name of zip file

             //Control
                  -a,--add                add items to DSpace
                  -R,--resume             resume a failed import (add only)
             */

                String sourceBatchDir = null;
                try {
                    sourceBatchDir = ItemImport.unzip(file);
                } catch (IOException e) {
                    log.error("BatchImportUI Unable to unzip", e);
                    result.setContinue(false);
                    result.setOutcome(false);
                    result.setMessage(T_import_failed);
                    return result;
                }

                //TODO, Should we run this in TEST mode first, to ensure we get a clean pass?
                try {
                    itemImport.addItemsAtomic(context, collections, sourceBatchDir, mapFile.getAbsolutePath(), true);
                } catch (Exception e) {
                    log.error("BatchImportUI - Failure during import: " + e.getMessage());
                    result.setContinue(false);
                    result.setOutcome(false);
                    result.setMessage(T_import_failed);
View Full Code Here

TOP

Related Classes of org.dspace.app.itemimport.ItemImport

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.