use of org.jbei.ice.lib.dto.sample.SampleRequest 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, List<String> fields) {
Folder folder = folderDAO.get(folderId);
if (folder == null)
return null;
// should have permission to read folder
folderAuthorization.expectRead(userId, folder);
// check if folder doesn't exist on this instance and has to be retrieved from another
if (folder.getType() == FolderType.REMOTE)
return getRemoteContents(userId, folder, pageParameters);
boolean visibleOnly = showVisibleOnlyEntries(userId, folder);
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 = folderAuthorization.canWrite(userId, folder);
details.setCanEdit(canEdit);
}
details.setPublicReadAccess(permissionsController.isPublicVisible(folder));
Account owner = DAOFactory.getAccountDAO().getByEmail(folder.getOwnerEmail());
if (owner != null)
details.setOwner(owner.toDataTransferObject());
// check for sample request information
if (folder.getType() == FolderType.SAMPLE) {
SampleCreateModel model = DAOFactory.getSampleCreateModelDAO().getByFolder(folder);
if (model != null) {
SampleRequest request = new SampleRequest();
request.setStatus(model.getStatus());
request.setId(model.getId());
details.setSampleRequest(request);
}
}
// retrieve folder contents
List<Long> results = folderDAO.retrieveFolderContents(folderId, pageParameters, visibleOnly);
for (Long entryId : results) {
PartData info = ModelToInfoFactory.createTableView(entryId, fields);
details.getEntries().add(info);
}
return details;
}
Aggregations