Search in sources :

Example 6 with ConfigurationSettings

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);
}
Also used : Account(org.jbei.ice.storage.model.Account) RemotePartner(org.jbei.ice.storage.model.RemotePartner) AccessPermission(org.jbei.ice.lib.dto.access.AccessPermission) ConfigurationSettings(org.jbei.ice.lib.config.ConfigurationSettings) FolderDetails(org.jbei.ice.lib.dto.folder.FolderDetails) Folder(org.jbei.ice.storage.model.Folder) Collections(org.jbei.ice.lib.folder.collection.Collections) RemoteAccessModel(org.jbei.ice.storage.model.RemoteAccessModel) AccountTransfer(org.jbei.ice.lib.account.AccountTransfer) Test(org.junit.Test)

Example 7 with ConfigurationSettings

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);
}
Also used : ConfigurationSettings(org.jbei.ice.lib.config.ConfigurationSettings)

Aggregations

ConfigurationSettings (org.jbei.ice.lib.config.ConfigurationSettings)7 File (java.io.File)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Path (java.nio.file.Path)1 LineIterator (org.apache.commons.io.LineIterator)1 AccountController (org.jbei.ice.lib.account.AccountController)1 AccountTransfer (org.jbei.ice.lib.account.AccountTransfer)1 FeaturedDNASequence (org.jbei.ice.lib.dto.FeaturedDNASequence)1 AccessPermission (org.jbei.ice.lib.dto.access.AccessPermission)1 SequenceInfo (org.jbei.ice.lib.dto.entry.SequenceInfo)1 FolderDetails (org.jbei.ice.lib.dto.folder.FolderDetails)1 AutoAnnotationBlastDbBuildTask (org.jbei.ice.lib.entry.sequence.annotation.AutoAnnotationBlastDbBuildTask)1 Collections (org.jbei.ice.lib.folder.collection.Collections)1 GroupController (org.jbei.ice.lib.group.GroupController)1 AbstractParser (org.jbei.ice.lib.parsers.AbstractParser)1 InvalidFormatParserException (org.jbei.ice.lib.parsers.InvalidFormatParserException)1 PlainParser (org.jbei.ice.lib.parsers.PlainParser)1 FastaParser (org.jbei.ice.lib.parsers.fasta.FastaParser)1 GenBankParser (org.jbei.ice.lib.parsers.genbank.GenBankParser)1