Package org.sakaiproject.entitybus.exception

Examples of org.sakaiproject.entitybus.exception.EntityException


                        } else {
                            // this better be an edit of an entity
                            view.setViewKey(EntityView.VIEW_EDIT);
                        }
                    } else {
                        throw new EntityException("Unable to handle POST request with _method, unknown method (only PUT/DELETE allowed): " + _method,
                                view.getEntityReference()+"", HttpServletResponse.SC_BAD_REQUEST);                       
                    }
                }
                view.setMethod(EntityView.Method.POST);
            } else {
                throw new EntityException("Unable to handle request method, unknown method (only GET/POST/PUT/DELETE allowed): " + method,
                        view.getEntityReference()+"", HttpServletResponse.SC_BAD_REQUEST);
            }

            // check that the request is valid (delete requires an entity id)
            if ( EntityView.VIEW_DELETE.equals(view.getViewKey())
                    && view.getEntityReference().getId() == null) {
                throw new EntityException("Unable to handle entity ("+view.getEntityReference()+") delete request without entity id, url="
                        + view.getOriginalEntityUrl(),
                        view.getEntityReference()+"", HttpServletResponse.SC_BAD_REQUEST);
            }
        }
        return output;
View Full Code Here


                            } catch (RuntimeException e) {
                                throw new EntityEncodingException("Unable to populate bean for ref ("+ref+") from request: " + e.getMessage(), ref+"", e);
                            }
                        } else {
                            // no request params, bad request
                            throw new EntityException("No request params for html input request (there must be at least one) for reference: " + ref,
                                    ref.toString(), HttpServletResponse.SC_BAD_REQUEST);
                        }
                    }
                } else {
                    // all other formats
                    if (input == null) {
                        // no request params, bad request
                        throw new EntityException("No input for input translation (input cannot be null) for reference: " + ref,
                                ref.toString(), HttpServletResponse.SC_BAD_REQUEST);
                    } else {
                        String data = StringUtils.makeStringFromInputStream(input);
                        Map<String, Object> decoded = null;
                        try {
                            decoded = decodeData(data, format);
                        } catch (IllegalArgumentException iae) {
                            throw new EntityEncodingException("No encoder available for the given format ("+format+"), ref=" + ref + ":" + iae.getMessage(), ref.toString(), iae);
                        } catch (UnsupportedOperationException uoe) {
                            throw new EntityEncodingException("Failure during internal input encoding of entity: " + ref + " to format ("+format+"):" + uoe.getMessage(), ref.toString(), uoe);
                        }
                        entity = current;
                        // handle the special case where the JSON was created by xstream or something else that puts the data inside an object with a "root"
                        if (decoded.size() == 1 && decoded.containsKey(ref.getPrefix())) {
                            Object o = decoded.get(ref.getPrefix());
                            if (o instanceof Map) {
                                decoded = (Map<String, Object>) o;
                            }
                        }
                        try {
                            ReflectUtils.getInstance().populate(entity, decoded);
                        } catch (RuntimeException e) {
                            throw new EntityEncodingException("Unable to populate bean for ref ("+ref+") from data: " + decoded + ":" + e.getMessage(), ref+"", e);
                        }
                    }
                }
            }
        } else {
            throw new IllegalArgumentException("This entity ("+ref+") does not allow input translation");
        }
        if (entity == null) {
            throw new EntityException("Unable to encode entity from input for reference: " + ref, ref.toString(), HttpServletResponse.SC_BAD_REQUEST);
        }
        return entity;
    }
View Full Code Here

            refreshParams(context);

            Collection comm = Collection.find(context, Integer.parseInt(id));
            return comm != null ? true : false;
        } catch (SQLException ex) {
            throw new EntityException("Internal server error", "SQL error", 500);
        } finally {
            removeConn(context);
        }
    }
View Full Code Here

            if (entityExists(ref.getId())) {
                return new CollectionEntity(ref.getId(), context);
            }
        } 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

                entities.add(trim ? new CollectionEntityTrim(c) : new CollectionEntity(c));
            }

            return entities;
        } catch (SQLException ex) {
            throw new EntityException("Internal server error", "SQL error", 500);
        } finally {
            removeConn(context);
        }
    }
View Full Code Here

            if (res.getOwner() != null) {
                this.reviewer = new UserEntityTrim(res.getOwner());
            }
            this.collection = new CollectionEntityTrimC(res.getCollection());
        } catch (SQLException ex) {
            throw new EntityException("Internal server error", "SQL error", 500);
        }
    }
View Full Code Here

            if (res.getOwner() != null) {
                this.reviewer = new UserEntityTrim(res.getOwner());
            }
            this.collection = new CollectionEntityTrimC(res.getCollection());
        } catch (SQLException ex) {
            throw new EntityException("Internal server error", "SQL error", 500);
        }
    }
View Full Code Here

    public Object getCount(EntityReference ref, UserRequestParams uparams, Context context) {
        try {
            return ContentHelper.countItemsWorkflow(context, uparams.getReviewer(), uparams.getSubmitter(), uparams.getFields(), uparams.getStatus());
        } catch (SQLException ex) {
            throw new EntityException("Internal server error", "SQL error", 500);
        }
    }
View Full Code Here

    public Object getSubmittersCount(EntityReference ref, UserRequestParams uparams, Context context) {
        try {
            return ContentHelper.countItemsSubmitters(context, uparams.getQuery());
        } catch (SQLException ex) {
            throw new EntityException("Internal server error", "SQL error", 500);
        }
    }
View Full Code Here

            for (EPerson e : ePersons) {
                entities.add(new UserEntityTrim(e));
            }
            return entities;
        } catch (SQLException ex) {
            throw new EntityException("Internal server error", "SQL error", 500);
        }
    }
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.