/** * * @param name the name of REST resource to enable * @param enable the new enable value * @return true if the resource enable flag has been changed, false otherwise */ public boolean enableResource(String name, boolean enable) { for (Resource resource: resources) { if (name.equals(resource.getName())) { return resource.setEnabled(enable); } } return false; }
/** * {@inheritDoc} */ @Override public String toString() { return "Resource [name=" + name + ", version=" + getVersion() + ", path=" + path + ", description=" + description + ", created at=" + getCreatedAt() + ", by=" + getCreatedBy() + ", module=" + module + ", enabled=" + enabled + "]"; }
@Override public void write(ObjectDataOutput out, Resource xResource) throws IOException { super.writeEntity(out, xResource); out.writeUTF(xResource.getName()); out.writeUTF(xResource.getPath()); out.writeUTF(xResource.getDescription()); out.writeUTF(xResource.getModule()); out.writeBoolean(xResource.isEnabled()); }
private boolean buildSchemaConfig(ResourceConfig config, String schemaName) { Schema schema = rePro.getSchema(schemaName); // get schema -> resources int cnt = 0; for (com.bagri.core.system.Resource res: schema.getResources()) { // for each resource -> get module if (res.isEnabled()) { Module module = rePro.getModule(res.getModule()); try { buildDynamicResources(config, res.getPath(), module); cnt++; } catch (Exception ex) { logger.error("buildSchemaConfig; error processing module: " + res.getModule(), ex); // skip it.. } } } return cnt > 0; }
Resource addResource(String name, String path, String module, String description) { Resource resource = new Resource(1, new Date(), getCurrentUser(), name, path, description, module, true); Schema schema = getEntity(); if (schema.addResource(resource)) { // store schema! flushEntity(schema); return resource; } return null; }
/** * * @param name the name of the resource to search for * @return the REST resource instance if it is found, null otherwise */ public Resource getResource(String name) { for (Resource resource: resources) { if (name.equals(resource.getName())) { return resource; } } return null; }
@Override public Resource read(ObjectDataInput in) throws IOException { Object[] entity = super.readEntity(in); Resource xResource = new Resource( (int) entity[0], (Date) entity[1], (String) entity[2], in.readUTF(), in.readUTF(), in.readUTF(), in.readUTF(), in.readBoolean()); return xResource; }
/** * * @param name the name of the resource to remove from schema * @return true if resource has been removed, false otherwise */ public Resource removeResource(String name) { for (Resource resource: resources) { if (name.equals(resource.getName())) { if (triggers.remove(resource)) { return resource; } break; } } return null; }