/** * Gets the option from the entries list that matches the package last. If no entry match, it returns * {@link org.apache.jackrabbit.vault.packaging.SubPackageHandling.Option#INSTALL} * @param id the package id to match * @return the option. */ public Option getOption(PackageId id) { Option opt = null; for (Entry e: entries) { if (!"*".equals(e.groupName) && !id.getGroup().equals(e.groupName)) { continue; } if (!"*".equals(e.packageName) && !id.getName().equals(e.packageName)) { continue; } opt = e.option; } return opt == null ? Option.INSTALL : opt; }
/** * Checks if the given package id matches this dependency specification. * @param id the package id * @return {@code true} if matches */ public boolean matches(@Nonnull PackageId id) { return groupId.equals(id.getGroup()) && name.equals(id.getName()) && range.isInRange(id.getVersion()); }
/** * Returns the relative path of this package. please note that since 2.3 this also * includes the version, but never the extension (.zip). * * @param id the package id * @return the relative path of this package * @since 2.2 */ public String getRelativeInstallationPath(PackageId id) { StringBuilder b = new StringBuilder("/"); if (id.getGroup().length() > 0) { b.append(id.getGroup()); b.append("/"); } b.append(id.getName()); String v = id.getVersion().toString(); if (v.length() > 0) { b.append("-").append(v); } return b.toString(); }
/** * Creates a new dependency to the specified package id * @param id package id. */ public Dependency(@Nonnull PackageId id) { this(id.getGroup(), id.getName(), new VersionRange(id.getVersion())); }
/** * {@inheritDoc} * * Compares this id with the given one. */ public int compareTo(PackageId o) { int comp = group.compareTo(o.getGroup()); if (comp != 0) { return comp; } comp = name.compareTo(o.getName()); if (comp != 0) { return comp; } return version.compareTo(o.getVersion()); }
public static PackId createPackId(final String group, final String name, final String version) { if (group != null && group.length() > 1 && name != null && name.length() > 1) { PackageId _id = new PackageId(group, name, version != null ? version : ""); return new PackId(_id.getGroup(), _id.getName(), _id.getVersionString(), _id.getInstallationPath()); } else { return null; } }
public static PackId identifyProperties(final Properties props) { String group = props.getProperty(PROP_GROUP); String name = props.getProperty(PROP_NAME); String version = props.getProperty(PROP_VERSION); PackId id = createPackId(group, name, version); if (id != null) { return id; } else { String path = props.getProperty(PROP_PATH); if (path != null && path.startsWith(PackageId.ETC_PACKAGES_PREFIX)) { PackageId _id = new PackageId(path); return new PackId(_id.getGroup(), _id.getName(), _id.getVersionString(), _id.getInstallationPath()); } else { return null; } } }
return new PackId(_id.getGroup(), _id.getName(), _id.getVersionString(), _id.getInstallationPath()); } else { return id;
JcrPackageDefinitionImpl def = new JcrPackageDefinitionImpl(defNode); def.set(JcrPackageDefinition.PN_NAME, pid.getName(), false); def.set(JcrPackageDefinition.PN_GROUP, pid.getGroup(), false); def.set(JcrPackageDefinition.PN_VERSION, pid.getVersionString(), false); def.touch(null, false);
/** * Returns the snapshot id of this package. * @return the snapshot package id * @throws RepositoryException if an error occurs */ private PackageId getSnapshotId() throws RepositoryException { PackageId id = getDefinition().getId(); String group = id.getGroup(); if (group.length() == 0) { group = ".snapshot"; } else { group += "/.snapshot"; } return new PackageId( group, id.getName(), id.getVersion()); }
/** * Writes the properties derived from the package id to the content * @param id the package id * @param autoSave if {@code true} the changes are saved automatically. */ public void setId(PackageId id, boolean autoSave) { set(PN_GROUP, id.getGroup(), false); set(PN_NAME, id.getName(), false); set(PN_VERSION, id.getVersionString(), false); }
JcrPackageDefinition def = new JcrPackageDefinitionImpl(defNode); def.set(JcrPackageDefinition.PN_NAME, pid.getName(), false); def.set(JcrPackageDefinition.PN_GROUP, pid.getGroup(), false); def.set(JcrPackageDefinition.PN_VERSION, pid.getVersionString(), false); def.touch(null, false);
/** * 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; }
PackageId id = def.getId(); PackageId newId = new PackageId( group == null ? id.getGroup() : group, name == null ? id.getName() : name, version == null ? id.getVersion() : Version.create(version)
List<JcrPackage> listPackages = pkgMgr.listPackages(pId.getGroup(), true);
/** * Load the given properties from the content * @param props the properties to load */ private void loadProperties(Properties props) { PackageId id = getId(); setProperty(props, VaultPackage.NAME_VERSION, id.getVersionString()); setProperty(props, VaultPackage.NAME_NAME, id.getName()); setProperty(props, VaultPackage.NAME_GROUP, id.getGroup()); setProperty(props, VaultPackage.NAME_BUILD_COUNT, get(PN_BUILD_COUNT)); setProperty(props, VaultPackage.NAME_DESCRIPTION, get(PN_DESCRIPTION)); setProperty(props, VaultPackage.NAME_REQUIRES_ROOT, get(PN_REQUIRES_ROOT)); setProperty(props, VaultPackage.NAME_REQUIRES_RESTART, get(PN_REQUIRES_RESTART)); setProperty(props, VaultPackage.NAME_LAST_MODIFIED, getCalendar(PN_LASTMODIFIED)); setProperty(props, VaultPackage.NAME_LAST_MODIFIED_BY, get(PN_LASTMODIFIED_BY)); setProperty(props, VaultPackage.NAME_LAST_WRAPPED, getCalendar(PN_LAST_WRAPPED)); setProperty(props, VaultPackage.NAME_LAST_WRAPPED_BY, get(PN_LAST_WRAPPED_BY)); setProperty(props, VaultPackage.NAME_CREATED, getCalendar(PN_CREATED)); setProperty(props, VaultPackage.NAME_CREATED_BY, get(PN_CREATED_BY)); setProperty(props, VaultPackage.NAME_DEPENDENCIES, Dependency.toString(getDependencies())); setProperty(props, VaultPackage.NAME_AC_HANDLING, get(PN_AC_HANDLING)); setProperty(props, VaultPackage.NAME_CND_PATTERN, get(PN_CND_PATTERN)); }