use of org.collectionspace.csp.api.core.CSPDependencyException in project application by collectionspace.
the class ServicesBaseClass method setup.
protected void setup() throws ConnectionException {
Spec spec = null;
String ims_base = "";
try {
base = getBaseUrl();
ims_base = getIMSBaseUrl();
spec = getDefaultSpec();
} catch (CSPDependencyException e) {
assertNotNull("Base service url invalid in config file", base);
}
// XXX still yuck but centralised now
log.info("ServicesBaseClass setting up connection using base URL:" + base);
conn = new ServicesConnection(base, ims_base);
creds = new ServicesRequestCredentials();
creds.setCredential(ServicesStorageGenerator.CRED_USERID, spec.getAdminData().getAuthUser());
creds.setCredential(ServicesStorageGenerator.CRED_PASSWORD, spec.getAdminData().getAuthPass());
ReturnedDocument out = conn.getXMLDocument(RequestMethod.GET, "accounts/0/accountperms", null, creds, cache);
Assume.assumeTrue(out.getStatus() == 200);
}
use of org.collectionspace.csp.api.core.CSPDependencyException 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.core.CSPDependencyException in project application by collectionspace.
the class TestDummyData method testDataCreation.
@Test
public void testDataCreation() {
Storage ss;
try {
ss = makeServicesStorage();
// create objects/procedures/
String objectUrl = create("collectionobjects/", "collectionobjects_common", "dummydata-object1.xml", "collection-object");
String acquisitionUrl = create("acquisitions/", "acquisitions_common", "dummydata-acquisition.xml", "acquisition");
String intakeUrl = create("intakes/", "intakes_common", "dummydata-intake.xml", "intake");
String loaninUrl = create("loansin/", "loansin_common", "dummydata-loanin.xml", "loanin");
String loanoutUrl = create("loansout/", "loansout_common", "dummydata-loanout.xml", "loanout");
String objectexitUrl = create("objectexit/", "objectexit_common", "dummydata-objectexit.xml", "objectexit");
// String groupUrl = create("group/", "group_common", "dummydata-group.xml","group");
// make relationships
relate2way(ss, objectUrl, acquisitionUrl);
relate2way(ss, objectUrl, intakeUrl);
relate2way(ss, objectUrl, loaninUrl);
relate2way(ss, objectUrl, loanoutUrl);
relate2way(ss, objectUrl, objectexitUrl);
testRelations(ss, objectUrl, acquisitionUrl, "affects");
testRelations(ss, objectUrl, intakeUrl, "affects");
testRelations(ss, objectUrl, loaninUrl, "affects");
testRelations(ss, objectUrl, loanoutUrl, "affects");
testRelations(ss, objectUrl, objectexitUrl, "affects");
// testRelations(ss,objectUrl,groupUrl,"affects");
} catch (CSPDependencyException e) {
fail(e.getMessage());
} catch (Exception e) {
fail(e.getMessage());
}
}
use of org.collectionspace.csp.api.core.CSPDependencyException 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;
}
use of org.collectionspace.csp.api.core.CSPDependencyException in project application by collectionspace.
the class TestPermissions method createUser.
private JSONObject createUser(String jsonFile) {
Storage ss;
try {
JSONObject u1 = getJSON(jsonFile);
String screenName = u1.getString("screenName");
String userId = u1.getString("userId");
JSONObject test = new JSONObject();
test.put("userId", userId);
ss = makeServicesStorage();
/* delete user if already exists */
JSONObject data = ss.getPathsJSON("users/", test);
String[] paths = (String[]) data.get("listItems");
if (paths.length > 0)
ss.deleteJSON("users/" + paths[0]);
/* create the user based on json */
/* will give a hidden 500 error if userid is not unique (useful eh?) */
String path = ss.autocreateJSON("users/", u1, null);
assertNotNull(path);
JSONObject u2 = getJSON(jsonFile);
ss.updateJSON("users/" + path, u2, new JSONObject());
JSONObject u3 = ss.retrieveJSON("users/" + path, new JSONObject());
assertNotNull(u3);
JSONObject userdata = new JSONObject();
userdata.put("screenName", screenName);
// csid
userdata.put("accountId", path);
// really email
userdata.put("userId", userId);
return userdata;
} 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