Entity entity = response.getEntity(); if(entity != null) entity.getContent().close();
/** * Updates the entity with the accumulated arguments, established by the * individual setter methods for each specific entity class. */ @SuppressWarnings("unchecked") public void update() { update(Collections.EMPTY_MAP); }
/** * Returns an array of system capabilities. * * @return An array of capabilities. */ public String[] getCapabilities() { Entity caps = new Entity(this, "authorization/capabilities"); return caps.getStringArray("capabilities"); }
/** * Returns the string array value associated with the specified key, or the * default value if the key does not exist. * * @param key The key to look up. * @param defaultValue The default value. * @return The string array value associated with the specified key. */ String[] getStringArray(String key, String[] defaultValue) { if (toUpdate.containsKey(key)) return getStringArray(key); return getContent().getStringArray(key, defaultValue); }
/** * Updates the entity with the values you previously set using the setter * methods, and any additional specified arguments. The specified arguments * take precedent over the values that were set using the setter methods. * * @param args The arguments to update. */ public void update(Map<String, Object> args) { if (!toUpdate.isEmpty() || !args.isEmpty()) { // Merge cached setters and live args together before updating. Map<String, Object> mergedArgs = new LinkedHashMap<String, Object>(); mergedArgs.putAll(toUpdate); mergedArgs.putAll(args); if (mergedArgs.containsKey("name") && !isNameChangeAllowed()) { throw new IllegalStateException("Cannot set 'name' on an existing entity."); } service.post(actionPath("edit"), mergedArgs); toUpdate.clear(); invalidate(); } }
/** * Disables the entity that is named by this endpoint. This method is * available on almost every endpoint. */ public void disable() { service.post(actionPath("disable")); invalidate(); }
/** * Displays the action path. * * @param action The requested action. * @return The action path. */ @Override protected String actionPath(String action) { if (action.equals("edit")) return path + "/deployment-client"; return super.actionPath(action); }
/** * Indicates whether this entity is disabled. This method is * available on almost every endpoint. * * @return {@code true} if this entity is disabled, {@code false} if * enabled. */ public boolean isDisabled() { return getBoolean("disabled", false); }
/** * Returns the metadata (eai:acl) of this entity. This data includes * permissions for accessing the resource, and values that indicate * which resource fields are wildcards, required, and optional. * * @return The metadata of this entity, or {@code null} if none exist. */ public EntityMetadata getMetadata() { // CONSIDER: For entities that don't have an eai:acl field, which is // uncommon but does happen at least in the case of a DeploymentClient // that is not enabled, we return null. A slightly friendlier option // would be to return a metadata instance that defaults all values? if (!containsKey("eai:acl")) return null; return new EntityMetadata(this); }
/** * Enables the entity that is named by this endpoint. This method is * available on almost every endpoint. */ public void enable() { service.post(actionPath("enable")); invalidate(); }
/** * Returns the action path. * * @param action The requested action. * @return The action path. */ @Override protected String actionPath(String action) { if (action.equals("edit")) return path + "/distributedSearch"; return super.actionPath(action); }
Entity en = ((BasicHttpEntityEnclosingRequest)request).getEntity(); InputStream ins = en.getContent(); //Lets you read from the entity
private final List< Entity > toBeRemoved = new LinkedList<>(); public void update(GameContainer gc, int delta) { toBeRemoved.clear(); for( Entity entity : entities ) { if( entity.update( gc, delta )) { toBeRemoved.add( entity ); } } entities.removeAll( toBeRemoved ); }
/** * Returns the action path. * * @param action The requested action. * @return The action path. */ @Override protected String actionPath(String action) { if (action.equals("control")) return path + "/control"; return super.actionPath(action); }
/** {@inheritDoc} */ public Collection<Object> values() { return getContent().values(); } }
/** * {@inheritDoc} */ @Override public void update() { // If not present in the update keys, add required attribute as long // as one pre-existing update pair exists if (toUpdate.size() > 0 && !toUpdate.containsKey("name")) { setCacheValue("name", "tcpout"); } super.update(); } }
/** {@inheritDoc} */ @Override protected String actionPath(String action) { if (action.equals("acknowledge")) return path + "/acknowledge"; if (action.equals("dispatch")) return path + "/dispatch"; if (action.equals("history")) return path + "/history"; return super.actionPath(action); }
/** * Returns the string value associated with the specified key, or the * default value if the key does not exist. * * @param key The key to look up. * @param defaultValue The default value. * @return The string value associated with the specified key. */ String getString(String key, String defaultValue) { if (toUpdate.containsKey(key)) return toUpdate.get(key).toString(); return getContent().getString(key, defaultValue); }