use of org.jbei.ice.lib.config.ConfigurationController in project ice by JBEI.
the class SequenceController method update.
/**
* Update the {@link Sequence} in the database, with the option to rebuild the search index.
*
* @param userId unique identifier for user performing action
* @param sequence sequence to be updated
* @return Saved Sequence.
*/
protected Sequence update(String userId, Sequence sequence) {
authorization.expectWrite(userId, sequence.getEntry());
Sequence result;
Entry entry = sequence.getEntry();
entry.setModificationTime(Calendar.getInstance().getTime());
Sequence oldSequence = dao.getByEntry(entry);
if (oldSequence == null) {
result = dao.create(sequence);
} else {
String tmpDir = new ConfigurationController().getPropertyValue(ConfigurationKey.TEMPORARY_DIRECTORY);
if (!StringUtils.isEmpty(tmpDir)) {
String hash = oldSequence.getFwdHash();
try {
Files.deleteIfExists(Paths.get(tmpDir, hash + ".png"));
} catch (IOException e) {
Logger.warn(e.getMessage());
}
}
oldSequence.setSequenceUser(sequence.getSequenceUser());
oldSequence.setSequence(sequence.getSequence());
oldSequence.setFwdHash(sequence.getFwdHash());
oldSequence.setRevHash(sequence.getRevHash());
result = dao.updateSequence(oldSequence, sequence.getSequenceFeatures());
}
BlastPlus.scheduleBlastIndexRebuildTask(true);
return result;
}
use of org.jbei.ice.lib.config.ConfigurationController in project ice by JBEI.
the class SequenceController method deleteSequence.
public boolean deleteSequence(String requester, long partId) {
Entry entry = DAOFactory.getEntryDAO().get(partId);
authorization.expectWrite(requester, entry);
Sequence sequence = dao.getByEntry(entry);
if (sequence == null)
return true;
String tmpDir = new ConfigurationController().getPropertyValue(ConfigurationKey.TEMPORARY_DIRECTORY);
dao.deleteSequence(sequence, tmpDir);
BlastPlus.scheduleBlastIndexRebuildTask(true);
return true;
}
use of org.jbei.ice.lib.config.ConfigurationController in project ice by JBEI.
the class Utils method getConfigValue.
public static String getConfigValue(ConfigurationKey key) {
ConfigurationController controller = new ConfigurationController();
String value = controller.getPropertyValue(key);
if (value != null)
return value;
return key.getDefaultValue();
}
use of org.jbei.ice.lib.config.ConfigurationController in project ice by JBEI.
the class WoRControllerTest method testIsWebEnabled.
@Test
public void testIsWebEnabled() throws Exception {
Assert.assertFalse(controller.isWebEnabled());
new ConfigurationController().setPropertyValue(ConfigurationKey.JOIN_WEB_OF_REGISTRIES, "yes");
Assert.assertTrue(controller.isWebEnabled());
new ConfigurationController().setPropertyValue(ConfigurationKey.JOIN_WEB_OF_REGISTRIES, "no");
Assert.assertFalse(controller.isWebEnabled());
}
use of org.jbei.ice.lib.config.ConfigurationController in project ice by JBEI.
the class WoRController method setEnable.
/**
* Runs the web of registries task for contacting the appropriate partners to enable or disable
* web of registries functionality
*
* @param enable if true, enables WoR; disables it otherwise
* @param url the url for this ice instance
*/
public void setEnable(String userId, boolean enable, String url) {
String thisUrl = Utils.getConfigValue(ConfigurationKey.URI_PREFIX);
if (!thisUrl.equalsIgnoreCase(url)) {
Logger.info("Auto updating uri to " + url);
ConfigurationController configurationController = new ConfigurationController();
configurationController.setPropertyValue(ConfigurationKey.URI_PREFIX, url);
}
WebOfRegistriesTask contactTask = new WebOfRegistriesTask(userId, url, enable);
IceExecutorService.getInstance().runTask(contactTask);
}
Aggregations