Search in sources :

Example 1 with RequestCache

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());
}
Also used : ConfigRoot(org.collectionspace.chain.csp.config.ConfigRoot) CSPManager(org.collectionspace.csp.api.container.CSPManager) CSPRequestCache(org.collectionspace.csp.api.core.CSPRequestCache) RequestCache(org.collectionspace.csp.helper.core.RequestCache) Record(org.collectionspace.chain.csp.schema.Record) CSPRequestCredentials(org.collectionspace.csp.api.core.CSPRequestCredentials) Spec(org.collectionspace.chain.csp.schema.Spec) StorageGenerator(org.collectionspace.csp.api.persistence.StorageGenerator)

Example 2 with 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");
}
Also used : CSPRequestCache(org.collectionspace.csp.api.core.CSPRequestCache) RequestCache(org.collectionspace.csp.helper.core.RequestCache) UIRequest(org.collectionspace.csp.api.ui.UIRequest) UnauthorizedException(org.collectionspace.csp.api.persistence.UnauthorizedException) UIException(org.collectionspace.csp.api.ui.UIException) CSPRequestCache(org.collectionspace.csp.api.core.CSPRequestCache) UIException(org.collectionspace.csp.api.ui.UIException) CSPDependencyException(org.collectionspace.csp.api.core.CSPDependencyException) UnauthorizedException(org.collectionspace.csp.api.persistence.UnauthorizedException)

Example 3 with RequestCache

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();
    }
}
Also used : AdminData(org.collectionspace.chain.csp.schema.AdminData) WebReset(org.collectionspace.chain.csp.webui.misc.WebReset) CSPRequestCache(org.collectionspace.csp.api.core.CSPRequestCache) RequestCache(org.collectionspace.csp.helper.core.RequestCache) UIException(org.collectionspace.csp.api.ui.UIException) CSPRequestCredentials(org.collectionspace.csp.api.core.CSPRequestCredentials)

Aggregations

CSPRequestCache (org.collectionspace.csp.api.core.CSPRequestCache)3 RequestCache (org.collectionspace.csp.helper.core.RequestCache)3 CSPRequestCredentials (org.collectionspace.csp.api.core.CSPRequestCredentials)2 UIException (org.collectionspace.csp.api.ui.UIException)2 ConfigRoot (org.collectionspace.chain.csp.config.ConfigRoot)1 AdminData (org.collectionspace.chain.csp.schema.AdminData)1 Record (org.collectionspace.chain.csp.schema.Record)1 Spec (org.collectionspace.chain.csp.schema.Spec)1 WebReset (org.collectionspace.chain.csp.webui.misc.WebReset)1 CSPManager (org.collectionspace.csp.api.container.CSPManager)1 CSPDependencyException (org.collectionspace.csp.api.core.CSPDependencyException)1 StorageGenerator (org.collectionspace.csp.api.persistence.StorageGenerator)1 UnauthorizedException (org.collectionspace.csp.api.persistence.UnauthorizedException)1 UIRequest (org.collectionspace.csp.api.ui.UIRequest)1