Package org.dspace.rest.common

Examples of org.dspace.rest.common.Collection


            if(AuthorizeManager.authorizeActionBoolean(context, dso, org.dspace.core.Constants.READ)) {
                switch(dso.getType()) {
                    case Constants.COMMUNITY:
                        return new Community((org.dspace.content.Community) dso, expand, context);
                    case Constants.COLLECTION:
                        return new Collection((org.dspace.content.Collection) dso, expand, context, null, null);
                    case Constants.ITEM:
                        return new Item((org.dspace.content.Item) dso, expand, context);
                    default:
                        return new DSpaceObject(dso);
                }
View Full Code Here


            @Context HttpHeaders headers, @Context HttpServletRequest request) throws WebApplicationException
    {

        log.info("Reading collection(id=" + collectionId + ").");
        org.dspace.core.Context context = null;
        Collection collection = null;

        try
        {
            context = createContext(getUser(headers));

            org.dspace.content.Collection dspaceCollection = findCollection(context, collectionId, org.dspace.core.Constants.READ);
            writeStats(dspaceCollection, UsageEvent.Action.VIEW, user_ip, user_agent, xforwarderfor,
                    headers, request, context);

            collection = new Collection(dspaceCollection, expand, context, limit, offset);
            context.complete();

        }
        catch (SQLException e)
        {
View Full Code Here

            org.dspace.content.Collection[] dspaceCollections = org.dspace.content.Collection.findAll(context, limit, offset);
            for(org.dspace.content.Collection dspaceCollection : dspaceCollections)
            {
                if (AuthorizeManager.authorizeActionBoolean(context, dspaceCollection, org.dspace.core.Constants.READ))
                {
                    Collection collection = new org.dspace.rest.common.Collection(dspaceCollection, null, context, limit,
                            offset);
                    collections.add(collection);
                    writeStats(dspaceCollection, UsageEvent.Action.VIEW, user_ip, user_agent,
                            xforwarderfor, headers, request, context);
                }
View Full Code Here

    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
    public Collection findCollectionByName(String name, @Context HttpHeaders headers) throws WebApplicationException
    {
        log.info("Searching for first collection with name=" + name + ".");
        org.dspace.core.Context context = null;
        Collection collection = null;

        try
        {
            context = createContext(getUser(headers));
            org.dspace.content.Collection[] dspaceCollections;

            dspaceCollections = org.dspace.content.Collection.findAll(context);

            for (org.dspace.content.Collection dspaceCollection : dspaceCollections)
            {
                if (AuthorizeManager.authorizeActionBoolean(context, dspaceCollection, org.dspace.core.Constants.READ))
                {
                    if (dspaceCollection.getName().equals(name))
                    {
                        collection = new Collection(dspaceCollection, "", context, 100, 0);
                        break;
                    }
                }
            }

            context.complete();

        }
        catch (SQLException e)
        {
            processException("Something went wrong while searching for collection(name=" + name + ") from database. Message: "
                    + e, context);
        }
        catch (ContextException e)
        {
            processException("Something went wrong while searching for collection(name=" + name + "), ContextError. Message: "
                    + e.getMessage(), context);
        }
        finally
        {
            processFinally(context);
        }

        if (collection == null)
        {
            log.info("Collection was not found.");
        }
        else
        {
            log.info("Collection was found with id(" + collection.getId() + ").");
        }
        return collection;
    }
View Full Code Here

            org.dspace.content.Collection[] dspaceCollections = dspaceCommunity.getCollections();
            for (int i = offset; (i < (offset + limit)) && (i < dspaceCollections.length); i++)
            {
                if (AuthorizeManager.authorizeActionBoolean(context, dspaceCollections[i], org.dspace.core.Constants.READ))
                {
                    collections.add(new Collection(dspaceCollections[i], expand, context, 20, 0));
                    writeStats(dspaceCollections[i], UsageEvent.Action.VIEW, user_ip, user_agent,
                            xforwarderfor, headers, request, context);
                }
            }
View Full Code Here

            throws WebApplicationException
    {

        log.info("Adding collection into community(id=" + communityId + ").");
        org.dspace.core.Context context = null;
        Collection retCollection = null;

        try
        {
            context = createContext(getUser(headers));
            org.dspace.content.Community dspaceCommunity = findCommunity(context, communityId, org.dspace.core.Constants.WRITE);

            writeStats(dspaceCommunity, UsageEvent.Action.UPDATE, user_ip, user_agent, xforwarderfor,
                    headers, request, context);

            org.dspace.content.Collection dspaceCollection = dspaceCommunity.createCollection();
            dspaceCollection.setLicense(collection.getLicense());
            // dspaceCollection.setLogo(collection.getLogo()); // TODO Add this option.
            dspaceCollection.setMetadata("name", collection.getName());
            dspaceCollection.setMetadata(org.dspace.content.Collection.COPYRIGHT_TEXT, collection.getCopyrightText());
            dspaceCollection.setMetadata(org.dspace.content.Collection.INTRODUCTORY_TEXT, collection.getIntroductoryText());
            dspaceCollection.setMetadata(org.dspace.content.Collection.SHORT_DESCRIPTION, collection.getShortDescription());
            dspaceCollection.setMetadata(org.dspace.content.Collection.SIDEBAR_TEXT, collection.getSidebarText());
            dspaceCollection.setLicense(collection.getLicense());
            dspaceCollection.update();
            dspaceCommunity.update();

            retCollection = new Collection(dspaceCollection, "", context, 100, 0);
            context.complete();

        }
        catch (SQLException e)
        {
            processException("Could not add collection into community(id=" + communityId + "), SQLException. Message:" + e,
                    context);
        }
        catch (AuthorizeException e)
        {
            processException("Could not add collection into community(id=" + communityId + "), AuthorizeException. Message:" + e,
                    context);
        }
        catch (ContextException e)
        {
            processException(
                    "Could not add collection into community(id=" + communityId + "), ContextException. Message:"
                            + e.getMessage(), context);
        }
        finally
        {
            processFinally(context);
        }


        log.info("Collection was successfully added into community(id=" + communityId + "). Collection handle="
                + retCollection.getHandle());
        return retCollection;
    }
View Full Code Here

TOP

Related Classes of org.dspace.rest.common.Collection

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.