use of org.jbei.ice.lib.dto.entry.PartData in project ice by JBEI.
the class FolderContents method getRemotelySharedContents.
// remote request for shared contents
public FolderDetails getRemotelySharedContents(String remoteUserId, String token, RegistryPartner partner, long folderId, PageParameters pageParameters) {
RemotePartner remotePartner = DAOFactory.getRemotePartnerDAO().getByUrl(partner.getUrl());
if (remotePartner == null) {
Logger.error("Cannot retrieve remote partner " + partner.getUrl());
return null;
}
Folder folder = folderDAO.get(folderId);
if (folder == null) {
Logger.error("Cannot retrieve folder with id " + folderId);
return null;
}
RemoteShareModelDAO shareModelDAO = DAOFactory.getRemoteShareModelDAO();
RemoteShareModel shareModel = shareModelDAO.get(remoteUserId, remotePartner, folder);
if (shareModel == null) {
Logger.error("Could not retrieve share model");
return null;
}
//verify access
TokenHash tokenHash = new TokenHash();
String secret = tokenHash.encrypt(folderId + remotePartner.getUrl() + remoteUserId, token);
if (!secret.equals(shareModel.getSecret())) {
Logger.error("Authorization failed for remote folder retrieve");
return null;
}
boolean canEdit = shareModel.getPermission().isCanWrite();
// todo : move everything above to folder permissions and folder authorization
FolderDetails details = folder.toDataTransferObject();
details.setCanEdit(canEdit);
long folderSize = folderDAO.getFolderSize(folderId, pageParameters.getFilter(), true);
details.setCount(folderSize);
// retrieve folder contents
List<Entry> results = folderDAO.retrieveFolderContents(folderId, pageParameters, true);
for (Entry entry : results) {
PartData info = ModelToInfoFactory.createTableViewData(null, entry, false);
info.setCanEdit(canEdit);
details.getEntries().add(info);
}
return details;
}
use of org.jbei.ice.lib.dto.entry.PartData in project ice by JBEI.
the class BlastPlus method parseBlastOutputLine.
/**
* Parses a blast output that represents a single hit
*
* @param line blast output for hit
* @return object wrapper around details of the hit
*/
private static SearchResult parseBlastOutputLine(String[] line) {
// extract part information
PartData view = new PartData(EntryType.nameToType(line[1]));
view.setId(Long.decode(line[0]));
view.setName(line[2]);
view.setPartId(line[3]);
String summary = DAOFactory.getEntryDAO().getEntrySummary(view.getId());
view.setShortDescription(summary);
//search result object
SearchResult searchResult = new SearchResult();
searchResult.setEntryInfo(view);
searchResult.seteValue(line[9]);
searchResult.setScore(Float.valueOf(line[11]));
searchResult.setAlignment(line[13]);
searchResult.setQueryLength(Integer.parseInt(line[12]));
searchResult.setNident(Integer.parseInt(line[13]));
return searchResult;
}
use of org.jbei.ice.lib.dto.entry.PartData in project ice by JBEI.
the class BulkUploadResource method createEntry.
/**
* @param uploadId
* @param data
* @return Response with created part data
*/
@PUT
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}/entry")
public Response createEntry(@PathParam("id") long uploadId, PartData data) {
String userId = getUserId();
Logger.info(userId + ": adding entry to upload \"" + uploadId + "\"");
PartData result = creator.createEntry(userId, uploadId, data);
return respond(result);
}
use of org.jbei.ice.lib.dto.entry.PartData in project ice by JBEI.
the class BulkUploadResource method updateEntry.
/**
* @param uploadId
* @param entryId
* @param data
* @return Response with updated part data
*/
@POST
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}/entry/{entryId}")
public Response updateEntry(@PathParam("id") long uploadId, @PathParam("entryId") long entryId, PartData data) {
String userId = getUserId();
Logger.info(userId + ": updating entry \"" + entryId + "\" for upload \"" + uploadId + "\"");
PartData result = creator.updateEntry(userId, uploadId, entryId, data);
return respond(result);
}
use of org.jbei.ice.lib.dto.entry.PartData in project ice by JBEI.
the class WebResource method getWebEntryTooltip.
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}/entries/{entryId}/tooltip")
public Response getWebEntryTooltip(@PathParam("id") final long partnerId, @PathParam("entryId") final long entryId) {
final String userId = super.getUserId();
final PartData result = remoteEntries.getPublicEntryTooltip(userId, partnerId, entryId);
return super.respond(Response.Status.OK, result);
}
Aggregations