Package org.dspace.content

Examples of org.dspace.content.DSpaceObject


        if(!reader.isDeleted(i))
        {
          Document doc = reader.document(i);
            String handle = doc.get("handle");
           
            DSpaceObject o = HandleManager.resolveToObject(context, handle);

                if (o == null)
                {
                  log.info("Deleting: " + handle);
                  /* Use IndexWriter to delete, its easier to manage write.lock */
                  DSIndexer.unIndexContent(context, handle);
                }
                else
                {
                  context.removeCached(o, o.getID());
                  log.debug("Keeping: " + handle);
                }
        }
        else
        {
View Full Code Here


        errors.add(error);
    }
   
   
    /* Set up our current Dspace object */
    DSpaceObject dso;
    switch (objectType) {
      case Constants.COMMUNITY: dso = Community.find(context, objectID); break;
      case Constants.COLLECTION: dso = Collection.find(context, objectID); break;
      case Constants.ITEM: dso = org.dspace.content.Item.find(context, objectID); break;
      case Constants.BUNDLE: dso = Bundle.find(context, objectID); break;
View Full Code Here

        {
            formatter.format("sample "+type);
        }
        else
        {
            DSpaceObject dso = (DSpaceObject) object;
            String name = dso.getName();
            if (name != null)
            {
                formatter.format(name);
            }
            else
View Full Code Here

        // If an Item is created or its metadata is modified..
        case Constants.ITEM:
            if(et == Event.MODIFY_METADATA || et == Event.CREATE)
            {
                DSpaceObject subj = event.getSubject(ctx);
                if (subj != null)
                {
                    log.debug("consume() adding event to update queue: " + event.toString());
                    toUpdate.add((Item)subj);
                }
View Full Code Here

            // validate each collection arg to see if it's a real collection
            mycollections = new Collection[collections.length];
            for (int i = 0; i < collections.length; i++)
            {
                // sanity check: did handle resolve, and to a collection?
                DSpaceObject dso = HandleManager.resolveToObject(context,
                        collections[i]);
                if (dso == null)
                    throw new IllegalArgumentException(
                            "Bad collection list -- "
                                    + "Cannot resolve collection handle \""
                                    + collections[i] + "\"");
                else if (dso.getType() != Constants.COLLECTION)
                    throw new IllegalArgumentException(
                            "Bad collection list -- " + "Object at handle \""
                                    + collections[i]
                                    + "\" is not a collection!");
                mycollections[i] = (Collection) dso;
                System.out.println((i == 0 ? "  Owning " : "  ")
                        + " Collection: "
                        + mycollections[i].getMetadata("name"));
            }

            try
            {
                WorkspaceItem wi = sip.ingest(context, mycollections[0],
                        source, pkgParams, null);
                if (useWorkflow)
                {
                    String handle = null;

                    // Check if workflow completes immediately, and
                    // return Handle if so.
                    WorkflowItem wfi = WorkflowManager.startWithoutNotify(context, wi);

                    if (wfi.getState() == WorkflowManager.WFSTATE_ARCHIVE)
                    {
                        Item ni = wfi.getItem();
                        handle = HandleManager.findHandle(context, ni);
                    }
                    if (handle == null)
                    System.out.println("Created Workflow item, ID="
                                + String.valueOf(wfi.getID()));
                    else
                        System.out.println("Created and installed item, handle="+handle);
                }
                else
                {
                    InstallItem.installItem(context, wi);
                    System.out.println("Created and installed item, handle="
                            + HandleManager.findHandle(context, wi.getItem()));
                }
                context.complete();
                System.exit(0);
            }
            catch (Exception e)
            {
                // abort all operations
                context.abort();
                e.printStackTrace();
                System.out.println(e);
                System.exit(1);
            }
        }
        else
        {
            OutputStream dest = (sourceFile.equals("-")) ? (OutputStream) System.out
                    : (OutputStream) (new FileOutputStream(sourceFile));

            PackageDisseminator dip = (PackageDisseminator) PluginManager
                    .getNamedPlugin(PackageDisseminator.class, packageType);
            if (dip == null)
                usageError("Error, Unknown package type: " + packageType);

            DSpaceObject dso = HandleManager.resolveToObject(context,
                    itemHandle);
            if (dso == null)
                throw new IllegalArgumentException("Bad Item handle -- "
                        + "Cannot resolve handle \"" + itemHandle);
            dip.disseminate(context, dso, pkgParams, dest);
View Full Code Here

        ArrayList<Item> items = new ArrayList<Item>();
        @SuppressWarnings("unchecked")
        java.util.List<String> handles = results.getHitHandles();
        for (String handle : handles)
        {
            DSpaceObject resultDSO = HandleManager.resolveToObject(context, handle);

            if (resultDSO instanceof Item)
            {
              Item item = (Item) resultDSO;
             
View Full Code Here

      }
     
        try
        {
          Context context = ContextUtil.obtainContext(objectModel);
            DSpaceObject dso = HandleUtil.obtainHandle(objectModel);
           
            if (dso == null)
              return null;
           
            boolean authorized =
View Full Code Here

            Parameters parameters)
    {
        try
        {
            Request request = ObjectModelHelper.getRequest(objectModel);
            DSpaceObject dso = HandleUtil.obtainHandle(objectModel);
            if (dso.getType() == Constants.ITEM)
            {
                Item item = (Item) dso;
                long modSince = request.getDateHeader("If-Modified-Since");
                if (modSince != -1 && item.getLastModified().getTime() < modSince)
                {
View Full Code Here

                getLogger().warn("Invalid test pattern, '" + pattern + "', encountered.");
                return null;
            }
        }

        DSpaceObject dso = null;
        try
        {
            // HandleUtil handles caching if needed.
            dso = HandleUtil.obtainHandle(objectModel);
        }
        catch (SQLException sqle)
        {
            throw new PatternException("Unable to obtain DSpace Object", sqle);
        }

        if (dso == null)
            return null;

        Map<String, String> result = new HashMap<String, String>();
        for (String expression : expressions)
        {
            if (ITEM_EXPRESSION.equals(expression)
                    && dso.getType() == Constants.ITEM)
            {
                result.put("type", ITEM_EXPRESSION);
                return result;
            }
            else if (COLLECITON_EXPRESSION.equals(expression)
                    && dso.getType() == Constants.COLLECTION)
            {
                result.put("type", COLLECITON_EXPRESSION);
                return result;
            }
            else if (COMMUNITY_EXPRESSION.equals(expression)
                    && dso.getType() == Constants.COMMUNITY)
            {
                result.put("type", COMMUNITY_EXPRESSION);
                return result;
            }
        }
View Full Code Here

    public Map match(String pattern, Map objectModel, Parameters parameters)
            throws PatternException
    {
        try
        {
            DSpaceObject dso = HandleUtil.obtainHandle(objectModel);
            if (dso == null)
                return null;

            DSpaceObject parent = dspaceObjectWalk(dso, pattern);

            if (parent != null)
            {
                return new HashMap();
            }
View Full Code Here

TOP

Related Classes of org.dspace.content.DSpaceObject

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.