Esempio n. 1
0
  public static byte[] createZippedRepository0(IModule module)
      throws IOException, URISyntaxException {
    File tempDir =
        new File(
            System.getProperty("java.io.tmpdir"),
            module.getName() + "_" + new java.util.Random().nextInt());
    ByteArrayOutputStream baos = null;
    ZipOutputStream zos = null;
    try {
      IPublisherInfo info = createPublisherInfo(tempDir);
      IPublisherAction[] actions = createActions(module);
      Publisher publisher = new Publisher(info);
      publisher.publish(actions, new NullProgressMonitor());

      baos = new ByteArrayOutputStream();
      zos = new ZipOutputStream(baos);
      addFolder(tempDir, zos);
    } finally {
      if (zos != null) {
        try {
          zos.close();
        } catch (IOException e) {
        }
      }
      if (baos != null) {
        try {
          baos.close();
        } catch (IOException e) {
        }
      }
    }
    tempDir.delete();
    return baos.toByteArray();
  }
Esempio n. 2
0
 /*
  * Check to see if an existing repository already has the "compressed" flag set
  */
 protected void initializeRepositories(PublisherInfo publisherInfo) throws ProvisionException {
   try {
     if (metadataLocation != null) {
       // Try to load the metadata repository. If it loads, check the "compressed" flag, and cache
       // it.
       // If there are any errors loading it (i.e. it doesn't exist), just skip this step
       // If there are serious problems with the repository, the superclass initializeRepositories
       // method
       // will handle it.
       IMetadataRepository result =
           Publisher.loadMetadataRepository(agent, metadataLocation, true, true);
       if (result != null) {
         Object property = result.getProperties().get(IRepository.PROP_COMPRESSED);
         if (property != null) {
           boolean compressProperty = Boolean.valueOf((String) property);
           this.compress = compressProperty || compress;
         }
       }
     }
   } catch (ProvisionException e) {
     // do nothing
   }
   super.initializeRepositories(publisherInfo);
 }