Search in sources :

Example 21 with RegistryPartner

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;
}
Also used : RemoteUser(org.jbei.ice.lib.dto.web.RemoteUser) RegistryPartner(org.jbei.ice.lib.dto.web.RegistryPartner) AccountTransfer(org.jbei.ice.lib.account.AccountTransfer)

Example 22 with RegistryPartner

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;
}
Also used : RemotePartner(org.jbei.ice.storage.model.RemotePartner) RegistryPartner(org.jbei.ice.lib.dto.web.RegistryPartner) WebOfRegistries(org.jbei.ice.lib.dto.web.WebOfRegistries) ArrayList(java.util.ArrayList)

Example 23 with RegistryPartner

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);
        }
    }
}
Also used : PermissionException(org.jbei.ice.lib.access.PermissionException) RegistryPartner(org.jbei.ice.lib.dto.web.RegistryPartner)

Example 24 with RegistryPartner

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);
    }
}
Also used : PermissionException(org.jbei.ice.lib.access.PermissionException) RegistryPartner(org.jbei.ice.lib.dto.web.RegistryPartner) FeaturedDNASequence(org.jbei.ice.lib.dto.FeaturedDNASequence)

Example 25 with RegistryPartner

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));
}
Also used : RegistryPartner(org.jbei.ice.lib.dto.web.RegistryPartner)

Aggregations

RegistryPartner (org.jbei.ice.lib.dto.web.RegistryPartner)33 RemotePartner (org.jbei.ice.storage.model.RemotePartner)11 PermissionException (org.jbei.ice.lib.access.PermissionException)6 AccountTransfer (org.jbei.ice.lib.account.AccountTransfer)3 Account (org.jbei.ice.storage.model.Account)3 ArrayList (java.util.ArrayList)2 RemoteUser (org.jbei.ice.lib.dto.web.RemoteUser)2 Test (org.junit.Test)2 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 Consumes (javax.ws.rs.Consumes)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 RemoteAccess (org.jbei.ice.lib.access.RemoteAccess)1 TokenVerification (org.jbei.ice.lib.access.TokenVerification)1 AccountController (org.jbei.ice.lib.account.AccountController)1 FeaturedDNASequence (org.jbei.ice.lib.dto.FeaturedDNASequence)1 AccessPermission (org.jbei.ice.lib.dto.access.AccessPermission)1