Search in sources :

Example 16 with RegistryPartner

use of org.jbei.ice.lib.dto.web.RegistryPartner in project ice by JBEI.

the class PermissionResource method addRemoteAccess.

/**
     * Add a remote access from a partner in the web of registries
     */
@POST
@Path("/remote")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response addRemoteAccess(RemoteAccessPermission accessPermission) {
    RegistryPartner partner = requireWebPartner();
    RemoteAccess remoteAccess = new RemoteAccess();
    return super.respond(remoteAccess.add(partner, accessPermission));
}
Also used : RegistryPartner(org.jbei.ice.lib.dto.web.RegistryPartner) RemoteAccess(org.jbei.ice.lib.access.RemoteAccess) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 17 with RegistryPartner

use of org.jbei.ice.lib.dto.web.RegistryPartner in project ice by JBEI.

the class WebResource method getWebPartner.

@GET
@Path("/partner/{id}")
public Response getWebPartner(@PathParam("id") final long partnerId) {
    final String userId = getUserId();
    final RegistryPartner partner = controller.getWebPartner(userId, partnerId);
    return super.respond(Response.Status.OK, partner);
}
Also used : RegistryPartner(org.jbei.ice.lib.dto.web.RegistryPartner)

Example 18 with RegistryPartner

use of org.jbei.ice.lib.dto.web.RegistryPartner in project ice by JBEI.

the class RestResource method requireUserIdOrWebPartner.

/**
     * Requires either a valid user request or request from a web partner
     *
     * @param logMessage log message for request
     */
protected void requireUserIdOrWebPartner(String logMessage) {
    String userId = getUserId();
    if (StringUtils.isNotEmpty(userId)) {
        log(userId, logMessage);
        return;
    }
    // try web partner
    RegistryPartner partner = getWebPartner();
    if (partner == null)
        throw new WebApplicationException(Response.Status.UNAUTHORIZED);
    log(partner.getUrl(), logMessage);
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) RegistryPartner(org.jbei.ice.lib.dto.web.RegistryPartner)

Example 19 with RegistryPartner

use of org.jbei.ice.lib.dto.web.RegistryPartner in project ice by JBEI.

the class WebPartnersTest method testAddNewPartner.

@Test
public void testAddNewPartner() throws Exception {
    Account admin = AccountCreator.createTestAccount("WebPartnersTest.testAddNewPartner", true);
    String adminUser = admin.getEmail();
    WebPartners partners = createThisPartnerObject();
    // create registryPartner for add
    RegistryPartner partner = new RegistryPartner();
    partner.setUrl("registry-test20.jbei.org");
    RegistryPartner added = partners.addNewPartner(adminUser, partner);
    Assert.assertNotNull(added);
    Assert.assertEquals(partner.getUrl(), "registry-test20.jbei.org");
    Assert.assertEquals(added.getStatus(), RemotePartnerStatus.APPROVED);
    // try to add the same partner again: list of partners should remain the same
    // (at two since both remote and local are implemented here)
    long size = partners.getPartners().size();
    partners.addNewPartner(adminUser, partner);
    Assert.assertEquals(size, partners.getPartners().size());
}
Also used : Account(org.jbei.ice.storage.model.Account) RegistryPartner(org.jbei.ice.lib.dto.web.RegistryPartner) Test(org.junit.Test)

Example 20 with RegistryPartner

use of org.jbei.ice.lib.dto.web.RegistryPartner in project ice by JBEI.

the class WebPartnersTest method createThisPartnerObject.

private WebPartners createThisPartnerObject() {
    final String myURL = "registry-test10.jbei.org";
    return new WebPartners(createRemoteContact()) {

        protected boolean isInWebOfRegistries() {
            return true;
        }

        protected RegistryPartner getThisInstanceWithNewApiKey() {
            RegistryPartner thisPartner = new RegistryPartner();
            String myName = "Registry test";
            thisPartner.setName(myName);
            thisPartner.setUrl(myURL);
            thisPartner.setApiKey("efg");
            return thisPartner;
        }

        protected String getThisUri() {
            return myURL;
        }
    };
}
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