Package uk.ac.osswatch.simal.rdf

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


        entityID = entityID + 1;
      }
    }
   
    if(!validID) {
      throw new SimalRepositoryException("Could not find available ID for property " + propertyName);
    }

    long newId = entityID + 1;
    SimalProperties.setProperty(propertyName, Long
            .toString(newId));
    try {
      SimalProperties.save();
    } catch (Exception e) {
      LOGGER.warn("Unable to save properties file", e);
      throw new SimalRepositoryException(
          "Unable to save properties file when creating the next category ID",
          e);
    }
    return fullID;
  }
View Full Code Here


  }

  public IDocument create(String uri) throws SimalRepositoryException,
      DuplicateURIException {
    if (uri == null || uri.length() == 0) {
      throw new SimalRepositoryException("URI cannot be blank or null");
    }
    Model model = getModel();
    if (SimalRepositoryFactory.getInstance().containsResource(uri)) {
      throw new DuplicateURIException(
          "Attempt to create a second homepage with the URI " + uri);
View Full Code Here

          }
        }
      } catch (QueryException e) {
        String message = "QueryException when trying to SPARQLquery projects with query: " + queryStr;
        LOGGER.warn(message + "; message: " + e.getMessage());
        throw new SimalRepositoryException(message, e);
      } finally {
        if (qe != null) {
          qe.close();
        }
      }
View Full Code Here

            Long.toString(newId));
        try {
          SimalProperties.save();
        } catch (Exception e) {
          LOGGER.warn("Unable to save properties file", e);
          throw new SimalRepositoryException(
              "Unable to save properties file when creating the next project ID", e);
        }
        LOGGER.debug("Generated new project ID {}", fullID);
        return fullID;
      }
View Full Code Here

    public IProject createProject(Document sourceXml)
        throws SimalRepositoryException {
      // Strip any extra XML, such as Atom feed data or web services response
      // data
      if (sourceXml == null) {
        throw new SimalRepositoryException("Supplied RDF/XML document is null.");
      }
     
      IProject newProject = null;
      NodeList projects = sourceXml.getElementsByTagNameNS(RDFUtils.DOAP_NS,
          "Project");

      if (projects.getLength() == 0) {
        throw new SimalRepositoryException("No projects in the supplied RDF/XML document");

        // FIXME when multiple projects are in the document, only the last created Project is returned.
        //      } else if (projects.getLength() > 1) {
        //        throw new SimalRepositoryException("Too many projects in the supplied RDF/XML document");
      } else {
View Full Code Here

    }

    try {
      cleanProjectXml(sourceProjectRoot);
    } catch (UnsupportedEncodingException e) {
      throw new SimalRepositoryException(
          "Unable to encode URIs for blank nodes", e);
    }

    String uri = sourceProjectRoot.getAttributeNS(RDFUtils.RDF_NS, "about");
    IProject project = findOrCreateProject(sourceProjectRoot, uri);

    generateRelatedEntities(sourceProjectRoot, project);

    /**
     * record any new seeAlsos against the project
     */
    NodeList seeAlsos = sourceProjectRoot.getElementsByTagNameNS(
        RDFUtils.RDFS_NS, RDFS.seeAlso.getLocalName());
    for (int i = 0; i < seeAlsos.getLength(); i = i + 1) {
      Element seeAlso = (Element) seeAlsos.item(i);
      if (seeAlso.getParentNode().equals(sourceProjectRoot)) {
        String seeAlsoUri = seeAlso.getAttributeNS(RDFUtils.RDF_NS, "resource")
            .trim();
        try {
          project.addSeeAlso(new URI(seeAlsoUri));
        } catch (URISyntaxException e) {
          throw new SimalRepositoryException(
              "Unable to add see also to simal:Project", e);
        }
      }
    }

    // add the source RDF
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    DocumentBuilder db;
    try {
      db = dbf.newDocumentBuilder();
    } catch (ParserConfigurationException e) {
      throw new SimalRepositoryException("Unable to create document builder", e);
    }
    Document sourceDoc = db.newDocument();
    Node root = sourceDoc.createElementNS(RDFUtils.RDF_NS, "RDF");
    root.appendChild(sourceDoc.importNode(sourceProjectRoot, true));
    sourceDoc.appendChild(root);
View Full Code Here

      LOGGER.debug("Updating an existing simal:Project instance with URI "
          + project.getURI());
      try {
        project.addSeeAlso(new URI(uri));
      } catch (URISyntaxException e) {
        throw new SimalRepositoryException(
            "Unable to add a seeAlso attribute to an existing object", e);
      }
    }
    return project;
  }
View Full Code Here

      dbf.setNamespaceAware(true);
      DocumentBuilder db;
      try {
        db = dbf.newDocumentBuilder();
      } catch (ParserConfigurationException e) {
        throw new SimalRepositoryException("Unable to create document builder", e);
      }
      Document simalProjectDoc = db.newDocument();
      Node simalProjectRDFRoot = simalProjectDoc.createElementNS(RDFUtils.RDF_NS,
          "RDF");
     
View Full Code Here

   */
  public URL getURL() throws SimalRepositoryException {
    try {
      return new URL(getURI());
    } catch (MalformedURLException e) {
      throw new SimalRepositoryException(
          "Unable to create an URL for resource, this method is deprecated, use getURI() instead",
          e);
    }
  }
View Full Code Here

  public void setSimalID(String id) throws SimalRepositoryException {
    if (id.contains(":")
        && !id.startsWith(SimalProperties
            .getProperty((SimalProperties.PROPERTY_SIMAL_INSTANCE_ID)))) {
      throw new SimalRepositoryException("Simal ID cannot contain a ':'");
    }
    logger.info("Setting simalId for " + this + " to " + id);
    getJenaResource().addLiteral(SimalOntology.CATEGORY_ID, id);
  }
View Full Code Here

TOP

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

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.