use of org.jbei.ice.lib.config.ConfigurationSettings in project ice by JBEI.
the class RemoteAccessTest method testAdd.
@Test
public void testAdd() throws Exception {
new ConfigurationSettings().setPropertyValue(ConfigurationKey.JOIN_WEB_OF_REGISTRIES, "true");
// this tests the scenario where a WoR partner shares a remote resource (folder or entry) with a user
// on another instance
Account account = AccountCreator.createTestAccount("RemoteAccessTest.testAdd", false);
RemoteAccess remoteAccess = new RemoteAccess();
// create mock remote partner
RemotePartner partner = new RemotePartner();
partner.setUrl("remote-test.jbei.org");
partner = DAOFactory.getRemotePartnerDAO().create(partner);
// create permission to share with this user
AccessPermission permission = new AccessPermission();
AccountTransfer accountTransfer = new AccountTransfer();
// person sharing
accountTransfer.setEmail("I wanna share from far away");
permission.setAccount(accountTransfer);
permission.setDisplay("Folder Name");
permission.setUserId(account.getEmail());
permission.setType(AccessPermission.Type.READ_FOLDER);
permission.setTypeId(Integer.MAX_VALUE);
permission.setSecret("supersekrit");
AccessPermission accessPermission = remoteAccess.add(partner.toDataTransferObject(), permission);
Folder folder = DAOFactory.getFolderDAO().get(accessPermission.getTypeId());
RemoteAccessModel model = DAOFactory.getRemoteAccessModelDAO().getByFolder(account, folder);
Assert.assertNotNull(model);
// shared folder should be in list of shared collection
Collections collections = new Collections(account.getEmail());
List<FolderDetails> subFolders = collections.getSubFolders(CollectionType.SHARED);
boolean found = false;
for (FolderDetails details : subFolders) {
found = details.getName().equalsIgnoreCase(permission.getDisplay()) && Long.toString(permission.getTypeId()).equals(details.getDescription());
if (found)
break;
}
Assert.assertTrue(found);
}
use of org.jbei.ice.lib.config.ConfigurationSettings 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);
ConfigurationSettings settings = new ConfigurationSettings();
settings.setPropertyValue(ConfigurationKey.URI_PREFIX, url);
}
WebOfRegistriesTask contactTask = new WebOfRegistriesTask(userId, url, enable);
IceExecutorService.getInstance().runTask(contactTask);
}
Aggregations