use of org.collectionspace.csp.api.core.CSPDependencyException in project application by collectionspace.
the class ServicesStorageGenerator method complete_init.
@Override
public void complete_init(CSPManager cspManager, boolean forXsdGeneration) throws CSPDependencyException {
Spec spec = (Spec) ctx.getConfigRoot().getRoot(Spec.SPEC_ROOT);
if (spec == null) {
throw new CSPDependencyException("Could not load spec");
}
real_init(cspManager, spec, forXsdGeneration);
}
use of org.collectionspace.csp.api.core.CSPDependencyException in project application by collectionspace.
the class ServicesStorageGenerator method configure.
@Override
public void configure(RuleSet rules) throws CSPDependencyException {
/* MAIN/persistence/service -> SERVICE */
rules.addRule(SECTIONED, new String[] { "persistence", "service" }, SECTION_PREFIX + "service", null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection milestone) {
((ConfigRoot) parent).setRoot(SERVICE_ROOT, ServicesStorageGenerator.this);
base_url = (String) milestone.getValue("/url");
// XXX should be path-selectable
((ConfigRoot) parent).setRoot(CSPContext.XXX_SERVICE_NAME, "service");
ims_url = (String) milestone.getValue("/ims-url");
tenantSpec = new TenantSpec(milestone);
return ServicesStorageGenerator.this;
}
});
rules.addRule(SECTION_PREFIX + "service", new String[] { "remoteclients", "remoteclient" }, SECTION_PREFIX + "remoteclient", null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection milestone) throws Exception {
String name = (String) milestone.getValue("/name");
String url = (String) milestone.getValue("/url");
String username = (String) milestone.getValue("/user");
String password = (String) milestone.getValue("/password");
String sslString = (String) milestone.getValue("/ssl");
boolean ssl = false;
if (sslString != null && sslString.equalsIgnoreCase(Boolean.toString(true))) {
ssl = true;
}
String authString = (String) milestone.getValue("/auth");
boolean auth = false;
if (authString != null && authString.equalsIgnoreCase(Boolean.toString(true))) {
auth = true;
}
String tenantId = (String) milestone.getValue("/tenantId");
String tenantName = (String) milestone.getValue("/tenantName");
RemoteClient remoteClient = tenantSpec.new RemoteClient(name, url, username, password, ssl, auth, tenantId, tenantName);
tenantSpec.addRemoteClient(remoteClient);
return this;
}
});
rules.addRule(SECTION_PREFIX + "service", new String[] { "repository", "dateformats", "pattern" }, SECTION_PREFIX + "dateformat", null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection milestone) {
String format = (String) milestone.getValue("");
tenantSpec.addFormat(format);
return this;
}
});
rules.addRule(SECTION_PREFIX + "service", new String[] { "repository", "languages", "language" }, SECTION_PREFIX + "language", null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection milestone) {
String lang = (String) milestone.getValue("");
tenantSpec.addLanguage(lang);
return this;
}
});
}
use of org.collectionspace.csp.api.core.CSPDependencyException in project application by collectionspace.
the class TenantServlet method load_config.
/**
* retrieve the correct config file based on the tenantId
* @param ctx
* @param tenantId
* @throws CSPDependencyException
*/
protected void load_config(ServletContext ctx, String tenantId) throws CSPDependencyException {
try {
ConfigFinder cfg = new ConfigFinder(ctx);
InputSource cfg_stream = cfg.resolveEntity("-//CSPACE//ROOT", "cspace-config-" + tenantId + ".xml");
if (cfg_stream == null) {
locked_down = "Cannot find cspace config xml file";
} else {
tenantCSPM.get(tenantId).configure(cfg_stream, cfg, false);
}
} catch (UnsupportedEncodingException e) {
throw new CSPDependencyException("Config has bad character encoding", e);
} catch (IOException e) {
throw new CSPDependencyException("Cannot load config", e);
} catch (SAXException e) {
throw new CSPDependencyException("Cannot parse config file", e);
}
}
use of org.collectionspace.csp.api.core.CSPDependencyException in project application by collectionspace.
the class TestData method getSpec.
public final Spec getSpec(ServletTester tester) {
if (this.spec == null) {
CSPManager cspm = new CSPManagerImpl();
cspm.register(new CoreConfig());
cspm.register(new Spec());
try {
cspm.go();
tester.getAttribute("config-filename");
String filename = (String) tester.getAttribute("config-filename");
cspm.configure(getSource(filename), new ConfigFinder(null), false);
} catch (CSPDependencyException e) {
log.info("CSPManagerImpl failed");
log.info(tester.getAttribute("config-filename").toString());
log.info(e.getLocalizedMessage());
}
ConfigRoot root = cspm.getConfigRoot();
Spec spec = (Spec) root.getRoot(Spec.SPEC_ROOT);
this.spec = spec;
}
return this.spec;
}
use of org.collectionspace.csp.api.core.CSPDependencyException in project application by collectionspace.
the class TestServices method getServiceManager.
private CSPManager getServiceManager(String filename) {
CSPManager cspm = new CSPManagerImpl();
cspm.register(new CoreConfig());
cspm.register(new Spec());
cspm.register(new ServicesStorageGenerator());
try {
cspm.go();
cspm.configure(getSource(filename), new ConfigFinder(null), false);
} catch (CSPDependencyException e) {
log.error("CSPManagerImpl failed");
log.error(e.getLocalizedMessage());
}
return cspm;
}
Aggregations