Package org.sakaiproject.entitybus.exception

Examples of org.sakaiproject.entitybus.exception.EntityException


        try {
            Integer id = Integer.parseInt(ref.getId());
            WorkflowItem workflowItem = WorkflowItem.find(context, id);
            WorkflowManager.claim(context, workflowItem, context.getCurrentUser());
        } catch (SQLException ex) {
            throw new EntityException("Internal server error", "SQL error", 500);
        } catch (AuthorizeException ae) {
            throw new EntityException("Forbidden", "Forbidden", 403);
        } catch (NumberFormatException ex) {
            throw new EntityException("Bad request", "Could not parse input", 400);
        } catch (IOException e) {
            throw new EntityException("Internal server error", "IO error", 500);
        }
    }
View Full Code Here


        try {
            Integer id = Integer.parseInt(ref.getId());
            WorkflowItem workflowItem = WorkflowItem.find(context, id);
            WorkflowManager.unclaim(context, workflowItem, context.getCurrentUser());
        } catch (SQLException ex) {
            throw new EntityException("Internal server error", "SQL error", 500);
        } catch (AuthorizeException ae) {
            throw new EntityException("Forbidden", "Forbidden", 403);
        } catch (NumberFormatException ex) {
            throw new EntityException("Bad request", "Could not parse input", 400);
        } catch (IOException e) {
            throw new EntityException("Internal server error", "IO error", 500);
        }
    }
View Full Code Here

        try {
            Integer id = Integer.parseInt(ref.getId());
            WorkflowItem workflowItem = WorkflowItem.find(context, id);
            WorkflowManager.advance(context, workflowItem, context.getCurrentUser());
        } catch (SQLException ex) {
            throw new EntityException("Internal server error", "SQL error", 500);
        } catch (AuthorizeException ae) {
            throw new EntityException("Forbidden", "Forbidden", 403);
        } catch (NumberFormatException ex) {
            throw new EntityException("Bad request", "Could not parse input", 400);
        } catch (IOException e) {
            throw new EntityException("Internal server error", "IO error", 500);
        }
    }
View Full Code Here

            Integer id = Integer.parseInt(ref.getId());
            String reason = (String) inputVar.get("reason");
            WorkflowItem workflowItem = WorkflowItem.find(context, id);
            WorkflowManager.reject(context, workflowItem, context.getCurrentUser(), reason);
        } catch (SQLException ex) {
            throw new EntityException("Internal server error", "SQL error", 500);
        } catch (AuthorizeException ae) {
            throw new EntityException("Forbidden", "Forbidden", 403);
        } catch (NumberFormatException ex) {
            throw new EntityException("Bad request", "Could not parse input", 400);
        } catch (IOException e) {
            throw new EntityException("Internal server error", "IO error", 500);
        }
    }
View Full Code Here

            // Check authorisation
            AuthorizeManager.authorizeAction(context, res, Constants.READ);
            this.id = res.getID();
            //context.complete();
        } catch (SQLException ex) {
            throw new EntityException("Internal server error", "SQL error", 500);
        } catch (AuthorizeException ex) {
            throw new EntityException("Forbidden", "Forbidden", 403);
        } catch (NumberFormatException ex) {
            throw new EntityException("Bad request", "Could not parse input", 400);
        }
    }
View Full Code Here

            AuthorizeManager.authorizeAction(context, res, Constants.READ);

            this.id = res.getID();
            //context.complete();
        } catch (SQLException ex) {
            throw new EntityException("Internal server error", "SQL error", 500);
        } catch (AuthorizeException ex) {
            throw new EntityException("Forbidden", "Forbidden", 403);
        } catch (NumberFormatException ex) {
            throw new EntityException("Bad request", "Could not parse input", 400);
        }
    }
View Full Code Here

        return true;
    }

    public Object getEntity(EntityReference reference) {
        log.info(userInfo() + "get_entity:" + reference.getId());
        throw new EntityException("Not Acceptable", "The data is not available", 406);
    }
View Full Code Here

        Context context;
        try {
            context = new Context();
        } 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
            // deprecated - this is now handled at the end of function
            QueryArgs arg = new QueryArgs();
            arg.setQuery(query);

//            if (_perpage > 0) {
//                arg.setPageSize(_perpage);
//            }
            arg.setStart(_start);

            if ((_order.equalsIgnoreCase("descending")) || (_order.equalsIgnoreCase("desc"))) {
                arg.setSortOrder(SortOption.DESCENDING);
            } else {
                arg.setSortOrder(SortOption.ASCENDING);
            }

            QueryResults qre;

            /**
             * search can be performed only on community or collection selected
             * or all, not on the both in same time; check this requirement
             */
//            if (_community != null) {
//                qre = DSQuery.doQuery(context, arg, _community);
//            } else if (_collection != null) {
//                qre = DSQuery.doQuery(context, arg, _collection);
//            } else {
                qre = DSQuery.doQuery(context, arg);
//            }
            entities.add(new SearchResultsInfoEntity(qre.getHitCount(), qre.getHitTypes(), qre.getHitHandles(), qre.getHitIds()));

            /**
             * check returned objects, recognize them and put in result
             * list as expected
             */
            for (int x = 0; x < qre.getHitTypes().size(); x++) {
                switch ((Integer) (qre.getHitTypes().get(x))) {
                    case Constants.ITEM: {
//                            entities.add(idOnly ? new ItemEntityId(qre.getHitIds().get(x).toString(), context) : new ItemEntity(qre.getHitIds().get(x).toString(), context,1, uparams));
                    }
                    break;

                    case Constants.COMMUNITY: {
//                            entities.add(idOnly ? new CommunityEntityId(qre.getHitIds().get(x).toString(), context) : new CommunityEntity(qre.getHitIds().get(x).toString(), context,1, uparams));
                    }
                    break;

                    case Constants.COLLECTION: {
//                            entities.add(idOnly ? new CollectionEntityId(qre.getHitIds().get(x).toString(), context) : new CollectionEntity(qre.getHitIds().get(x).toString(), context,1, uparams));
                    }
                    break;

                    case Constants.BITSTREAM: {
//                            entities.add(idOnly ? new BitstreamEntityId(qre.getHitIds().get(x).toString(), context) : new BitstreamEntity(qre.getHitIds().get(x).toString(), context,1, uparams));
                    }
                    break;

                    case Constants.BUNDLE: {
//                            entities.add(idOnly ? new BundleEntityId(qre.getHitIds().get(x).toString(), context) : new BundleEntity(qre.getHitIds().get(x).toString(), context,1, uparams));
                    }
                    break;

                    case Constants.EPERSON: {
//                            entities.add(idOnly ? new UserEntityId(qre.getHitIds().get(x).toString(), context) : new UserEntity(qre.getHitIds().get(x).toString(), context,1, uparams));
                    }
                    break;

                }
            }

            context.complete();
        } catch (SQLException sql) {
            throw new EntityException("Internal Server Error", "SQL Problem", 500);
        } catch (IOException io) {
            throw new EntityException("Internal Server Error", "Could not execute query", 500);
        }

        /**
         * if the full info are requested and there are sorting requirements
         * process entities through sorting filter first
View Full Code Here

            refreshParams(context);

            Community comm = Community.find(context, Integer.parseInt(id));
            return comm != null ? true : false;
        } catch (SQLException ex) {
            throw new EntityException("Internal server error", "SQL error", 500);
        } catch (NumberFormatException ex) {
            throw new EntityException("Bad request", "Could not parse input", 400);
        } finally {
            removeConn(context);
        }
    }
View Full Code Here

            if (entityExists(ref.getId())) {
                return new CommunityEntity(ref.getId(), context, uparams);
            }
        } catch (SQLException ex) {
            throw new EntityException("Internal server error", "SQL error", 500);
        } finally {
            removeConn(context);
        }
        throw new IllegalArgumentException("Invalid id:" + ref.getId());
    }
View Full Code Here

TOP

Related Classes of org.sakaiproject.entitybus.exception.EntityException

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.