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;
}
}
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);
}
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();
}
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;
}
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());
}
Aggregations