private ActionReturn getBullhornAlerts(List<BullhornAlert> alerts) { ResourceLoader rl = new ResourceLoader("bullhorns"); if (alerts.size() > 0) { Map<String, Object> data = new HashMap<>(); data.put("alerts", alerts); data.put("i18n", rl); return new ActionReturn(data); } else { Map<String, String> i18n = new HashMap<>(); i18n.put("noAlerts", rl.getString("noAlerts")); Map<String, Object> data = new HashMap<>(); data.put("message", "NO_ALERTS"); data.put("i18n", i18n); return new ActionReturn(data); } }
/** * Special constructor which will ensure the data is output exactly as is without adding in the entity meta data * @param data the data to encode (any java objects including collections, POJOs, maps, etc.) * @param headers (optional) headers to include in the response (can use the header constants if desired: {@link Header}) * @param format (optional) the format to return this data in (from {@link Formats}), e.g. Formats.XML */ public ActionReturn(Object data, Map<String, String> headers, String format) { if (data != null && EntityData.class.isAssignableFrom(data.getClass())) { this.entityData = (EntityData) data; } else { this.entityData = new EntityData(data); } this.format = format; setHeaders(headers); }
} else { addResponseHeaders(res, actionReturn.getHeaders());
} else { addResponseHeaders(res, actionReturn.getHeaders());
private ActionReturn getBullhornAlerts(List<BullhornAlert> alerts) { ResourceLoader rl = new ResourceLoader("bullhorns"); if (alerts.size() > 0) { Map<String, Object> data = new HashMap(); data.put("alerts", alerts); data.put("i18n", rl); return new ActionReturn(data); } else { Map<String, String> i18n = new HashMap(); i18n.put("noAlerts", rl.getString("noAlerts")); Map<String, Object> data = new HashMap(); data.put("message", "NO_ALERTS"); data.put("i18n", i18n); return new ActionReturn(data); } }
@EntityCustomAction(action = "bullhornCounts", viewKey = EntityView.VIEW_LIST) public ActionReturn getBullhornCounts(EntityView view) { String currentUserId = getCheckedCurrentUser(); Map<String, Long> counts = new HashMap<>(); counts.put("academic", bullhornService.getAcademicAlertCount(currentUserId)); counts.put("social", bullhornService.getSocialAlertCount(currentUserId)); return new ActionReturn(counts); }
@EntityCustomAction(action="yyyy",viewKey="") public ActionReturn xxxAction(EntityView view) { return new ActionReturn(view.getOriginalEntityUrl()); }
@EntityCustomAction(action = "bullhornCounts", viewKey = EntityView.VIEW_LIST) public ActionReturn getBullhornCounts(EntityView view) { String currentUserId = getCheckedCurrentUser(); Map<String, Integer> counts = new HashMap(); counts.put("academic", bullhornService.getAcademicAlertCount(currentUserId)); counts.put("social", bullhornService.getSocialAlertCount(currentUserId)); return new ActionReturn(counts); }
@EntityCustomAction(action="yyyy",viewKey="") public ActionReturn xxxAction(EntityView view) { return new ActionReturn(view.getOriginalEntityUrl()); }
actionReturn = (ActionReturn) result; } else if (OutputStream.class.isAssignableFrom(resultClass)) { actionReturn = new ActionReturn(outputStream); } else if (String.class.isAssignableFrom(resultClass)) { actionReturn = new ActionReturn((String) result); } else if (List.class.isAssignableFrom(resultClass)) { actionReturn = new ActionReturn(data, (String) null); } else if (EntityData.class.isAssignableFrom(resultClass)) { actionReturn = new ActionReturn( (EntityData) result, (String) null); } else { actionReturn = new ActionReturn( ed, (String) null);
actionReturn = (ActionReturn) result; } else if (OutputStream.class.isAssignableFrom(resultClass)) { actionReturn = new ActionReturn(outputStream); } else if (String.class.isAssignableFrom(resultClass)) { actionReturn = new ActionReturn((String) result); } else if (List.class.isAssignableFrom(resultClass)) { actionReturn = new ActionReturn(data, (String) null); } else if (EntityData.class.isAssignableFrom(resultClass)) { actionReturn = new ActionReturn( (EntityData) result, (String) null); } else { actionReturn = new ActionReturn( ed, (String) null);
return new ActionReturn(hits); } catch (Exception e) { log.error(e.getMessage(), e);
return new ActionReturn(hits); } catch (Exception e) { log.error(e.getMessage(), e);
return new ActionReturn(Formats.UTF_8, Formats.HTML_MIME_TYPE, writer.toString()); } catch (IOException ioe) { throw new EntityException("Failed to format profile.", ref.getReference());
return new ActionReturn(Formats.UTF_8, Formats.HTML_MIME_TYPE, writer.toString()); } catch (IOException ioe) { throw new EntityException("Failed to format profile.", ref.getReference());
private Object myDoubleAction(EntityView view) { MyEntity me = (MyEntity) getEntity(view.getEntityReference()); MyEntity togo = me.copy(); togo.setNumber( togo.getNumber() * 2 ); return new ActionReturn(new EntityData(view.getEntityReference().toString(), togo.getStuff(), togo), (String)null); }
public Object doubleUp(EntityView view) { MyEntity me = (MyEntity) getEntity(view.getEntityReference()); MyEntity togo = me.copy(); togo.setNumber( togo.getNumber() * 2 ); return new ActionReturn(new EntityData(view.getEntityReference().toString(), togo.getStuff(), togo), (String)null); }
public Object doubleCustomAction(EntityView view) { MyEntity me = (MyEntity) getEntity(view.getEntityReference()); MyEntity togo = me.copy(); togo.setNumber( togo.getNumber() * 2 ); return new ActionReturn(new EntityData(view.getEntityReference().toString(), togo.getStuff(), togo), (String)null); }
public Object doubleCustomAction(EntityView view) { MyEntity me = (MyEntity) getEntity(view.getEntityReference()); MyEntity togo = me.copy(); togo.setNumber( togo.getNumber() * 2 ); return new ActionReturn(new EntityData(view.getEntityReference().toString(), togo.getStuff(), togo), (String)null); }
private Object myDoubleAction(EntityView view) { MyEntity me = (MyEntity) getEntity(view.getEntityReference()); MyEntity togo = me.copy(); togo.setNumber( togo.getNumber() * 2 ); return new ActionReturn(new EntityData(view.getEntityReference().toString(), togo.getStuff(), togo), (String)null); }