use of org.jbei.ice.lib.dto.web.RegistryPartner in project ice by JBEI.
the class RemoteClientModel method toDataTransferObject.
@Override
public RemoteUser toDataTransferObject() {
RemoteUser remoteUser = new RemoteUser();
RegistryPartner partner = new RegistryPartner();
partner.setId(remotePartner.getId());
partner.setUrl(remotePartner.getUrl());
partner.setName(remotePartner.getName());
remoteUser.setPartner(partner);
AccountTransfer accountTransfer = new AccountTransfer();
accountTransfer.setEmail(email);
remoteUser.setUser(accountTransfer);
return remoteUser;
}
use of org.jbei.ice.lib.dto.web.RegistryPartner in project ice by JBEI.
the class WoRController method getRegistryPartners.
public WebOfRegistries getRegistryPartners(boolean approvedOnly) {
WebOfRegistries webOfRegistries = new WebOfRegistries();
webOfRegistries.setWebEnabled(isWebEnabled());
// retrieve actual partners
List<RemotePartner> partners = dao.getRegistryPartners();
ArrayList<RegistryPartner> registryPartners = new ArrayList<>();
for (RemotePartner partner : partners) {
if (approvedOnly && partner.getPartnerStatus() != RemotePartnerStatus.APPROVED)
continue;
registryPartners.add(partner.toDataTransferObject());
}
webOfRegistries.setPartners(registryPartners);
return webOfRegistries;
}
use of org.jbei.ice.lib.dto.web.RegistryPartner in project ice by JBEI.
the class PartResource method read.
/**
* Retrieves a part using any of the unique identifiers. e.g. Part number, synthetic id, or
* global unique identifier.
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}")
public Response read(@PathParam("id") final String id, @DefaultValue("false") @QueryParam("remote") boolean isRemote, // todo : move to header
@QueryParam("token") String remoteUserToken, @QueryParam("userId") String remoteUserId, @QueryParam("folderId") long fid) {
String userId = getUserId();
if (isRemote) {
log(userId, "get remote entry");
long partId = Long.decode(id);
PartData data = remoteEntries.getEntryDetails(userId, fid, partId);
return super.respond(data);
} else {
try {
if (StringUtils.isEmpty(userId)) {
RegistryPartner partner = requireWebPartner();
log(partner.getUrl(), "retrieving details for " + id);
return super.respond(controller.getRequestedEntry(remoteUserId, remoteUserToken, id, fid, partner));
} else {
log(userId, "retrieving details for " + id);
return super.respond(controller.retrieveEntryDetails(userId, id));
}
} catch (final PermissionException pe) {
throw new WebApplicationException(Response.Status.FORBIDDEN);
}
}
}
use of org.jbei.ice.lib.dto.web.RegistryPartner in project ice by JBEI.
the class PartResource method getSequence.
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}/sequence")
public Response getSequence(@PathParam("id") final String partId, @DefaultValue("false") @QueryParam("remote") boolean isRemote, @QueryParam("token") String remoteUserToken, @QueryParam("userId") String remoteUserId, @QueryParam("folderId") long fid) {
final FeaturedDNASequence sequence;
final String userId = getUserId();
try {
if (isRemote) {
// entry exists remotely
sequence = remoteEntries.getSequence(userId, fid, partId);
} else {
// what request is being responded to (local or remote)
if (StringUtils.isEmpty(userId)) {
RegistryPartner partner = requireWebPartner();
if (StringUtils.isEmpty(remoteUserToken) || fid == 0) {
sequence = sequenceController.retrievePartSequence(userId, partId);
} else {
sequence = sequenceController.getRequestedSequence(partner, remoteUserId, remoteUserToken, partId, fid);
}
} else {
// user id can be null if partId is public
sequence = sequenceController.retrievePartSequence(userId, partId);
}
}
return Response.status(Response.Status.OK).entity(sequence).build();
} catch (PermissionException pe) {
throw new WebApplicationException(Response.Status.FORBIDDEN);
}
}
use of org.jbei.ice.lib.dto.web.RegistryPartner in project ice by JBEI.
the class PartnerResource method updateRemotePartnerAPIKey.
/**
* Request from a remote ICE instance to update it's api key
* Verification uses the existing API key. Similar to updating password
* by sending the old password
*
* @param partner remote partner information (including new api key)
* @return information about this instance with the new token remote partner
*/
@PUT
public Response updateRemotePartnerAPIKey(RegistryPartner partner) {
RegistryPartner registryPartner = requireWebPartner();
WebPartners partners = new WebPartners();
return super.respond(partners.updateRemoteAPIKey(registryPartner.getUrl(), partner));
}
Aggregations