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));
}
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);
}
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);
}
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());
}
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;
}
};
}
Aggregations