/** * Returns an array of package id from strings * @param str the strings * @return the array of package ids */ public static PackageId[] fromString(String ... str) { PackageId[] ret = new PackageId[str.length]; for (int i=0; i<str.length; i++) { ret[i] = PackageId.fromString(str[i]); } return ret; }
private static PackageId readPackageId(Element child) { return PackageId.fromString(child.getAttribute(ATTR_PACKAGE_ID)); }
/** * Returns the list of sub packages set on the definition node via the {@link #PN_SUB_PACKAGES} property. * @return the list of sub package ids * @throws RepositoryException if an error occurs. */ List<PackageId> getSubPackages() throws RepositoryException { LinkedList<PackageId> subPackages = new LinkedList<>(); if (defNode.hasProperty(PN_SUB_PACKAGES)) { Value[] subIds = defNode.getProperty(PN_SUB_PACKAGES).getValues(); for (Value v : subIds) { // reverse installation order subPackages.add(PackageId.fromString(v.getString())); } } return subPackages; }
private static Violation violationFromJSON(JSONObject jsonViolation) { String vSeverity = jsonViolation.optString(KEY_SEVERITY, Violation.Severity.MINOR.name()); Violation.Severity severity = Violation.Severity.valueOf(vSeverity); String description = jsonViolation.optString(KEY_DESCRIPTION, ""); List<PackageId> packages = new ArrayList<>(); JSONArray vPackages = jsonViolation.optJSONArray(KEY_PACKAGES); if (vPackages != null) { packages = StreamSupport.stream(vPackages.spliterator(), false) .map(v -> Optional.ofNullable(PackageId.fromString(String.valueOf(v)))) .filter(Optional::isPresent).map(Optional::get) .collect(Collectors.toList()); } return new SimpleViolation(severity, description, packages); }
private void readTask(Element elem) throws IOException { PackageTask.Type type = PackageTask.Type.valueOf(elem.getAttribute(ATTR_CMD).toUpperCase()); PackageId id = PackageId.fromString(elem.getAttribute(ATTR_PACKAGE_ID)); addTask().with(id).with(type); }
final File downloadDir = new File(project.getBuildDir() + "/tmp"); downloadDir.mkdirs(); final SuccessOrFailure<RuntimePackageProperties> packageInfoSF = RuntimePackageProperties.packageProperties(slingPackageSupport, PackageId.fromString(getPackageName())); if (packageInfoSF.failed()) throw new IllegalStateException("Could not get package information: " + packageInfoSF.getError());
return new FSInstallState(PackageId.fromString(packageId), status) .withFilePath(filePath) .withExternal(external)
/** * Parses a options string as described above and returns a new SubPackageHandling instance. * @param str the string to parse * @return the configuration or {@code null} if the string is malformed. */ public static SubPackageHandling fromString(String str) { if (str == null || str.isEmpty()) { return SubPackageHandling.DEFAULT; } SubPackageHandling sp = new SubPackageHandling(); for (String instruction: Text.explode(str, ',')) { String[] opts = Text.explode(instruction.trim(), ';'); if (opts.length > 0) { PackageId id = PackageId.fromString(opts[0]); Option opt = Option.INSTALL; if (opts.length > 1) { try { opt = Option.valueOf(opts[1].toUpperCase()); } catch (IllegalArgumentException e) { // ignore } } sp.getEntries().add(new Entry(id.getGroup(), id.getName(), opt)); } } return sp; }
/** * Calls {@link CqPackageHelper#uninstallAllBundles(List, SlingSupport, UninstallBundlePredicate)} for * each server in {@link SlingServersConfiguration} and all the bundles in the package file downloaded from * that server * * @return the "aggregate" HTTP response: if all the calls are in the >= 200 and <400 range, or a * 404 (not installed) or a 408 (timeout, server not running) the returns an empty HTTP_OK; * otherwise returns the first error response it came across */ public HttpResponse uninstallBundles(final UninstallBundlePredicate bundlePredicate) { return doAcrossServers(true, slingSupport -> { final SlingServerConfiguration serverConf = slingSupport.getServerConf(); PackageServerConfiguration packageServerConfiguration = new PackageServerConfiguration(serverConf); SlingPackageSupport slingPackageSupport = new SlingPackageSupport(packageServerConfiguration, slingSupport); SuccessOrFailure<RuntimePackageProperties> packageInfo = RuntimePackageProperties.packageProperties(slingPackageSupport, PackageId.fromString(getPackageName())); if (packageInfo.succeeded()) { // package is installed try { List<String> namesFromDownloadedPackage = symbolicNamesFromDownloadedPackage(slingPackageSupport); return uninstallAllBundles(namesFromDownloadedPackage, slingSupport, bundlePredicate); } catch (URISyntaxException | IOException e) { throw new IllegalStateException("Problem getting symbolic names from " + packageInfo.getValue().getDownloadName(), e); } } else { LOG.info(getPackageName() + " is not on " + serverConf.getName()); return new HttpResponse(HTTP_OK, ""); } }); }