Search in sources :

Example 1 with CSPManagerImpl

use of org.collectionspace.csp.container.impl.CSPManagerImpl in project application by collectionspace.

the class TenantServlet method register_csps.

/* Not in the constructor because errors during construction of servlets tend to get lost in a mess of startup.
	 * Better present it on first request.
	 */
protected void register_csps(String tenantId) throws IOException, DocumentException {
    if (!tenantCSPM.containsKey(tenantId)) {
        tenantCSPM.put(tenantId, new CSPManagerImpl());
    }
    tenantCSPM.get(tenantId).register(new CoreConfig());
    tenantCSPM.get(tenantId).register(new FileStorage());
    tenantCSPM.get(tenantId).register(new ServicesStorageGenerator());
    tenantCSPM.get(tenantId).register(new WebUI());
    tenantCSPM.get(tenantId).register(new Spec());
}
Also used : ServicesStorageGenerator(org.collectionspace.chain.csp.persistence.services.ServicesStorageGenerator) WebUI(org.collectionspace.chain.csp.webui.main.WebUI) CoreConfig(org.collectionspace.chain.csp.inner.CoreConfig) FileStorage(org.collectionspace.chain.csp.persistence.file.FileStorage) CSPManagerImpl(org.collectionspace.csp.container.impl.CSPManagerImpl) Spec(org.collectionspace.chain.csp.schema.Spec)

Example 2 with CSPManagerImpl

use of org.collectionspace.csp.container.impl.CSPManagerImpl in project application by collectionspace.

the class ServicesBaseClass method getServiceManager.

private CSPManager getServiceManager() throws CSPDependencyException {
    CSPManager cspm = new CSPManagerImpl();
    cspm.register(new CoreConfig());
    cspm.register(new Spec());
    cspm.register(new ServicesStorageGenerator());
    cspm.go();
    cspm.configure(getRootSource(), new ConfigFinder(null), false);
    return cspm;
}
Also used : CSPManager(org.collectionspace.csp.api.container.CSPManager) CoreConfig(org.collectionspace.chain.csp.inner.CoreConfig) CSPManagerImpl(org.collectionspace.csp.container.impl.CSPManagerImpl) Spec(org.collectionspace.chain.csp.schema.Spec) ConfigFinder(org.collectionspace.csp.helper.core.ConfigFinder) TestConfigFinder(org.collectionspace.csp.helper.test.TestConfigFinder)

Example 3 with CSPManagerImpl

use of org.collectionspace.csp.container.impl.CSPManagerImpl in project application by collectionspace.

the class TestService method testXMLJSONConversion.

@Test
public void testXMLJSONConversion() throws Exception {
    CSPManager cspm = new CSPManagerImpl();
    cspm.register(new CoreConfig());
    cspm.register(new Spec());
    cspm.register(new ServicesStorageGenerator());
    cspm.go();
    // argh - test break when config changes *sob*
    cspm.configure(getRootSource(), new ConfigFinder(null), false);
    ConfigRoot root = cspm.getConfigRoot();
    Spec spec = (Spec) root.getRoot(Spec.SPEC_ROOT);
    testXMLJSON(spec, "location", "location.xml", "location.json");
    testXMLJSON(spec, "concept", "concept.xml", "concept.json");
    testXMLJSON(spec, "place", "placeXMLJSON.xml", "placeJSON.json");
    testXMLJSON(spec, "citation", "citation.xml", "citation.json");
    testXMLJSON(spec, "work", "work.xml", "work.json");
    testXMLJSON(spec, "collection-object", "objectsXMLJSON.xml", "objectsJSON.json");
    testXMLJSON(spec, "acquisition", "acquisitionXMLJSON.xml", "acquisitionJSON.json");
    testXMLJSON(spec, "intake", "intake.xml", "intake.json");
    testXMLJSON(spec, "loanin", "loanin.xml", "loanin.json");
    testXMLJSON(spec, "loanout", "loanout.xml", "loanout.json");
    testXMLJSON(spec, "valuationcontrol", "valuationcontrol.xml", "valuationcontrol.json");
    testXMLJSON(spec, "movement", "movement.xml", "movement.json");
    testXMLJSON(spec, "objectexit", "objectexit.xml", "objectexit.json");
    testXMLJSON(spec, "group", "group.xml", "group.json");
    testXMLJSON(spec, "media", "media.xml", "mediaJSON.json");
    testXMLJSON(spec, "conditioncheck", "conditioncheck.xml", "conditioncheck.json");
    testXMLJSON(spec, "conservation", "conservation.xml", "conservation.json");
    testXMLJSON(spec, "exhibition", "exhibition.xml", "exhibition.json");
    testXMLJSON(spec, "role", "role.xml", "role.json");
    testXMLJSON(spec, "permrole", "rolepermissions.xml", "rolepermissions.json");
    testXMLJSON(spec, "userrole", "accountrole.xml", "accountrole.json");
// testXMLJSON(spec,
// "permission","permissionXMLJSON.xml","permissionsJSON.json");
// testXMLJSON(spec,
// "organization","orgauthref.xml","permissionsJSON.json");
}
Also used : ConfigRoot(org.collectionspace.chain.csp.config.ConfigRoot) CSPManager(org.collectionspace.csp.api.container.CSPManager) CoreConfig(org.collectionspace.chain.csp.inner.CoreConfig) CSPManagerImpl(org.collectionspace.csp.container.impl.CSPManagerImpl) Spec(org.collectionspace.chain.csp.schema.Spec) ConfigFinder(org.collectionspace.csp.helper.core.ConfigFinder) Test(org.junit.Test)

Example 4 with CSPManagerImpl

use of org.collectionspace.csp.container.impl.CSPManagerImpl in project application by collectionspace.

the class ServiceConfigGeneration method getServiceManager.

private CSPManager getServiceManager(File configFile) throws Exception {
    CSPManager result = null;
    CSPManager cspm = new CSPManagerImpl();
    cspm.register(new CoreConfig());
    cspm.register(new Spec());
    cspm.register(new ServicesStorageGenerator());
    // Do more initialization of our CSPManagerImpl instance (i.e., cspm)
    cspm.go();
    File configBase = configFile.getParentFile();
    // Saves a copy of the base config directory
    cspm.setConfigBase(configBase);
    cspm.configure(getSource(configFile), new ConfigFinder(null, configBase), true);
    this.setConfigBase(configBase);
    this.setConfigFile(configFile);
    result = cspm;
    return result;
}
Also used : ServicesStorageGenerator(org.collectionspace.chain.csp.persistence.services.ServicesStorageGenerator) CSPManager(org.collectionspace.csp.api.container.CSPManager) CoreConfig(org.collectionspace.chain.csp.inner.CoreConfig) CSPManagerImpl(org.collectionspace.csp.container.impl.CSPManagerImpl) TenantSpec(org.collectionspace.chain.csp.persistence.services.TenantSpec) Spec(org.collectionspace.chain.csp.schema.Spec) File(java.io.File) ConfigFinder(org.collectionspace.csp.helper.core.ConfigFinder) TestConfigFinder(org.collectionspace.csp.helper.test.TestConfigFinder)

Example 5 with CSPManagerImpl

use of org.collectionspace.csp.container.impl.CSPManagerImpl in project application by collectionspace.

the class TestSchema method testSchema.

@Test
public void testSchema() {
    CSPManager cspm = new CSPManagerImpl();
    cspm.register(new CoreConfig());
    cspm.register(new Spec());
    try {
        cspm.go();
        // finds "src/main/resources/default.xml" when running tests
        InputSource configsource = getSource("config.xml");
        // pieces together the set of config/settings files for parsing
        cspm.configure(configsource, new ConfigFinder(null), false);
    } catch (CSPDependencyException e) {
        log.error("CSPManagerImpl failed");
        log.error(e.getLocalizedMessage());
    }
    ConfigRoot root = cspm.getConfigRoot();
    Spec spec = (Spec) root.getRoot(Spec.SPEC_ROOT);
    assertNotNull(spec);
    // spec.dump()
    Record r_obj = spec.getRecord("collection-object");
    if (log.isTraceEnabled()) {
        try {
            String recordDump = r_obj.dumpFields();
            log.trace(recordDump);
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            log.trace("JSONException encountered trying to log debugging information", e);
        }
    }
    assertNotNull(r_obj);
    assertEquals("collection-object", r_obj.getID());
    assertEquals("cataloging", r_obj.getWebURL());
    StringBuffer dumpBuffer = new StringBuffer(1000);
    r_obj.dump(dumpBuffer);
    System.out.println(dumpBuffer.toString());
    // log.info(spec.dump());
    JSONObject out = new JSONObject();
    Boolean ignore = false;
    String t = "";
    for (Record r : spec.getAllRecords()) {
        // log.info(r.getID());
        if (r.getID().equals("termlist")) {
            ignore = true;
        }
        if (!ignore) {
            try {
                t = spec.getRecord(r.getID()).dumpFields();
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        // log.info(t.toString());
        }
    }
/* RECORD/field -> FIELD(type) */
/*
		rules.addRule("record",new String[]{"field"},"field",new SectionGenerator() {
			public void step(Section milestone,Map<String, String> data) {
				milestone.addValue("field.type",milestone.getParent().getValue("/record/type"));
			}
		},new Target(){
			public Object populate(Object parent, ReadOnlySection milestone) {
				Field f=new Field();
				f.type=(String)milestone.getValue("field.type");
				((Record)parent).fields.add(f);
				return f;
			}
		});
			
		// MAIN/persistence/service -> URL(url)
		rules.addRule("main",new String[]{"persistence","service"},"url",new SectionGenerator() {
			public void step(Section milestone,Map<String, String> data) {
				milestone.addValue("service.url",data.get("/service/url"));
			}
		},null);
		*/
}
Also used : InputSource(org.xml.sax.InputSource) ConfigRoot(org.collectionspace.chain.csp.config.ConfigRoot) CSPManager(org.collectionspace.csp.api.container.CSPManager) CoreConfig(org.collectionspace.chain.csp.inner.CoreConfig) JSONException(org.json.JSONException) CSPManagerImpl(org.collectionspace.csp.container.impl.CSPManagerImpl) ConfigFinder(org.collectionspace.csp.helper.core.ConfigFinder) TestConfigFinder(org.collectionspace.csp.helper.test.TestConfigFinder) JSONObject(org.json.JSONObject) CSPDependencyException(org.collectionspace.csp.api.core.CSPDependencyException) Test(org.junit.Test)

Aggregations

CSPManagerImpl (org.collectionspace.csp.container.impl.CSPManagerImpl)9 CoreConfig (org.collectionspace.chain.csp.inner.CoreConfig)8 Spec (org.collectionspace.chain.csp.schema.Spec)8 ConfigFinder (org.collectionspace.csp.helper.core.ConfigFinder)8 CSPManager (org.collectionspace.csp.api.container.CSPManager)7 ConfigRoot (org.collectionspace.chain.csp.config.ConfigRoot)5 TestConfigFinder (org.collectionspace.csp.helper.test.TestConfigFinder)5 ServicesStorageGenerator (org.collectionspace.chain.csp.persistence.services.ServicesStorageGenerator)3 CSPDependencyException (org.collectionspace.csp.api.core.CSPDependencyException)3 Test (org.junit.Test)3 TenantSpec (org.collectionspace.chain.csp.persistence.services.TenantSpec)2 WebUI (org.collectionspace.chain.csp.webui.main.WebUI)2 InputSource (org.xml.sax.InputSource)2 File (java.io.File)1 FileStorage (org.collectionspace.chain.csp.persistence.file.FileStorage)1 UI (org.collectionspace.csp.api.ui.UI)1 UIException (org.collectionspace.csp.api.ui.UIException)1 JSONException (org.json.JSONException)1 JSONObject (org.json.JSONObject)1 SAXException (org.xml.sax.SAXException)1