use of org.collectionspace.csp.helper.core.RequestCache in project application by collectionspace.
the class ServicesBaseClass method makeServicesStorage.
protected Storage makeServicesStorage() throws CSPDependencyException {
CSPManager cspm = getServiceManager();
ConfigRoot root = cspm.getConfigRoot();
Spec spec = (Spec) root.getRoot(Spec.SPEC_ROOT);
assertNotNull(spec);
// XXX this is spec specific testing that will break when we rename the object in the UI
Record r_obj = spec.getRecord("collection-object");
assertNotNull(r_obj);
assertEquals("collection-object", r_obj.getID());
assertEquals("cataloging", r_obj.getWebURL());
StorageGenerator gen = cspm.getStorage("service");
CSPRequestCredentials creds = gen.createCredentials();
creds.setCredential(ServicesStorageGenerator.CRED_USERID, spec.getAdminData().getAuthUser());
creds.setCredential(ServicesStorageGenerator.CRED_PASSWORD, spec.getAdminData().getAuthPass());
return gen.getStorage(creds, new RequestCache());
}
use of org.collectionspace.csp.helper.core.RequestCache in project application by collectionspace.
the class WebUI method serviceRequest.
@Override
public void serviceRequest(UIRequest ui) throws UIException, UnauthorizedException {
CSPRequestCache cache = new RequestCache();
String[] path = ui.getPrincipalPath();
Request r = new Request(xxx_storage, cache, ui);
String test = ui.getRequestedOperation().toString();
log.debug("ServiceRequest path: " + StringUtils.join(path, "/"));
log.debug(test);
try {
if (tries.get(ui.getRequestedOperation()).call(path, r))
return;
} catch (UIException e) {
throw e;
} catch (UnauthorizedException ue) {
throw ue;
} catch (Exception e) {
log.error("Error in WebUI.serviceRequest", e);
log.error(String.format("Request body= %s", ui.getBody()));
throw new UIException("Error in read", e);
}
throw new UIException("path not used");
}
use of org.collectionspace.csp.helper.core.RequestCache in project application by collectionspace.
the class ServicesStorageGenerator method initializeAuthorities.
private void initializeAuthorities(CSPManager cspManager, Spec spec) {
AdminData ad = spec.getAdminData();
String adminUsername = ad.getAuthUser();
String adminPass = ad.getAuthPass();
// request.getSession().setValue(UISession.USERID,ad.getAuthUser());
// request.getSession().setValue(UISession.PASSWORD,ad.getAuthPass());
CSPRequestCredentials creds = this.createCredentials();
creds.setCredential(CRED_USERID, spec.getAdminData().getAuthUser());
creds.setCredential(CRED_PASSWORD, spec.getAdminData().getAuthPass());
WebReset webReset = new WebReset(false, false);
webReset.configure((WebUI) cspManager.getUI(""), spec);
try {
webReset.run(getStorage(creds, new RequestCache()), null, new String[0], false);
} catch (UIException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Aggregations