use of org.sagebionetworks.schema.adapter.org.json.JSONObjectAdapterImpl in project Synapse-Repository-Services by Sage-Bionetworks.
the class Synapse method search.
public SearchResults search(SearchQuery searchQuery) throws SynapseException, UnsupportedEncodingException, JSONObjectAdapterException {
SearchResults searchResults = null;
String uri = "/search";
String jsonBody = EntityFactory.createJSONStringForEntity(searchQuery);
JSONObject obj = signAndDispatchSynapseRequest(repoEndpoint, uri, "POST", jsonBody, defaultPOSTPUTHeaders);
if (obj != null) {
JSONObjectAdapter adapter = new JSONObjectAdapterImpl(obj);
searchResults = new SearchResults(adapter);
}
return searchResults;
}
use of org.sagebionetworks.schema.adapter.org.json.JSONObjectAdapterImpl in project Synapse-Repository-Services by Sage-Bionetworks.
the class Synapse method getEntityTypeBatch.
public BatchResults<EntityHeader> getEntityTypeBatch(List<String> entityIds) throws SynapseException {
// TODO move UrlHelpers someplace shared so that we can UrlHelpers.ENTITY_TYPE
String url = ENTITY_URI_PATH + "/type";
url += "?" + ServiceConstants.BATCH_PARAM + "=" + StringUtils.join(entityIds, ServiceConstants.BATCH_PARAM_VALUE_SEPARATOR);
JSONObject jsonObj = getEntity(url);
JSONObjectAdapter adapter = new JSONObjectAdapterImpl(jsonObj);
BatchResults<EntityHeader> results = new BatchResults<EntityHeader>(EntityHeader.class);
try {
results.initializeFromJSONObject(adapter);
return results;
} catch (JSONObjectAdapterException e) {
throw new RuntimeException(e);
}
}
use of org.sagebionetworks.schema.adapter.org.json.JSONObjectAdapterImpl in project Synapse-Repository-Services by Sage-Bionetworks.
the class Synapse method getUsersEntityPermissions.
/**
* Get the current user's permission for a given entity.
* @param entityId
* @return
* @throws SynapseException
*/
public UserEntityPermissions getUsersEntityPermissions(String entityId) throws SynapseException {
String url = ENTITY_URI_PATH + "/" + entityId + "/permissions";
JSONObject jsonObj = getEntity(url);
JSONObjectAdapter adapter = new JSONObjectAdapterImpl(jsonObj);
UserEntityPermissions uep = new UserEntityPermissions();
try {
uep.initializeFromJSONObject(adapter);
return uep;
} catch (JSONObjectAdapterException e) {
throw new SynapseException(e);
}
}
use of org.sagebionetworks.schema.adapter.org.json.JSONObjectAdapterImpl in project Synapse-Repository-Services by Sage-Bionetworks.
the class Synapse method getEntityPath.
/**
* Get the hierarchical path to this entity via its id and urlPrefix
* @param entityId
* @param urlPrefix
* @return
* @throws SynapseException
*/
public EntityPath getEntityPath(String entityId) throws SynapseException {
String url = ENTITY_URI_PATH + "/" + entityId + "/path";
JSONObject jsonObj = getEntity(url);
JSONObjectAdapter adapter = new JSONObjectAdapterImpl(jsonObj);
EntityPath path = new EntityPath();
try {
path.initializeFromJSONObject(adapter);
return path;
} catch (JSONObjectAdapterException e) {
throw new RuntimeException(e);
}
}
use of org.sagebionetworks.schema.adapter.org.json.JSONObjectAdapterImpl in project Synapse-Repository-Services by Sage-Bionetworks.
the class Synapse method getEntityReferencedBy.
/**
* Get the hierarchical path to this entity via its id and urlPrefix
* @param entityId
* @param urlPrefix
* @return
* @throws SynapseException
*/
public PaginatedResults<EntityHeader> getEntityReferencedBy(String entityId, String targetVersion) throws SynapseException {
String url = ENTITY_URI_PATH + "/" + entityId;
if (targetVersion != null) {
url += "/version/" + targetVersion;
}
url += "/referencedby";
JSONObject jsonObj = getEntity(url);
JSONObjectAdapter adapter = new JSONObjectAdapterImpl(jsonObj);
PaginatedResults<EntityHeader> results = new PaginatedResults<EntityHeader>(EntityHeader.class);
try {
results.initializeFromJSONObject(adapter);
return results;
} catch (JSONObjectAdapterException e) {
throw new RuntimeException(e);
}
}
Aggregations