use of org.nhindirect.config.model.Setting in project nhin-d by DirectProject.
the class SettingResource method getSettingByName.
/**
* Gets a setting by name.
* @param name The name of the setting to retrieve.
* @return A JSON representation of the setting. Returns a status of 404 if a setting with the given name does not exist.
*/
@Produces(MediaType.APPLICATION_JSON)
@Path("{name}")
@GET
public Response getSettingByName(@PathParam("name") String name) {
try {
final Collection<org.nhindirect.config.store.Setting> retSettings = settingDao.getByNames(Arrays.asList(name));
if (retSettings.isEmpty())
return Response.status(Status.NOT_FOUND).cacheControl(noCache).build();
final Setting modelSetting = EntityModelConversion.toModelSetting(retSettings.iterator().next());
return Response.ok(modelSetting).cacheControl(noCache).build();
} catch (Exception e) {
log.error("Error looking up setting.", e);
return Response.serverError().cacheControl(noCache).build();
}
}
use of org.nhindirect.config.model.Setting in project nhin-d by DirectProject.
the class SettingResource method addSetting.
/**
* Adds a setting to the system.
* @param uriInfo Injected URI context used for building the location URI.
* @param name The name of the setting to add.
* @param value The value of the setting.
* @return Status of 201 if the setting was created or a status of 409 if a setting with the same name
* already exists.
*/
@PUT
@Path("{name}/{value}")
public Response addSetting(@Context UriInfo uriInfo, @PathParam("name") String name, @PathParam("value") String value) {
// check to see if it already exists
try {
final Collection<org.nhindirect.config.store.Setting> retSettings = settingDao.getByNames(Arrays.asList(name));
if (!retSettings.isEmpty())
return Response.status(Status.CONFLICT).cacheControl(noCache).build();
} catch (Exception e) {
log.error("Error looking up setting.", e);
return Response.serverError().cacheControl(noCache).build();
}
try {
settingDao.add(name, value);
final UriBuilder newLocBuilder = uriInfo.getBaseUriBuilder();
final URI newLoc = newLocBuilder.path("setting/" + name).build();
return Response.created(newLoc).cacheControl(noCache).build();
} catch (Exception e) {
log.error("Error adding setting.", e);
return Response.serverError().cacheControl(noCache).build();
}
}
use of org.nhindirect.config.model.Setting in project nhin-d by DirectProject.
the class RESTSmtpAgentConfig method buildMDNSettings.
protected void buildMDNSettings() {
Setting autoResponseSettings;
Setting prodNameSetting;
Setting textSetting;
try {
autoResponseSettings = settingsService.getSetting("MDNAutoResponse");
prodNameSetting = settingsService.getSetting("MDNProdName");
textSetting = settingsService.getSetting("MDNProdName");
} catch (Exception e) {
throw new SmtpAgentException(SmtpAgentError.InvalidConfigurationFormat, "WebService error getting MDN settings: " + e.getMessage(), e);
}
boolean autoResponse = (autoResponseSettings == null) ? true : Boolean.parseBoolean(autoResponseSettings.getValue());
String prodName = (prodNameSetting == null) ? "" : prodNameSetting.getValue();
String text = (textSetting == null) ? "" : textSetting.getValue();
notificationProducer = new NotificationProducer(new NotificationSettings(autoResponse, prodName, text));
}
use of org.nhindirect.config.model.Setting in project nhin-d by DirectProject.
the class RESTSmtpAgentConfig method buildMessageSettings.
protected void buildMessageSettings(String type) {
Setting folderSettings;
try {
folderSettings = settingsService.getSetting("MessageSaveFolder");
} catch (Exception e) {
throw new SmtpAgentException(SmtpAgentError.InvalidConfigurationFormat, "WebService error getting " + type + " message settings: " + e.getMessage(), e);
}
String saveFolder = (folderSettings == null) ? null : folderSettings.getValue();
MessageProcessingSettings settings = null;
if (type.equalsIgnoreCase(MESSAGE_SETTING_RAW))
settings = rawSettings = new RawMessageSettings();
else if (type.equalsIgnoreCase(MESSAGE_SETTING_INCOMING))
settings = incomingSettings = new ProcessIncomingSettings();
else if (type.equalsIgnoreCase(MESSAGE_SETTING_OUTGOING))
settings = outgoingSettings = new ProcessOutgoingSettings();
else if (type.equalsIgnoreCase(MESSAGE_SETTING_BAD))
settings = badSettings = new ProcessBadMessageSettings();
if (saveFolder != null && settings != null)
settings.setSaveMessageFolder(new File(saveFolder));
}
use of org.nhindirect.config.model.Setting in project nhin-d by DirectProject.
the class RESTSmtpAgentConfig method buildPrivateCertStore.
protected void buildPrivateCertStore() {
Provider<CertificateResolver> resolverProvider = null;
Setting setting = null;
String storeType;
try {
setting = settingsService.getSetting("PrivateStoreType");
} catch (Exception e) {
throw new SmtpAgentException(SmtpAgentError.InvalidConfigurationFormat, "WebService error getting public store type: " + e.getMessage(), e);
}
if (setting == null || setting.getValue() == null || setting.getValue().isEmpty())
// default to WS
storeType = STORE_TYPE_WS;
else
storeType = setting.getValue();
/*
* KeyStore based resolver
*/
if (storeType.equalsIgnoreCase(STORE_TYPE_KEYSTORE)) {
Setting file;
Setting pass;
Setting privKeyPass;
try {
file = settingsService.getSetting("PrivateStoreFile");
pass = settingsService.getSetting("PrivateStoreFilePass");
privKeyPass = settingsService.getSetting("PrivateStorePrivKeyPass");
} catch (Exception e) {
throw new SmtpAgentException(SmtpAgentError.InvalidConfigurationFormat, "WebService error getting private store file settings: " + e.getMessage(), e);
}
resolverProvider = new KeyStoreCertificateStoreProvider((file == null) ? null : file.getValue(), (pass == null) ? null : pass.getValue(), (privKeyPass == null) ? null : privKeyPass.getValue());
} else if (storeType.equalsIgnoreCase(STORE_TYPE_LDAP)) {
resolverProvider = buildLdapCertificateStoreProvider("PrivateStore", "LDAPPrivateCertStore");
} else if (storeType.equalsIgnoreCase(STORE_TYPE_WS)) {
resolverProvider = new ConfigServiceRESTCertificateStoreProvider(certificateService, null, new ConfigServiceCertificateStore.DefaultConfigStoreCachePolicy(), this.storeProvider);
} else {
throw new SmtpAgentException(SmtpAgentError.InvalidPrivateCertStoreSettings);
}
privateCertModule = new PrivateCertStoreModule(resolverProvider);
}
Aggregations