@Override public JSONObject serialize(Filter bean) throws JSONException { if (bean == null) { return null; } if (bean instanceof Selection) { return selectionJsonHandler.serialize((Selection) bean); } if (bean instanceof StringQuery) { JSONObject ret = (JSONObject) JsonSerializer.serialize(bean); return new JSONObject().put("query", ret); } if (bean instanceof AndOr) { AndOr andOr = (AndOr) bean; String operation = andOr.getOperation().name(); List<JSONObject> filters = convertToJson(andOr.filters); return new JSONObject().put(operation, new JSONArray(filters)); } if (bean instanceof BoolFilter) { BoolFilter bool = (BoolFilter) bean; JSONObject ret = new JSONObject(); if (bool.getMust() != null) { ret.put("must", new JSONArray(convertToJson(bool.getMust()))); } if (bool.getMust_not() != null) { ret.put("must_not", new JSONArray(convertToJson(bool.getMust_not()))); } if (bool.getShould() != null) { ret.put("should", new JSONArray(convertToJson(bool.getShould()))); } return new JSONObject().put("bool", ret); } if (bean instanceof Ids) { Ids ids = (Ids) bean; JSONObject ret = new JSONObject(); if (ids.getValues() != null) { ret.put("values", new JSONArray(ids.getValues())); } if (ids.getExcludes() != null) { ret.put("excludes", new JSONArray(ids.getExcludes())); } return new JSONObject().put("ids", ret); } if (bean instanceof Query) { return queryJsonHandler.serialize((Query) bean); } if (bean instanceof QueryFilter) { return new JSONObject() .put("query", queryJsonHandler.serialize(((QueryFilter) bean).getQuery())); } throw new UnsupportedOperationException(bean.getClass() + " is not supported"); }
/** * Pushes a message onto the queue. * * @param msg The body of the message to push. * @param timeout The message's timeout in seconds. * @param delay The message's delay in seconds. * @param expiresIn The message's expiration offset in seconds. * @return The new message's ID * @throws HTTPException If the IronMQ service returns a status other than 200 OK. * @throws IOException If there is an error accessing the IronMQ server. */ public String push(String msg, long timeout, long delay, long expiresIn) throws IOException { Message message = new Message(); message.setBody(msg); message.setTimeout(timeout); message.setDelay(delay); message.setExpiresIn(expiresIn); Messages msgs = new Messages(message); Gson gson = new Gson(); String body = gson.toJson(msgs); Reader reader = client.post("queues/" + name + "/messages", body); Ids ids = gson.fromJson(reader, Ids.class); reader.close(); return ids.getId(0); }
@Override public boolean equals(final Object o) { if (this == o) return true; if (!(o instanceof Show)) return false; final Show show = (Show) o; return !(ids != null ? !ids.equals(show.ids) : show.ids != null); }
public int doStartTag() throws JspException { try { HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); ModuleContext context = (ModuleContext) request.getSession().getAttribute("context"); String viewObject = request.getParameter("viewObject"); viewObject = (viewObject == null || viewObject.equals("")) ? "xava_view" : viewObject; View view = (View) context.get(request, viewObject); MetaReference metaReference = view.getMetaReference(reference).cloneMetaReference(); metaReference.setName(reference); String prefix = request.getParameter("propertyPrefix"); prefix = prefix == null ? "" : prefix; String application = request.getParameter("application"); String module = request.getParameter("module"); String referenceKey = Ids.decorate(application, module, prefix + reference); request.setAttribute(referenceKey, metaReference); String editorURL = "reference.jsp?referenceKey=" + referenceKey + "&onlyEditor=true&frame=false&composite=false&descriptionsList=true"; String editorPrefix = Module.isPortlet() ? "/WEB-INF/jsp/xava/" : "/xava/"; try { pageContext.include(editorPrefix + editorURL); } catch (ServletException ex) { Throwable cause = ex.getRootCause() == null ? ex : ex.getRootCause(); log.error(cause.getMessage(), cause); pageContext.include(editorPrefix + "editors/notAvailableEditor.jsp"); } catch (Exception ex) { log.error(ex.getMessage(), ex); pageContext.include(editorPrefix + "editors/notAvailableEditor.jsp"); } } catch (Exception ex) { log.error(ex.getMessage(), ex); throw new JspException(XavaResources.getString("descriptionsList_tag_error", reference)); } return SKIP_BODY; }
@Override public int hashCode() { return ids != null ? ids.hashCode() : 0; }