use of org.jbei.ice.lib.dto.folder.FolderDetails in project ice by JBEI.
the class RemoteEntries method getPublicEntries.
public PartnerEntries getPublicEntries(long remoteId, int offset, int limit, String sort, boolean asc) {
if (!hasRemoteAccessEnabled())
return null;
RemotePartner partner = this.remotePartnerDAO.get(remoteId);
if (partner == null)
return null;
FolderDetails details;
try {
final String restPath = "rest/folders/public/entries";
HashMap<String, Object> queryParams = new HashMap<>();
queryParams.put("offset", offset);
queryParams.put("limit", limit);
queryParams.put("asc", asc);
queryParams.put("sort", sort);
details = this.remoteContact.getFolderEntries(partner.getUrl(), restPath, queryParams, partner.getApiKey());
if (details == null)
return null;
} catch (Exception e) {
Logger.error(e);
return null;
}
Results<PartData> results = new Results<>();
results.setData(details.getEntries());
results.setResultCount(details.getCount());
return new PartnerEntries(partner.toDataTransferObject(), results);
}
use of org.jbei.ice.lib.dto.folder.FolderDetails in project ice by JBEI.
the class FolderResource method update.
/**
* Updates the specified folder resource
*
* @param folderId resource identifier of folder to be updated
* @param details details for update
*/
@PUT
@Path("/{id}")
public Response update(@PathParam("id") final long folderId, final FolderDetails details) {
final String userId = requireUserId();
log(userId, "update folder \"" + folderId + "\"");
final FolderDetails resp = controller.update(userId, folderId, details);
return super.respond(resp);
}
use of org.jbei.ice.lib.dto.folder.FolderDetails in project ice by JBEI.
the class FolderContents method getContents.
/**
* Retrieves the folder specified in the parameter and contents
*
* @param userId unique identifier for user making request. If null, folder must have public read privs
* @param folderId unique identifier for folder to be retrieved
* @param pageParameters paging parameters
* @return wrapper around list of folder entries if folder is found, null otherwise
* @throws PermissionException if user does not have read permissions on folder
*/
public FolderDetails getContents(String userId, long folderId, PageParameters pageParameters) {
Folder folder = folderDAO.get(folderId);
if (folder == null)
return null;
// should have permission to read folder
folderAuthorization.expectRead(userId, folder);
if (folder.getType() == FolderType.REMOTE)
return getRemoteContents(userId, folder, pageParameters);
boolean visibleOnly = folder.getType() != FolderType.TRANSFERRED;
FolderDetails details = folder.toDataTransferObject();
// all local entries at this point
long folderSize = folderDAO.getFolderSize(folderId, pageParameters.getFilter(), visibleOnly);
details.setCount(folderSize);
if (userId != null) {
List<AccessPermission> permissions = getAndFilterFolderPermissions(userId, folder);
details.setAccessPermissions(permissions);
boolean canEdit = permissionsController.hasWritePermission(userId, folder);
details.setCanEdit(canEdit);
}
details.setPublicReadAccess(permissionsController.isPublicVisible(folder));
Account owner = DAOFactory.getAccountDAO().getByEmail(folder.getOwnerEmail());
if (owner != null)
details.setOwner(owner.toDataTransferObject());
// retrieve folder contents
List<Entry> results = folderDAO.retrieveFolderContents(folderId, pageParameters, visibleOnly);
for (Entry entry : results) {
PartData info = ModelToInfoFactory.createTableViewData(userId, entry, false);
details.getEntries().add(info);
}
return details;
}
use of org.jbei.ice.lib.dto.folder.FolderDetails in project ice by JBEI.
the class FolderController method createPersonalFolder.
public FolderDetails createPersonalFolder(String userId, FolderDetails folderDetails) {
if (folderDetails.getName() == null)
return null;
Folder folder = new Folder(folderDetails.getName());
AccountTransfer owner = folderDetails.getOwner();
if (owner != null && !StringUtils.isEmpty(owner.getEmail()) && accountController.isAdministrator(userId))
folder.setOwnerEmail(owner.getEmail());
else
folder.setOwnerEmail(userId);
folder.setType(FolderType.PRIVATE);
folder.setCreationTime(new Date());
folder = dao.create(folder);
FolderDetails details = folder.toDataTransferObject();
details.setCanEdit(true);
return details;
}
use of org.jbei.ice.lib.dto.folder.FolderDetails in project ice by JBEI.
the class FolderController method getPublicEntries.
/**
* Retrieves entries that are made available publicly
*
* @param sort order of retrieval for the entries
* @param offset start of retrieval
* @param limit maximum number of entries to retrieve
* @param asc whether to retrieve the entries in ascending order
* @return wrapper around the retrieved entries
*/
public FolderDetails getPublicEntries(ColumnField sort, int offset, int limit, boolean asc) {
Group publicGroup = new GroupController().createOrRetrievePublicGroup();
Set<Group> groups = new HashSet<>();
groups.add(publicGroup);
EntryDAO entryDAO = DAOFactory.getEntryDAO();
List<Entry> results = entryDAO.retrieveVisibleEntries(null, groups, sort, asc, offset, limit, null);
long visibleCount = entryDAO.visibleEntryCount(null, groups, null);
FolderDetails details = new FolderDetails();
details.setCount(visibleCount);
for (Entry entry : results) {
try {
PartData info = ModelToInfoFactory.createTableViewData(null, entry, false);
info.setPublicRead(true);
details.getEntries().add(info);
} catch (Exception e) {
Logger.error(e);
}
}
return details;
}
Aggregations