use of org.collectionspace.chain.csp.persistence.services.TenantSpec.RemoteClient 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.chain.csp.persistence.services.TenantSpec.RemoteClient in project application by collectionspace.
the class ServiceBindingsGeneration method makeRemoteClients.
private void makeRemoteClients(Element tenantBindingElement) {
RemoteClient[] remoteClientList = tenantSpec.getRemoteClients();
if (remoteClientList != null && remoteClientList.length > 0) {
Element remoteClientsElement = tenantBindingElement.addElement(new QName("remoteClientConfigurations", nstenant));
for (TenantSpec.RemoteClient remoteClient : remoteClientList) {
Element remoteClientElement = remoteClientsElement.addElement(new QName("remoteClientConfig", nstenant));
Element ele;
ele = remoteClientElement.addElement(new QName("name", nstenant));
ele.addText(remoteClient.getName());
ele = remoteClientElement.addElement(new QName("url", nstenant));
ele.addText(remoteClient.getUrl());
ele = remoteClientElement.addElement(new QName("user", nstenant));
ele.addText(remoteClient.getUser());
ele = remoteClientElement.addElement(new QName("password", nstenant));
ele.addText(remoteClient.getPassword());
// Optional
if (remoteClient.getTenantId() != null) {
ele = remoteClientElement.addElement(new QName("tenantId", nstenant));
ele.addText(remoteClient.getTenantId());
}
// Optional
if (remoteClient.getTenantName() != null) {
ele = remoteClientElement.addElement(new QName("tenantName", nstenant));
ele.addText(remoteClient.getTenantName());
}
ele = remoteClientElement.addElement(new QName("ssl", nstenant));
ele.addText(remoteClient.getSSL());
ele = remoteClientElement.addElement(new QName("auth", nstenant));
ele.addText(remoteClient.getAuth());
}
}
}
Aggregations