public JcrRegisteredPackage(JcrPackage pkg) throws IOException, RepositoryException { this.pkg = pkg; this.vltPkg = pkg.getPackage(); }
@Nonnull @Override public PackageId register(@Nonnull InputStream in, boolean replace) throws IOException, PackageExistsException { try (JcrPackage pkg = upload(in, replace)){ //noinspection resource return pkg.getPackage().getId(); } catch (RepositoryException e) { throw new IOException(e); } }
@Override protected Properties getPropertiesMap() { try { return pkg.getPackage().getMetaInf().getProperties(); } catch (RepositoryException|IOException e) { throw new IllegalStateException(e); } }
@Nonnull @Override public PackageId register(@Nonnull File file, boolean replace) throws IOException, PackageExistsException { ZipVaultPackage pack = new ZipVaultPackage(file, false, true); try (JcrPackage pkg = upload(pack, replace)) { //noinspection resource return pkg.getPackage().getId(); } catch (RepositoryException e) { throw new IOException(e); } }
/** * Gets the last build time of the package. * * @param jcrPackage the package obj * @return the package's last build time or null if none can be found * @throws RepositoryException */ private Calendar getJcrPackageLastModified(final JcrPackage jcrPackage) throws RepositoryException, IOException { if (ReplicatedAt.CURRENT_TIME.equals(this.replicatedAt)) { return Calendar.getInstance(); } else { return jcrPackage.getPackage().getCreated(); } }
/** * Get a JSONObject from the JCR package configured for the Angular model. * * @param jcrPackage The JCR Package to retrieve data from. * @return the JSON Object configured for the Angular model. * @throws JSONException * @throws RepositoryException * @throws IOException */ private JSONObject getJsonFromJcrPackage(final JcrPackage jcrPackage) throws JSONException, RepositoryException, IOException { final JSONObject json = new JSONObject(); final SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT); json.put(JSON_SIZE_PROPERTY, getSize(jcrPackage.getPackage().getSize())); json.put(JSON_DATE_PROPERTY, dateFormat.format(jcrPackage.getPackage().getCreated().getTime())); json.put(JSON_NAME_PROPERTY, jcrPackage.getDefinition().getId().getName()); json.put(JSON_PATH_PROPERTY, jcrPackage.getNode().getPath()); json.put(JSON_ID_PROPERTY, jcrPackage.getDefinition().getId().toString()); return json; }
private void processPackageFile(Session admin, JcrPackageManager manager, final File file, final boolean preInstall) throws AbortedScanException { JcrPackage jcrPackage = null; try { jcrPackage = manager.upload(file, false, true, null, true); final PackageId packageId = jcrPackage.getPackage().getId(); if (!preInstall) { progressChecks.forEach(handler -> { try { handler.identifyPackage(packageId, file); } catch (Exception e) { getErrorListener().onListenerException(e, handler, packageId); } }); } processPackage(admin, manager, jcrPackage, preInstall); } catch (IOException | PackageException | RepositoryException e) { throw new AbortedScanException(e, file); } finally { if (jcrPackage != null) { jcrPackage.close(); } } }
private void processPackage(Session admin, JcrPackageManager manager, JcrPackage jcrPackage, final boolean preInstall) throws IOException, PackageException, RepositoryException { final PackageId packageId = jcrPackage.getPackage().getId(); final Session inspectSession = SessionFacade.findBestWrapper(admin, false); final ProgressTrackerListener tracker = final VaultPackage vaultPackage = jcrPackage.getPackage(); if (!vaultPackage.isValid()) { throw new PackageException("Package is not valid: " + packageId);