Package org.dspace.rest.util

Examples of org.dspace.rest.util.UserRequestParams


        } catch (SQLException ex) {
            throw new EntityException("Internal server error", "SQL error", 500);
        }

        // refresh parameters for this request
        UserRequestParams uparams;
        uparams = refreshParams(context);
        List<Object> entities = new ArrayList<Object>();

        try {
            // extract query arguments from the request
View Full Code Here


        }

        Context context = null;
        try {
            context = new Context();
            UserRequestParams uparams = refreshParams(context);

            if (entityExists(ref.getId())) {
                return new CommunityEntity(ref.getId(), context, uparams);
            }
        } catch (SQLException ex) {
View Full Code Here

        log.info(userInfo() + "list_communities");

        Context context = null;
        try {
            context = new Context();
            UserRequestParams uparams = refreshParams(context);

            List<Object> entities = new ArrayList<Object>();
            Community[] communities = Community.findAllTop(context);
            for (Community c : communities) {
                entities.add(trim ? new CommunityEntityTrim(c, uparams) : new CommunityEntity(c, uparams));
View Full Code Here

        }

        Context context = null;
        try {
            context = new Context();
            UserRequestParams uparams = refreshParams(context);

            if (entityExists(ref.getId())) {
                return new ItemEntity(ref.getId(), context, uparams);
            }
        } catch (SQLException ex) {
View Full Code Here

        log.info(userInfo() + "list_items");

        Context context = null;
        try {
            context = new Context();
            UserRequestParams uparams = refreshParams(context);

            List<Object> entities = new ArrayList<Object>();
            ItemIterator items = Item.findAll(context);
            while (items.hasNext()) {
                entities.add(new ItemEntity(items.next(), context, uparams));
View Full Code Here

        log.info(userInfo() + "list_harvests");

        Context context = null;
        try {
            context = new Context();
            UserRequestParams uparams = refreshParams(context);

            List<Object> entities = new ArrayList<Object>();
            List<HarvestedItemInfo> res;

            /**
 
View Full Code Here

    public void after(EntityView view, HttpServletRequest req, HttpServletResponse res) {
    }

    public UserRequestParams refreshParams(Context context) {

        UserRequestParams uparam = new UserRequestParams();

        try {
            user = reqStor.getStoredValue("user").toString();
        } catch (NullPointerException ex) {
            user = "";
        }

        try {
            pass = reqStor.getStoredValue("pass").toString();
        } catch (NullPointerException ex) {
            pass = "";
        }

        try {
            if (!(userc.isEmpty() && passc.isEmpty())) {
                user = userc;
                pass = passc;
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        } // now try to login user
        loggedUser = "anonymous";

        try {
            EPerson eUser = EPerson.findByEmail(context, user);
            if ((eUser.canLogIn()) && (eUser.checkPassword(pass))) {
                context.setCurrentUser(eUser);
                loggedUser = eUser.getName();
            } else {
                throw new EntityException("Bad username or password", user, 403);
            }
        } catch (SQLException sql) {
//            System.out.println(sql.toString());
            sql.printStackTrace();
        } catch (AuthorizeException auth) {
            throw new EntityException("Unauthorised", user, 401);
        } catch (NullPointerException ne) {
            if (!(user.equals("") && pass.equals(""))) {
                throw new EntityException("Bad username or password", user, 403);
            }
        }

        this.collections = "true".equals(reqStor.getStoredValue("collections"));
        uparam.setCollections(this.collections);
        this.trim = "true".equals(reqStor.getStoredValue("trim"));
        uparam.setTrim(this.trim);
        this.parents = "true".equals(reqStor.getStoredValue("parents"));
        uparam.setParents(this.parents);
        this.children = "true".equals(reqStor.getStoredValue("children"));
        uparam.setChildren(this.children);
        this.groups = "true".equals(reqStor.getStoredValue("groups"));
        uparam.setGroups(this.groups);
        this.replies = "true".equals(reqStor.getStoredValue("replies"));
        uparam.setReplies(this.replies);

//        try {
//            action = reqStor.getStoredValue("action").toString();
//            uparam.setAction(action);
//        } catch (NullPointerException ex) {
//            action = "";
//        }

        try {
            query = reqStor.getStoredValue("query").toString();
            uparam.setQuery(query);
        } catch (NullPointerException ex) {
            query = "";
        }

        try {
            Object o = reqStor.getStoredValue("fields");
            if (o instanceof String) {
                fields = new String[]{o.toString()};
            } else if (o instanceof String[]) {
                fields = (String[]) o;
            } else if (o == null) {
                fields = null;
            }
            uparam.setFields(fields);
        } catch (NullPointerException ex) {
            fields = null;
        }

        try {
            status = reqStor.getStoredValue("status").toString();
            uparam.setStatus(status);
        } catch (NullPointerException ex) {
            status = "";
        }

        try {
            submitter = reqStor.getStoredValue("submitter").toString();
            uparam.setSubmitter(submitter);
        } catch (NullPointerException ex) {
            submitter = "";
        }

        try {
            reviewer = reqStor.getStoredValue("reviewer").toString();
            uparam.setReviewer(reviewer);
        } catch (NullPointerException ex) {
            reviewer = "";
        }

        try {
            String bundleStr = reqStor.getStoredValue("type").toString();
            uparam.setType(bundleStr.split(","));
        } catch (NullPointerException ex) {
            type = null;
        }

        try {
            _order = reqStor.getStoredValue("order").toString();
            uparam.setOrder(_order);
        } catch (NullPointerException ex) {
            _order = "";
        }

        try {
            _sort = reqStor.getStoredValue("sort").toString();
            uparam.setSort(_sort);
        } catch (NullPointerException ex) {
            _sort = "";


        } // both parameters are used according to requirements
        if (_order.length() > 0 && _sort.equals("")) {
            _sort = _order;
        }

        try {
            _start = Integer.parseInt(reqStor.getStoredValue("start").toString());
            uparam.setStart(_start);
        } catch (NullPointerException ex) {
            _start = 0;
        }

        try {
            _limit = Integer.parseInt(reqStor.getStoredValue("limit").toString());
            uparam.setLimit(_limit);
        } catch (NullPointerException ex) {
            _limit = 0;
        } // some checking for invalid values

        if (_limit < 0) {
View Full Code Here

            }

            Context context = null;
            try {
                context = new Context();
                UserRequestParams uparams = refreshParams(context);

                Object CE = entityConstructor.newInstance();
                Method method = CE.getClass().getMethod(function, funcParamsGET.get(action));
                result = method.invoke(CE, ref, uparams, context);
            } catch (NoSuchMethodException ex) {
View Full Code Here

        log.info(userInfo() + "list_users");

        Context context = null;
        try {
            context = new Context();
            UserRequestParams uparams = refreshParams(context);

            List<Object> entities = new ArrayList<Object>();
            EPerson[] ePersons = ContentHelper.findAllEPerson(context, _start, _limit);
            for (EPerson c : ePersons) {
                entities.add(new UserEntity(c, context, uparams));
View Full Code Here

TOP

Related Classes of org.dspace.rest.util.UserRequestParams

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.