예제 #1
0
파일: ObrUpdate.java 프로젝트: CHATTG1/sofa
  private String relativisePath(URI uri) {
    if (null != uri) {
      if (m_userConfig.isPathRelative()) {
        return ObrUtils.getRelativeURI(m_baseURI, uri).toASCIIString();
      }

      return uri.toASCIIString();
    }

    return null;
  }
예제 #2
0
파일: ObrUpdate.java 프로젝트: CHATTG1/sofa
  /**
   * update the repository descriptor file. parse the old repository descriptor file, get the old
   * reference of the bundle or determine the id for a new bundle, extract information from bindex
   * set the new information in descriptor file and save it.
   *
   * @param bundleJar path to the bundle jar file
   * @param sourceJar path to the source jar file
   * @param docJar path to the docs jar file
   * @throws MojoExecutionException if the plugin failed
   */
  public void updateRepository(URI bundleJar, URI sourceJar, URI docJar)
      throws MojoExecutionException {
    m_logger.debug(" (f) repositoryXml = " + m_repositoryXml);
    m_logger.debug(" (f) bundleJar = " + bundleJar);
    m_logger.debug(" (f) sourceJar = " + sourceJar);
    m_logger.debug(" (f) docJar = " + docJar);
    m_logger.debug(" (f) obrXml = " + m_obrXml);

    if (m_repository == null) {
      return;
    }

    // get the file size
    File bundleFile = new File(bundleJar);
    if (!bundleFile.exists()) {
      String snapshot = TIMESTAMP.matcher(bundleFile.getName()).replaceFirst("-SNAPSHOT");
      bundleFile = new File(bundleFile.getParentFile(), snapshot);
    }
    if (bundleFile.exists()) {
      URI resourceURI = m_userConfig.getRemoteBundle();
      if (null == resourceURI) {
        resourceURI = bundleJar;
        if (m_userConfig.isPathRelative()) {
          resourceURI = ObrUtils.getRelativeURI(m_baseURI, resourceURI);
        }
      }

      if (m_userConfig.isRemoteFile()) {
        m_logger.info("Deploying " + resourceURI);
      } else {
        m_logger.info("Installing " + resourceURI);
      }

      try {
        m_resourceBundle =
            (ResourceImpl) new DataModelHelperImpl().createResource(bundleFile.toURI().toURL());
        if (m_resourceBundle == null) {
          return;
        }
      } catch (IOException e) {
        throw new MojoExecutionException("Unable to load resource information", e);
      }

      m_resourceBundle.put(Resource.SIZE, String.valueOf(bundleFile.length()));
      m_resourceBundle.put(Resource.URI, resourceURI.toASCIIString());
    } else {
      m_logger.error("file doesn't exist: " + bundleJar);
      return;
    }

    // parse the obr.xml file
    if (m_obrXml != null) {
      m_logger.info("Adding " + m_obrXml);

      // URL url = getClass().getResource("/SchemaObr.xsd");
      // TODO validate obr.xml file

      // add contents to resource bundle
      parseObrXml();
    }

    String sourcePath = relativisePath(sourceJar);
    String docPath = relativisePath(docJar);

    //        m_resourceBundle.construct( m_project, bindexExtractor, sourcePath, docPath );
    //         TODO: rebuild wrt m_project

    m_repository.addResource(m_resourceBundle);
    m_repository.setLastModified(System.currentTimeMillis());
  }