Package uk.ac.osswatch.simal.rdf

Examples of uk.ac.osswatch.simal.rdf.SimalException


    dbf.setNamespaceAware(true);
    DocumentBuilder db;
    try {
      db = dbf.newDocumentBuilder();
    } catch (ParserConfigurationException e) {
      throw new SimalException("Unable to create new RDF/XML document", e);
    }
    Document resultDoc = db.newDocument();
    Element root = resultDoc.createElementNS(RDFUtils.RDF_NS, "RDF");
    Iterator<URI> pings = getListOfPings(export).iterator();
    Document projectDoc;
View Full Code Here


      FileWriter fw = null;
      try {
        fw = new FileWriter(tmpFile);
        fw.write(writer.toString());
      } catch (IOException e) {
        throw new SimalException(
            "Unable to write PTSW export file to temporary space");
      } finally {
        if (fw != null) {
          try {
            fw.close();
View Full Code Here

      if (newProject != null) {
        PageParameters newProjectPageParams = new PageParameters();
        newProjectPageParams.add("simalID", newProject.getSimalID());
        setResponsePage(ProjectDetailPage.class, newProjectPageParams);
      } else {
        throw new SimalException(
            "Failed to created new project based on submitted DOAP.");
      }
    } catch (SimalException e) {
      if (e.getCause().getClass() == IOException.class ||
          e.getCause().getClass() == SAXParseException.class) {
View Full Code Here

      logger.debug("Written file to " + backupFile.getAbsolutePath());
    } catch (IOException e) {
      String msg = "Could not write file to " + backupFileName + "; "
          + e.getMessage();
      logger.warn(msg);
      throw new SimalException(msg, e);
    }
  }
View Full Code Here

    StringWriter writer = new StringWriter();
    XMLSerializer serial = new XMLSerializer(writer, format);
    try {
      serial.serialize(pings);
    } catch (IOException e) {
      throw new SimalException("Unable to serialize PTSW response");
    }
    logger.info("Updated DOAP documents:\n");
    logger.info(writer.toString());

    File tmpFile = new File(System.getProperty("java.io.tmpdir")
        + File.separator + "PTSWExport.xml");
    FileWriter fw = null;
    try {
      fw = new FileWriter(tmpFile);
      fw.write(writer.toString());
    } catch (IOException e) {
      throw new SimalException(
          "Unable to write PTSW export file to temporary space");
    } finally {
      if (fw != null) {
        try {
          fw.close();
        } catch (IOException e) {
          throw new RuntimeException("Attempt to close a file writer failed", e);
        }
      }
    }

    try {
      repository.addProject(tmpFile.toURI().toURL(), tmpFile.toURI().toURL()
          .toExternalForm());
    } catch (MalformedURLException e) {
      throw new SimalException("Unable to add projects from PTSW Export", e);
    }
  }
View Full Code Here

    try {
      if (selectedCategory != null) {
        getUpdatePanel().addToDisplayList(selectedCategory);
        getUpdatePanel().addToModel(selectedCategory);
      } else {
        throw new SimalException("No valid selected category.");
      }
    } catch (SimalException e) {
      UserReportableException error = new UserReportableException(
          "Unable to generate a category from the given form data",
          ProjectDetailPage.class, e);
View Full Code Here

    if (category != null) {
      add(new CategorySummaryPanel("summary", category));
      add(new ProjectListPanel("projectList", category.getProjects(), 15));
      add(new PersonListPanel("peopleList", "People working in this category", category.getPeople(), 15));
    } else {
      throw new SimalException("Cannot populate page with null category.");
    }
  }
View Full Code Here

      data.append("&");
      data.append(URLEncoder.encode("widgetid", "UTF-8"));
      data.append("=");
      data.append(URLEncoder.encode(widget.getIdentifier(), "UTF-8"));
    } catch (UnsupportedEncodingException e) {
      throw new SimalException(
          "UTF-8 encoding must be supported on the server", e);
    }

    URL url;
    WidgetInstance instance;
    OutputStreamWriter wr = null;
    InputStream is = null;

    try {
      url = new URL(getURL() + "/widgetinstances");
      URLConnection conn = url.openConnection();
      conn.setDoOutput(true);
      wr = new OutputStreamWriter(conn.getOutputStream());
      wr.write(data.toString());
      wr.flush();
      conn.setReadTimeout(1000);
      is = conn.getInputStream();

      DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
      DocumentBuilder db = dbf.newDocumentBuilder();
      instance = widget.addInstance(db.parse(is));
    } catch (MalformedURLException e) {
      throw new RuntimeException("URL for supplied Wookie Server is malformed",
          e);
    } catch (ParserConfigurationException e) {
      throw new SimalException("Unable to configure XML parser", e);
    } catch (SAXException e) {
      throw new SimalException("Problem parsing XML from Wookie Server", e);
    } catch (IOException e) {
      throw new SimalException("Problem parsing XML from Wookie Server", e);
    } finally {
      if (wr != null) {
        try {
          wr.close();
        } catch (IOException e) {
View Full Code Here

        identifier = widgetEl.getAttribute("identifier");

        widgets.put(title, new Widget(identifier, title, desc, icon));
      }
    } catch (ParserConfigurationException e) {
      throw new SimalException("Unable to create XML parser", e);
    } catch (MalformedURLException e) {
      throw new SimalException("URL for Wookie is malformed", e);
    } catch (IOException e) {
      // return an empty set, or the set received so far in order to allow
      // the application to proceed. The application should display an
      // appropriate message in this case.
      LOGGER.debug("Error communicating with the widget server. " + e.getMessage());
      throw new SimalException("Wookie server at '" + getURL() + "' not available.", e);
    } catch (SAXException e) {
      throw new SimalException("Unable to parse the response from Wookie", e);
    }
  }
View Full Code Here

  }

  public IPerson getReviewer() throws SimalException {
    List<Statement> reviewers = listProperties(SimalOntology.PERSON);
    if (reviewers.size() == 0) {
      throw new SimalException("No reviewer recorded for review: ");
    } else if (reviewers.size() > 1) {
      throw new SimalException("More than one reviewer recorded for review ");
    }
    IPerson reviewer = new Person(reviewers.get(0).getResource());
    return reviewer;
  }
View Full Code Here

TOP

Related Classes of uk.ac.osswatch.simal.rdf.SimalException

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.