Search in sources :

Example 31 with FolderDetails

use of org.jbei.ice.lib.dto.folder.FolderDetails in project ice by JBEI.

the class RemoteFolder method getEntries.

public FolderDetails getEntries(String sort, boolean asc, int offset, int limit) {
    try {
        String restPath = "rest/folders/" + folderId + "/entries";
        HashMap<String, Object> queryParams = new HashMap<>();
        queryParams.put("offset", offset);
        queryParams.put("limit", limit);
        queryParams.put("asc", asc);
        queryParams.put("sort", sort);
        FolderDetails result = this.restClient.getWor(partner.getUrl(), restPath, FolderDetails.class, queryParams, partner.getApiKey());
        if (result == null)
            return null;
        return result;
    } catch (Exception e) {
        Logger.error("Error getting public folder entries from \"" + partner.getUrl() + "\": " + e.getMessage());
        return null;
    }
}
Also used : HashMap(java.util.HashMap) FolderDetails(org.jbei.ice.lib.dto.folder.FolderDetails)

Example 32 with FolderDetails

use of org.jbei.ice.lib.dto.folder.FolderDetails in project ice by JBEI.

the class FolderResource method create.

/**
     * Creates a new folder with the details specified in the parameter. The folder
     * is either created by a user or represents one that is transferred
     * <p/>
     * The default type for the folder is <code>PRIVATE</code> and is owned by the user creating it
     * unless it is transferred
     *
     * @param isTransfer whether the folder being created is a transfer folder or not
     * @param folder     details of the folder to create
     * @return information about the created folder including the unique identifier
     */
@POST
@Produces(MediaType.APPLICATION_JSON)
public Response create(@DefaultValue("false") @QueryParam("isTransfer") boolean isTransfer, final FolderDetails folder) {
    FolderDetails created;
    if (!isTransfer) {
        final String userId = requireUserId();
        log(userId, "creating new folder");
        created = controller.createPersonalFolder(userId, folder);
    } else {
        // todo : get partner identifier
        created = controller.createTransferredFolder(folder);
    }
    return super.respond(created);
}
Also used : FolderDetails(org.jbei.ice.lib.dto.folder.FolderDetails)

Example 33 with FolderDetails

use of org.jbei.ice.lib.dto.folder.FolderDetails in project ice by JBEI.

the class Manuscripts method add.

public Manuscript add(Manuscript manuscript) {
    // todo : validation
    ManuscriptModel model = new ManuscriptModel();
    model.setCreationTime(new Date());
    model.setStatus(manuscript.getStatus());
    model.setParagonUrl(manuscript.getParagonUrl());
    model.setTitle(manuscript.getTitle());
    model.setAuthorFirstName(manuscript.getAuthorFirstName());
    model.setAuthorLastName(manuscript.getAuthorLastName());
    FolderDetails details = manuscript.getFolder();
    Folder folder = DAOFactory.getFolderDAO().get(details.getId());
    model.setFolder(folder);
    return dao.create(model).toDataTransferObject();
}
Also used : ManuscriptModel(org.jbei.ice.storage.model.ManuscriptModel) FolderDetails(org.jbei.ice.lib.dto.folder.FolderDetails) Folder(org.jbei.ice.storage.model.Folder) Date(java.util.Date)

Example 34 with FolderDetails

use of org.jbei.ice.lib.dto.folder.FolderDetails in project ice by JBEI.

the class UserResource method getProfileEntries.

/**
     * @return collection for user's part entries
     */
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}/entries")
public FolderDetails getProfileEntries(@PathParam("id") long userId, @DefaultValue("0") @QueryParam("offset") int offset, @DefaultValue("15") @QueryParam("limit") int limit, @DefaultValue("created") @QueryParam("sort") String sort, @DefaultValue("false") @QueryParam("asc") boolean asc, @DefaultValue("") @QueryParam("filter") String filter) {
    String userIdString = getUserId();
    ColumnField field = ColumnField.valueOf(sort.toUpperCase());
    OwnerEntries ownerEntries = new OwnerEntries(userIdString, userId);
    List<PartData> entries = ownerEntries.retrieveOwnerEntries(field, asc, offset, limit, filter);
    long count = ownerEntries.getNumberOfOwnerEntries();
    FolderDetails details = new FolderDetails();
    details.getEntries().addAll(entries);
    details.setCount(count);
    return details;
}
Also used : ColumnField(org.jbei.ice.lib.shared.ColumnField) PartData(org.jbei.ice.lib.dto.entry.PartData) FolderDetails(org.jbei.ice.lib.dto.folder.FolderDetails) OwnerEntries(org.jbei.ice.lib.entry.OwnerEntries)

Example 35 with FolderDetails

use of org.jbei.ice.lib.dto.folder.FolderDetails in project ice by JBEI.

the class RemoteAccessTest method testAdd.

@Test
public void testAdd() throws Exception {
    Account account = AccountCreator.createTestAccount("RemoteAccessTest.testAdd", false);
    RemoteAccess remoteAccess = new RemoteAccess();
    RemotePartner partner = new RemotePartner();
    partner.setUrl("registry.jbei.org");
    partner = DAOFactory.getRemotePartnerDAO().create(partner);
    // create permission to share with this user
    AccessPermission permission = new AccessPermission();
    AccountTransfer accountTransfer = new AccountTransfer();
    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.setSecret("supersekrit");
    remoteAccess.add(partner.toDataTransferObject(), permission);
    Collections collections = new Collections(account.getEmail());
    List<FolderDetails> subFolders = collections.getSubFolders(CollectionType.SHARED);
    Assert.assertEquals(1, subFolders.size());
}
Also used : Account(org.jbei.ice.storage.model.Account) RemotePartner(org.jbei.ice.storage.model.RemotePartner) AccessPermission(org.jbei.ice.lib.dto.access.AccessPermission) FolderDetails(org.jbei.ice.lib.dto.folder.FolderDetails) Collections(org.jbei.ice.lib.folder.collection.Collections) AccountTransfer(org.jbei.ice.lib.account.AccountTransfer) Test(org.junit.Test)

Aggregations

FolderDetails (org.jbei.ice.lib.dto.folder.FolderDetails)35 Folder (org.jbei.ice.storage.model.Folder)11 PartData (org.jbei.ice.lib.dto.entry.PartData)8 Account (org.jbei.ice.storage.model.Account)8 PermissionException (org.jbei.ice.lib.access.PermissionException)6 AccessPermission (org.jbei.ice.lib.dto.access.AccessPermission)5 Test (org.junit.Test)5 AccountTransfer (org.jbei.ice.lib.account.AccountTransfer)4 GroupController (org.jbei.ice.lib.group.GroupController)4 ArrayList (java.util.ArrayList)3 BulkUploadInfo (org.jbei.ice.lib.bulkupload.BulkUploadInfo)3 EntrySelection (org.jbei.ice.lib.entry.EntrySelection)3 Group (org.jbei.ice.storage.model.Group)3 RemotePartner (org.jbei.ice.storage.model.RemotePartner)3 Date (java.util.Date)2 HashMap (java.util.HashMap)2 TokenHash (org.jbei.ice.lib.account.TokenHash)2 Entries (org.jbei.ice.lib.entry.Entries)2 Entry (org.jbei.ice.storage.model.Entry)2 HashSet (java.util.HashSet)1