示例#1
0
 /**
  * Returns a JSON object containing only the specified fields from the provided resource. If the
  * list of fields is empty then the resource is returned unchanged.
  *
  * <p><b>NOTE:</b> this method only performs a shallow copy of extracted fields, so changes to the
  * filtered resource may impact the original resource, and vice-versa.
  *
  * @param resource The resource whose fields are to be filtered.
  * @param fields The list of fields to be extracted.
  * @return The filtered resource.
  */
 public static Resource filterResource(
     final Resource resource, final Collection<JsonPointer> fields) {
   final JsonValue unfiltered = resource.getContent();
   final JsonValue filtered = filterResource(unfiltered, fields);
   if (filtered == unfiltered) {
     return resource; // Unchanged.
   } else {
     return new Resource(resource.getId(), resource.getRevision(), filtered);
   }
 }
示例#2
0
文件: Link.java 项目: koberj/OpenIDM
 /**
  * TODO: Description.
  *
  * @throws SynchronizationException TODO.
  */
 void create() throws SynchronizationException {
   _id = UUID.randomUUID().toString(); // client-assigned identifier
   JsonValue jv = toJsonValue();
   try {
     CreateRequest r = Requests.newCreateRequest(linkId(null), _id, jv);
     Resource resource =
         mapping
             .getService()
             .getConnectionFactory()
             .getConnection()
             .create(mapping.getService().getServerContext(), r);
     this._id = resource.getId();
     this._rev = resource.getRevision();
     this.initialized = true;
   } catch (ResourceException ose) {
     LOGGER.debug("Failed to create link", ose);
     throw new SynchronizationException(ose);
   }
 }