Search in sources :

Example 1 with ServicesConnection

use of org.collectionspace.chain.csp.persistence.services.connection.ServicesConnection in project application by collectionspace.

the class ServicesStorageGenerator method real_init.

private void real_init(CSPManager cspManager, Spec spec, boolean forXsdGeneration) throws CSPDependencyException {
    try {
        ServicesConnection conn = new ServicesConnection(base_url, ims_url);
        for (Record r : spec.getAllRecords()) {
            if (r.isType("blob") || r.isType("report") || r.isType("batch"))
                addChild(r.getID(), new BlobStorage(spec.getRecord(r.getID()), conn));
            else if (r.isType("userdata"))
                addChild(r.getID(), new UserStorage(spec.getRecord(r.getID()), conn));
            else if (r.isType("record") || r.isType("searchall"))
                addChild(r.getID(), new RecordStorage(spec.getRecord(r.getID()), conn));
            else if (r.isType("authority"))
                addChild(r.getID(), new ConfiguredVocabStorage(spec.getRecord(r.getID()), conn));
            else if (r.isType("authorizationdata"))
                addChild(r.getID(), new AuthorizationStorage(spec.getRecord(r.getID()), conn));
        }
        addChild("direct", new DirectRedirector(spec));
        addChild("id", new ServicesIDGenerator(conn, spec));
        addChild("relations", new ServicesRelationStorage(conn, spec));
        // 
        if (forXsdGeneration == false) {
            initializeAuthorities(cspManager, spec);
        }
    } catch (Exception e) {
        e.printStackTrace();
        // XXX wrong type
        throw new CSPDependencyException("Could not set target", e);
    }
}
Also used : AuthorizationStorage(org.collectionspace.chain.csp.persistence.services.authorization.AuthorizationStorage) CSPDependencyException(org.collectionspace.csp.api.core.CSPDependencyException) ServicesConnection(org.collectionspace.chain.csp.persistence.services.connection.ServicesConnection) Record(org.collectionspace.chain.csp.schema.Record) ConfiguredVocabStorage(org.collectionspace.chain.csp.persistence.services.vocab.ConfiguredVocabStorage) UserStorage(org.collectionspace.chain.csp.persistence.services.user.UserStorage) ServicesRelationStorage(org.collectionspace.chain.csp.persistence.services.relation.ServicesRelationStorage) UIException(org.collectionspace.csp.api.ui.UIException) CSPDependencyException(org.collectionspace.csp.api.core.CSPDependencyException)

Example 2 with ServicesConnection

use of org.collectionspace.chain.csp.persistence.services.connection.ServicesConnection 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);
}
Also used : CSPDependencyException(org.collectionspace.csp.api.core.CSPDependencyException) ServicesConnection(org.collectionspace.chain.csp.persistence.services.connection.ServicesConnection) Spec(org.collectionspace.chain.csp.schema.Spec) ReturnedDocument(org.collectionspace.chain.csp.persistence.services.connection.ReturnedDocument)

Aggregations

ServicesConnection (org.collectionspace.chain.csp.persistence.services.connection.ServicesConnection)2 CSPDependencyException (org.collectionspace.csp.api.core.CSPDependencyException)2 AuthorizationStorage (org.collectionspace.chain.csp.persistence.services.authorization.AuthorizationStorage)1 ReturnedDocument (org.collectionspace.chain.csp.persistence.services.connection.ReturnedDocument)1 ServicesRelationStorage (org.collectionspace.chain.csp.persistence.services.relation.ServicesRelationStorage)1 UserStorage (org.collectionspace.chain.csp.persistence.services.user.UserStorage)1 ConfiguredVocabStorage (org.collectionspace.chain.csp.persistence.services.vocab.ConfiguredVocabStorage)1 Record (org.collectionspace.chain.csp.schema.Record)1 Spec (org.collectionspace.chain.csp.schema.Spec)1 UIException (org.collectionspace.csp.api.ui.UIException)1