Search in sources :

Example 1 with LSIDServerException

use of com.ibm.lsid.server.LSIDServerException in project cdmlib by cybertaxonomy.

the class AuthorityControllerTest method testNotifyForeignAuthority.

@Test(expected = LSIDServerException.class)
public void testNotifyForeignAuthority() throws Exception {
    LSIDServerException lse = new LSIDServerException(LSIDException.METHOD_NOT_IMPLEMENTED, "FAN service not available");
    authorityService.notifyForeignAuthority(LSIDMatchers.eqLSID(lsid), LSIDMatchers.eqLSIDAuthority(lsidAuthority));
    EasyMock.expectLastCall().andThrow(lse);
    EasyMock.replay(authorityService);
    authorityController.notifyForeignAuthority(lsid, lsidAuthority);
}
Also used : LSIDServerException(com.ibm.lsid.server.LSIDServerException) Test(org.junit.Test)

Example 2 with LSIDServerException

use of com.ibm.lsid.server.LSIDServerException in project cdmlib by cybertaxonomy.

the class AuthorityControllerTest method testGetServicesWithUnknownLSID.

@Test(expected = LSIDServerException.class)
public void testGetServicesWithUnknownLSID() throws Exception {
    LSIDServerException lse = new LSIDServerException(LSIDException.UNKNOWN_LSID, "Unknown LSID");
    EasyMock.expect(authorityService.getAvailableServices(LSIDMatchers.eqLSID(lsid))).andThrow(lse);
    EasyMock.replay(authorityService);
    authorityController.getAvailableServices(lsid);
}
Also used : LSIDServerException(com.ibm.lsid.server.LSIDServerException) Test(org.junit.Test)

Example 3 with LSIDServerException

use of com.ibm.lsid.server.LSIDServerException in project cdmlib by cybertaxonomy.

the class DataControllerTest method testGetDataWithUnknownLSID.

@Test(expected = LSIDServerException.class)
public void testGetDataWithUnknownLSID() throws Exception {
    ;
    LSIDServerException lse = new LSIDServerException(LSIDException.UNKNOWN_LSID, "Unknown LSID");
    EasyMock.expect(dataService.getData(LSIDMatchers.eqLSID(lsid))).andThrow(lse);
    EasyMock.replay(dataService);
    dataController.setLsidDataService(dataService);
    dataController.getData(lsid, response);
}
Also used : LSIDServerException(com.ibm.lsid.server.LSIDServerException) Test(org.junit.Test)

Example 4 with LSIDServerException

use of com.ibm.lsid.server.LSIDServerException in project cdmlib by cybertaxonomy.

the class MetadataController method getMetadata.

/**
 * Handle requests for the metadata representation of an object with a given lsid. Will return metadata in any format supported
 * from a list of formats if specified.
 *
 * @param lsid the lsid to get metadata for
 * @param formats a comma separated list of acceptable formats to the client
 * @return ModelAndView containing the metadata response as an object with key 'metadataResponse', view name 'Metadata.rdf'
 * @throws LSIDServerException
 */
@RequestMapping(value = "/authority/metadata.do", params = "lsid", method = RequestMethod.GET)
public ModelAndView getMetadata(@RequestParam("lsid") LSID lsid, @RequestParam(value = "acceptedFormats", required = false) String formats) throws LSIDServerException {
    String[] acceptedFormats = null;
    if (formats != null) {
        StringTokenizer st = new StringTokenizer(formats, ",", false);
        Vector<String> v = new Vector<String>();
        while (st.hasMoreTokens()) {
            v.add(st.nextToken());
        }
        acceptedFormats = new String[v.size()];
        v.toArray(acceptedFormats);
    }
    if (acceptedFormats != null) {
        boolean found = false;
        for (int i = 0; i < acceptedFormats.length; i++) {
            if (acceptedFormats[i].equals(MetadataResponse.RDF_FORMAT)) {
                found = true;
            }
            break;
        }
        if (!found) {
            throw new LSIDServerException(LSIDServerException.NO_METADATA_AVAILABLE_FOR_FORMATS, "No metadata found for given format");
        }
    }
    IIdentifiableEntity identifiableEntity = lsidMetadataService.getMetadata(lsid);
    ModelAndView modelAndView = new ModelAndView("Metadata.rdf");
    modelAndView.addObject(identifiableEntity);
    return modelAndView;
}
Also used : StringTokenizer(java.util.StringTokenizer) ModelAndView(org.springframework.web.servlet.ModelAndView) LSIDServerException(com.ibm.lsid.server.LSIDServerException) Vector(java.util.Vector) IIdentifiableEntity(eu.etaxonomy.cdm.model.common.IIdentifiableEntity) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with LSIDServerException

use of com.ibm.lsid.server.LSIDServerException in project cdmlib by cybertaxonomy.

the class AuthorityControllerTest method testRevokeForeignAuthority.

@Test(expected = LSIDServerException.class)
public void testRevokeForeignAuthority() throws Exception {
    LSIDServerException lse = new LSIDServerException(LSIDException.METHOD_NOT_IMPLEMENTED, "FAN service not available");
    authorityService.revokeNotificationForeignAuthority(LSIDMatchers.eqLSID(lsid), LSIDMatchers.eqLSIDAuthority(lsidAuthority));
    EasyMock.expectLastCall().andThrow(lse);
    EasyMock.replay(authorityService);
    authorityController.revokeNotificationForeignAuthority(lsid, lsidAuthority);
}
Also used : LSIDServerException(com.ibm.lsid.server.LSIDServerException) Test(org.junit.Test)

Aggregations

LSIDServerException (com.ibm.lsid.server.LSIDServerException)8 Test (org.junit.Test)5 LSIDException (com.ibm.lsid.LSIDException)2 IIdentifiableEntity (eu.etaxonomy.cdm.model.common.IIdentifiableEntity)2 ExpiringResponse (com.ibm.lsid.ExpiringResponse)1 HTTPLocation (com.ibm.lsid.wsdl.HTTPLocation)1 LSIDWSDLWrapper (eu.etaxonomy.cdm.api.service.lsid.LSIDWSDLWrapper)1 LSID (eu.etaxonomy.cdm.model.common.LSID)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 StringTokenizer (java.util.StringTokenizer)1 Vector (java.util.Vector)1 WSDLException (javax.wsdl.WSDLException)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1