use of org.collectionspace.csp.api.persistence.UnimplementedException in project application by collectionspace.
the class DirectRedirector method retrieveJSON.
@Override
public JSONObject retrieveJSON(ContextualisedStorage root, CSPRequestCredentials creds, CSPRequestCache cache, String path, JSONObject restrictions) throws ExistException, UnimplementedException, UnderlyingStorageException {
/* Find relevant controller, and call */
String[] url = path.split("/");
RefName.AuthorityItem itemParsed = RefName.AuthorityItem.parse(url[2]);
String thisShortid = itemParsed.getShortIdentifier();
String thisparent = itemParsed.getParentShortIdentifier();
String displayName = itemParsed.displayName;
String test = itemParsed.inAuthority.resource;
String vocab = RefName.shortIdToPath(thisparent);
String csid = RefName.shortIdToPath(thisShortid);
Record r = spec.getRecordByServicesUrl(itemParsed.inAuthority.resource);
String storageID = r.getID();
if (r.isType("vocabulary")) {
url[0] = r.getServicesURL();
storageID = "vocab";
}
if (!r.isType("authority") && !r.isType("vocabulary"))
throw new UnimplementedException("Only authorities and vocabularies supported at direct at the moment");
return root.retrieveJSON(root, creds, cache, storageID + "/_direct/" + url[0] + "/" + vocab + "/" + csid, restrictions);
}
use of org.collectionspace.csp.api.persistence.UnimplementedException in project application by collectionspace.
the class DataGenerator method createAllRecords.
/**
* Create all record types (that make sense)
* @param storage
* @param ui
* @return
* @throws UIException
*/
protected JSONObject createAllRecords(Storage storage, UIRequest ui) throws UIException {
log.info("Lets make some records");
tty.line("Lets make some records");
tty.flush();
JSONObject returnData = new JSONObject();
try {
for (Record r : spec.getAllRecords()) {
if (r.isType("authority") || r.isType("authorizationdata") || r.isType("id") || r.isType("userdata")) {
// don't do these yet (if ever)
} else if (r.getID().equals("structureddate") || r.getID().equals("media") || r.getID().equals("hierarchy") || r.getID().equals("blobs") || r.getID().equals("dimension") || r.getID().equals("contacts") || r.isType("searchall")) {
// and ignore these
} else if (r.getID().equals("termlist") || r.getID().equals("termlistitem")) {
// and ignore these
} else {
this.record = r;
this.structureview = "screen";
this.writer = new RecordCreateUpdate(r, true);
JSONObject items = createRecords(storage, ui);
returnData.put(r.getID(), items.getJSONObject(r.getID()));
}
}
// lets create some relationships
log.info("Initializing relationships");
tty.line("Initializing relationships");
tty.flush();
createDataSetRelationships(returnData);
} catch (JSONException x) {
throw new UIException("Failed to parse json: ", x);
} catch (ExistException x) {
throw new UIException("Existence exception: ", x);
} catch (UnimplementedException x) {
throw new UIException("Unimplemented exception: ", x);
} catch (UnderlyingStorageException x) {
throw new UIException("Problem storing: " + x.getLocalizedMessage(), x.getStatus(), x.getUrl(), x);
}
return returnData;
}
use of org.collectionspace.csp.api.persistence.UnimplementedException in project application by collectionspace.
the class DataGenerator method createRecords.
/**
* generate records of a specific type
* @param storage
* @param ui
* @return
* @throws UIException
*/
protected JSONObject createRecords(Storage storage, UIRequest ui) throws UIException {
log.info("Making " + this.record.getID());
tty.line("Making " + this.record.getID());
tty.flush();
JSONObject returnData = new JSONObject();
JSONObject out = datagenerator(storage, ui);
try {
// make it a record
JSONObject data = new JSONObject();
Iterator rit = out.keys();
JSONObject dataitems = new JSONObject();
while (rit.hasNext()) {
String key = (String) rit.next();
data.put("fields", out.getJSONObject(key));
String path = writer.sendJSON(storage, null, data, null);
dataitems.put(key, path);
// log.info(path);
log.info("created " + this.record.getID() + " with csid of: " + path);
tty.line("created " + this.record.getID() + " with csid of: " + path);
tty.flush();
}
returnData.put(this.record.getID(), dataitems);
} catch (JSONException x) {
tty.line("JSONException(Failed to parse json: " + x);
log.info("JSONException(Failed to parse json: " + x);
throw new UIException("Failed to parse json: " + x, x);
} catch (ExistException x) {
log.info("ExistException(Existence exception: " + x);
tty.line("ExistException(Existence exception: " + x);
throw new UIException("Existence exception: " + x, x);
} catch (UnimplementedException x) {
tty.line("UnimplementedException(UnimplementedException: " + x);
log.info("UnimplementedException(UnimplementedException: " + x);
throw new UIException("Unimplemented exception: " + x, x);
} catch (UnderlyingStorageException x) {
tty.line("UnderlyingStorageException(UnderlyingStorageException: " + x);
log.info("UnderlyingStorageException(UnderlyingStorageException: " + x);
throw new UIException("Problem storing: " + x.getLocalizedMessage(), x.getStatus(), x.getUrl(), x);
}
// return something to screen
return returnData;
}
use of org.collectionspace.csp.api.persistence.UnimplementedException in project application by collectionspace.
the class TestAccount method testAccountSearch.
// XXX this test needs work
// @Test
public void testAccountSearch() {
Storage ss;
try {
ss = makeServicesStorage();
/*
* arggg how do I get it to do an exact match */
JSONObject data = ss.getPathsJSON("users/", new JSONObject("{\"email\":\"bob@indigo-e.co.uk\"}"));
String[] paths = (String[]) data.get("listItems");
if (paths.length >= 1) {
for (int i = 0; i < paths.length; i++) {
// log.info(paths[i] +" : "+ i +" of "+ paths.length);
}
}
} catch (CSPDependencyException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ExistException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnimplementedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnderlyingStorageException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of org.collectionspace.csp.api.persistence.UnimplementedException in project application by collectionspace.
the class TestPermissions method createRole.
private JSONObject createRole(String jsonFile) {
Storage ss;
try {
// delete this role if exist
JSONObject u1 = getJSON(jsonFile);
String roleName = u1.getString("roleName");
JSONObject test = new JSONObject();
test.put("keywords", roleName);
ss = makeServicesStorage();
/* delete role if already exists */
JSONObject data = ss.getPathsJSON("role/", test);
String[] paths = (String[]) data.get("listItems");
log.info(data.toString());
if (paths.length > 0) {
ss.deleteJSON("role/" + paths[0]);
}
// create role
String path = ss.autocreateJSON("role/", u1, null);
assertNotNull(path);
JSONObject u3 = ss.retrieveJSON("role/" + path, new JSONObject());
assertNotNull(u3);
// return role path
JSONObject roledata = new JSONObject();
roledata.put("roleName", roleName);
roledata.put("roleId", path);
return roledata;
} catch (CSPDependencyException e) {
fail("CSPDependencyException:" + e.getMessage());
} catch (JSONException e) {
fail("JSONException:" + e.getMessage());
} catch (ExistException e) {
fail("ExistException:" + e.getMessage());
} catch (UnimplementedException e) {
fail("UnimplementedException:" + e.getMessage());
} catch (UnderlyingStorageException e) {
fail("UnderlyingStorageException:" + e.getMessage());
} catch (IOException e) {
fail("IOException:" + e.getMessage());
}
return null;
}
Aggregations