コード例 #1
0
 protected Map<String, PackageDefinition> getDistributionDefinitions(List<String> md5Filenames) {
   Map<String, PackageDefinition> allDefinitions = new HashMap<String, PackageDefinition>();
   if (md5Filenames == null) {
     return allDefinitions;
   }
   for (String md5Filename : md5Filenames) {
     File md5File = new File(distributionMPDir, md5Filename);
     if (!md5File.exists()) {
       // distribution file has been deleted
       continue;
     }
     ZipFile zipFile;
     try {
       zipFile = new ZipFile(md5File);
     } catch (ZipException e) {
       log.warn("Unzip error reading file " + md5File, e);
       continue;
     } catch (IOException e) {
       log.warn("Could not read file " + md5File, e);
       continue;
     }
     try {
       ZipEntry zipEntry = zipFile.getEntry("package.xml");
       InputStream in = zipFile.getInputStream(zipEntry);
       PackageDefinition pd = NuxeoConnectClient.getPackageUpdateService().loadPackage(in);
       allDefinitions.put(md5Filename, pd);
     } catch (Exception e) {
       log.error("Could not read package description", e);
       continue;
     } finally {
       try {
         zipFile.close();
       } catch (IOException e) {
         log.warn("Unexpected error closing file " + md5File, e);
       }
     }
   }
   return allDefinitions;
 }
コード例 #2
0
  // Wrap connect client services as Nuxeo Services
  public <T> T getAdapter(Class<T> adapter) {

    if (adapter.getCanonicalName().equals(ConnectConnector.class.getCanonicalName())) {
      return adapter.cast(NuxeoConnectClient.getConnectConnector());
    }

    if (adapter.getCanonicalName().equals(ConnectRegistrationService.class.getCanonicalName())) {
      return adapter.cast(NuxeoConnectClient.getConnectRegistrationService());
    }

    if (adapter.getCanonicalName().equals(ConnectDownloadManager.class.getCanonicalName())) {
      return adapter.cast(NuxeoConnectClient.getDownloadManager());
    }

    if (adapter.getCanonicalName().equals(PackageManager.class.getCanonicalName())) {
      return adapter.cast(NuxeoConnectClient.getPackageManager());
    }

    if (adapter.getCanonicalName().equals(PackageUpdateService.class.getCanonicalName())) {
      return adapter.cast(NuxeoConnectClient.getPackageUpdateService());
    }

    return adapter.cast(this);
  }