Package uk.ac.osswatch.simal.rest

Examples of uk.ac.osswatch.simal.rest.SimalAPIException


   */
  public String execute() throws SimalAPIException {
    if (command.isGetColleagues()) {
      return getAllColleagues(command);
    } else {
      throw new SimalAPIException("Unkown command: " + command);
    }
  }
View Full Code Here


    HttpClient client = new HttpClient();
    HttpMethod method = new GetMethod(reqURI);
    try {
      client.executeMethod(method);
    } catch (HttpException e) {
      throw new SimalAPIException(
          "Unable to retrieve data from the MyExperiment instance "
              + getBaseURI(), e);
    } catch (IOException e) {
      throw new SimalAPIException(
          "Unable to retrieve data from the MyExperiment instance "
              + getBaseURI(), e);
    }

    StringWriter out;
    try {
      InputSource in = new InputSource(new StringReader(new String(method
          .getResponseBody())));
      DocumentBuilderFactory docBuildFactory = DocumentBuilderFactory
          .newInstance();
      DocumentBuilder parser = docBuildFactory.newDocumentBuilder();
      Document document = parser.parse(in);

      TransformerFactory xformFactory = TransformerFactory.newInstance();
      StreamSource xslt = new StreamSource(PersonAPI.class
          .getResourceAsStream("myExperiment-to-shindig.xsl"));
      Transformer transformer = xformFactory.newTransformer(xslt);
      DOMSource source = new DOMSource(document);
      out = new StringWriter();
      StreamResult scrResult = new StreamResult(out);
      transformer.transform(source, scrResult);
    } catch (IOException e) {
      throw new SimalAPIException(
          "Unable to read the response from the MyExperiment instance "
              + reqURI, e);
    } catch (ParserConfigurationException e) {
      throw new SimalAPIException("Unable to create an XML parser", e);
    } catch (SAXException e) {
      throw new SimalAPIException(
          "Unable to parse the response from the MyExperiment instance "
              + reqURI, e);
    } catch (TransformerConfigurationException e) {
      throw new SimalAPIException("Unable to create an XSLT transformer", e);
    } catch (TransformerException e) {
      throw new SimalAPIException(
          "Unable to transform the response from the MyExperiment instance "
              + reqURI, e);
    }

    return out.toString();
View Full Code Here

    IAPIHandler handler = null;
    if (command.isPersonCommand()) {
      try {
        handler = new PersonAPI(command);
      } catch (SimalRepositoryException e) {
        throw new SimalAPIException("Unable to create API handler", e);
      }
    }

    if (handler == null) {
      throw new SimalAPIException("Unable to create API Handler for command ("
          + command + "}");
    }

    return handler;
View Full Code Here

TOP

Related Classes of uk.ac.osswatch.simal.rest.SimalAPIException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.