Package org.dspace.checker

Examples of org.dspace.checker.BitstreamInfoDAO


     *                If a problem occurs accessing the RDBMS
     */
    public static void cleanup(boolean deleteDbRecords, boolean verbose) throws SQLException, IOException
    {
        Context context = null;
        BitstreamInfoDAO bitstreamInfoDAO = new BitstreamInfoDAO();
        int commit_counter = 0;

        try
        {
            context = new Context();

            String myQuery = "select * from Bitstream where deleted = '1'";

            List storage = DatabaseManager.queryTable(context, "Bitstream", myQuery)
                    .toList();

            for (Iterator iterator = storage.iterator(); iterator.hasNext();)
            {
                TableRow row = (TableRow) iterator.next();
                int bid = row.getIntColumn("bitstream_id");

        GeneralFile file = getFile(row);

                // Make sure entries which do not exist are removed
                if (file == null || !file.exists())
                {
                    log.debug("file is null");
                    if (deleteDbRecords)
                    {
                        log.debug("deleting record");
                        if (verbose) System.out.println(" - Deleting bitstream information (ID: " + bid + ")");
                        bitstreamInfoDAO.deleteBitstreamInfoWithHistory(bid);
                        if (verbose) System.out.println(" - Deleting bitstream record from database (ID: " + bid + ")");
                        DatabaseManager.delete(context, "Bitstream", bid);
                    }
                    continue;
                }

                // This is a small chance that this is a file which is
                // being stored -- get it next time.
                if (isRecent(file))
                {
                  log.debug("file is recent");
                    continue;
                }

                if (deleteDbRecords)
                {
                    log.debug("deleting db record");
                    if (verbose) System.out.println(" - Deleting bitstream information (ID: " + bid + ")");
                    bitstreamInfoDAO.deleteBitstreamInfoWithHistory(bid);
                    if (verbose) System.out.println(" - Deleting bitstream record from database (ID: " + bid + ")");
                    DatabaseManager.delete(context, "Bitstream", bid);
                }

        if (isRegisteredBitstream(row.getStringColumn("internal_id"))) {
View Full Code Here


       
        // process should loop infinitely through
        // most_recent_checksum table
        if (line.hasOption('l'))
        {
            dispatcher = new SimpleDispatcher(new BitstreamInfoDAO(), processStart, false);
        }
        else if (line.hasOption('L'))
        {
            dispatcher = new SimpleDispatcher(new BitstreamInfoDAO(), processStart, true);
        }
        else if (line.hasOption('b'))
        {
            // check only specified bitstream(s)
            String[] ids = line.getOptionValues('b');
            List idList = new ArrayList(ids.length);

            for (int i = 0; i < ids.length; i++)
            {
                try
                {
                    idList.add(new Integer(ids[i]));
                }
                catch (NumberFormatException nfe)
                {
                    System.err.println("The following argument: " + ids[i]
                            + " is not an integer");
                    System.exit(0);
                }
            }
            dispatcher = new ListDispatcher(idList);
        }

        else if (line.hasOption('a'))
        {
            dispatcher = new HandleDispatcher(new BitstreamInfoDAO(), line.getOptionValue('a'));
        }
        else if (line.hasOption('d'))
        {
            // run checker process for specified duration
            try
            {
                dispatcher = new LimitedDurationDispatcher(
                        new SimpleDispatcher(new BitstreamInfoDAO(), processStart, true), new Date(
                                System.currentTimeMillis()
                                        + Utils.parseDuration(line
                                                .getOptionValue('d'))));
            }
            catch (Exception e)
            {
                LOG.fatal("Couldn't parse " + line.getOptionValue('d')
                        + " as a duration: ", e);
                System.exit(0);
            }
        }
        else if (line.hasOption('c'))
        {
          int count = new Integer(line.getOptionValue('c')).intValue();
           
          // run checker process for specified number of bitstreams
            dispatcher = new LimitedCountDispatcher(new SimpleDispatcher(
                    new BitstreamInfoDAO(), processStart, false), count);
        }
        else
        {
            dispatcher = new LimitedCountDispatcher(new SimpleDispatcher(
                    new BitstreamInfoDAO(), processStart, false), 1);
        }
       
        ResultsLogger logger = new ResultsLogger(processStart);
        CheckerCommand checker = new CheckerCommand();
        // verbose reporting
View Full Code Here

     *                If a problem occurs accessing the RDBMS
     */
    public static void cleanup(boolean deleteDbRecords, boolean verbose) throws SQLException, IOException
    {
        Context context = null;
        BitstreamInfoDAO bitstreamInfoDAO = new BitstreamInfoDAO();
        int commitCounter = 0;

        try
        {
            context = new Context();

            String myQuery = "select * from Bitstream where deleted = '1'";

            List<TableRow> storage = DatabaseManager.queryTable(context, "Bitstream", myQuery)
                    .toList();

            for (Iterator<TableRow> iterator = storage.iterator(); iterator.hasNext();)
            {
                TableRow row = iterator.next();
                int bid = row.getIntColumn("bitstream_id");

        GeneralFile file = getFile(row);

                // Make sure entries which do not exist are removed
                if (file == null || !file.exists())
                {
                    log.debug("file is null");
                    if (deleteDbRecords)
                    {
                        log.debug("deleting record");
                        if (verbose)
                        {
                            System.out.println(" - Deleting bitstream information (ID: " + bid + ")");
                        }
                        bitstreamInfoDAO.deleteBitstreamInfoWithHistory(bid);
                        if (verbose)
                        {
                            System.out.println(" - Deleting bitstream record from database (ID: " + bid + ")");
                        }
                        DatabaseManager.delete(context, "Bitstream", bid);
                    }
                    continue;
                }

                // This is a small chance that this is a file which is
                // being stored -- get it next time.
                if (isRecent(file))
                {
                  log.debug("file is recent");
                    continue;
                }

                if (deleteDbRecords)
                {
                    log.debug("deleting db record");
                    if (verbose)
                    {
                        System.out.println(" - Deleting bitstream information (ID: " + bid + ")");
                    }
                    bitstreamInfoDAO.deleteBitstreamInfoWithHistory(bid);
                    if (verbose)
                    {
                        System.out.println(" - Deleting bitstream record from database (ID: " + bid + ")");
                    }
                    DatabaseManager.delete(context, "Bitstream", bid);
View Full Code Here

       
        // process should loop infinitely through
        // most_recent_checksum table
        if (line.hasOption('l'))
        {
            dispatcher = new SimpleDispatcher(new BitstreamInfoDAO(), processStart, false);
        }
        else if (line.hasOption('L'))
        {
            dispatcher = new SimpleDispatcher(new BitstreamInfoDAO(), processStart, true);
        }
        else if (line.hasOption('b'))
        {
            // check only specified bitstream(s)
            String[] ids = line.getOptionValues('b');
            List<Integer> idList = new ArrayList<Integer>(ids.length);

            for (int i = 0; i < ids.length; i++)
            {
                try
                {
                    idList.add(Integer.valueOf(ids[i]));
                }
                catch (NumberFormatException nfe)
                {
                    System.err.println("The following argument: " + ids[i]
                            + " is not an integer");
                    System.exit(0);
                }
            }
            dispatcher = new ListDispatcher(idList);
        }

        else if (line.hasOption('a'))
        {
            dispatcher = new HandleDispatcher(new BitstreamInfoDAO(), line.getOptionValue('a'));
        }
        else if (line.hasOption('d'))
        {
            // run checker process for specified duration
            try
            {
                dispatcher = new LimitedDurationDispatcher(
                        new SimpleDispatcher(new BitstreamInfoDAO(), processStart, true), new Date(
                                System.currentTimeMillis()
                                        + Utils.parseDuration(line
                                                .getOptionValue('d'))));
            }
            catch (Exception e)
            {
                LOG.fatal("Couldn't parse " + line.getOptionValue('d')
                        + " as a duration: ", e);
                System.exit(0);
            }
        }
        else if (line.hasOption('c'))
        {
          int count = Integer.valueOf(line.getOptionValue('c')).intValue();
           
          // run checker process for specified number of bitstreams
            dispatcher = new LimitedCountDispatcher(new SimpleDispatcher(
                    new BitstreamInfoDAO(), processStart, false), count);
        }
        else
        {
            dispatcher = new LimitedCountDispatcher(new SimpleDispatcher(
                    new BitstreamInfoDAO(), processStart, false), 1);
        }
       
        ResultsLogger logger = new ResultsLogger(processStart);
        CheckerCommand checker = new CheckerCommand();
        // verbose reporting
View Full Code Here

TOP

Related Classes of org.dspace.checker.BitstreamInfoDAO

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.