You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by tr...@apache.org on 2017/10/30 07:12:00 UTC
svn commit: r1813728 - in /jackrabbit/commons/filevault/trunk/vault-core/src:
main/java/org/apache/jackrabbit/vault/fs/config/
main/java/org/apache/jackrabbit/vault/packaging/
main/java/org/apache/jackrabbit/vault/packaging/impl/
test/java/org/apache/j...
Author: tripod
Date: Mon Oct 30 07:11:59 2017
New Revision: 1813728
URL: http://svn.apache.org/viewvc?rev=1813728&view=rev
Log:
JCRVLT-170 Introduce the concept of package types
Added:
jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/PackageType.java
jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestPackageTypes.java
jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/packagetype/
jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/packagetype/application-pkg.zip
jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/packagetype/container-pkg.zip
jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/packagetype/content-pkg.zip
jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/packagetype/mixed-pkg.zip
jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/packagetype/notype-pkg.zip
Modified:
jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/config/MetaInf.java
jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/PackageProperties.java
jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/PackagePropertiesImpl.java
Modified: jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/config/MetaInf.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/config/MetaInf.java?rev=1813728&r1=1813727&r2=1813728&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/config/MetaInf.java (original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/config/MetaInf.java Mon Oct 30 07:11:59 2017
@@ -27,6 +27,7 @@ import org.apache.jackrabbit.vault.fs.ap
import org.apache.jackrabbit.vault.fs.api.WorkspaceFilter;
import org.apache.jackrabbit.vault.fs.spi.NodeTypeSet;
import org.apache.jackrabbit.vault.fs.spi.PrivilegeDefinitions;
+import org.apache.jackrabbit.vault.packaging.PackageType;
/**
* Abstracts the way of accessing the vault specific meta-info of a checkout.
Modified: jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/PackageProperties.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/PackageProperties.java?rev=1813728&r1=1813727&r2=1813728&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/PackageProperties.java (original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/PackageProperties.java Mon Oct 30 07:11:59 2017
@@ -19,6 +19,8 @@ package org.apache.jackrabbit.vault.pack
import java.util.Calendar;
+import javax.annotation.Nullable;
+
import org.apache.jackrabbit.vault.fs.api.VaultFsConfig;
import org.apache.jackrabbit.vault.fs.io.AccessControlHandling;
import org.osgi.annotation.versioning.ProviderType;
@@ -137,6 +139,11 @@ public interface PackageProperties {
String NAME_USE_BINARY_REFERENCES = VaultFsConfig.NAME_USE_BINARY_REFERENCES;
/**
+ * Name of the package-type property
+ */
+ String NAME_PACKAGE_TYPE = "packageType";
+
+ /**
* the prefix for an install hook property. eg:
* 'installhook.test1.class = ....'
*/
@@ -233,4 +240,9 @@ public interface PackageProperties {
*/
String getProperty(String name);
+ /**
+ * Returns the package type or {@code null} if not package type was specified for this package.
+ */
+ @Nullable
+ PackageType getPackageType();
}
\ No newline at end of file
Added: jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/PackageType.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/PackageType.java?rev=1813728&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/PackageType.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/PackageType.java Mon Oct 30 07:11:59 2017
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.vault.packaging;
+
+/**
+ * Specifies the type of the package. The package type helps to characterize the contents of a package and influences
+ * how the package is used during deployment, installation and removal.
+ */
+public enum PackageType {
+
+ /**
+ * An application package consists purely of application content. It serializes entire subtrees with no
+ * inclusion or exclusion filters. it does not contain any subpackages nor OSGi configuration or bundles.
+ */
+ APPLICATION,
+
+ /**
+ * A content package consists only of content and user defined configuration. It usually serializes entire subtrees
+ * but can contain inclusion or exclusion filters. it does not contain any subpackages nor OSGi configuration or bundles.
+ */
+ CONTENT,
+
+ /**
+ * A container package only contains sub packages and OSGi configuration and bundles. The container package is only
+ * used as container for deployment.
+ */
+ CONTAINER,
+
+ /**
+ * Catch all type for a combination of the above.
+ */
+ MIXED
+
+}
\ No newline at end of file
Modified: jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/PackagePropertiesImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/PackagePropertiesImpl.java?rev=1813728&r1=1813727&r2=1813728&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/PackagePropertiesImpl.java (original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/PackagePropertiesImpl.java Mon Oct 30 07:11:59 2017
@@ -20,11 +20,14 @@ package org.apache.jackrabbit.vault.pack
import java.util.Calendar;
import java.util.Properties;
+import javax.annotation.Nullable;
+
import org.apache.jackrabbit.util.ISO8601;
import org.apache.jackrabbit.vault.fs.io.AccessControlHandling;
import org.apache.jackrabbit.vault.packaging.Dependency;
import org.apache.jackrabbit.vault.packaging.PackageId;
import org.apache.jackrabbit.vault.packaging.PackageProperties;
+import org.apache.jackrabbit.vault.packaging.PackageType;
import org.apache.jackrabbit.vault.packaging.SubPackageHandling;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -38,6 +41,7 @@ public abstract class PackagePropertiesI
private PackageId id;
+ @Override
public PackageId getId() {
if (id == null) {
String version = getProperty(NAME_VERSION);
@@ -59,6 +63,7 @@ public abstract class PackagePropertiesI
/**
* {@inheritDoc}
*/
+ @Override
public Calendar getLastModified() {
return getDateProperty(NAME_LAST_MODIFIED);
}
@@ -66,6 +71,7 @@ public abstract class PackagePropertiesI
/**
* {@inheritDoc}
*/
+ @Override
public String getLastModifiedBy() {
return getProperty(NAME_LAST_MODIFIED_BY);
}
@@ -73,6 +79,7 @@ public abstract class PackagePropertiesI
/**
* {@inheritDoc}
*/
+ @Override
public Calendar getCreated() {
return getDateProperty(NAME_CREATED);
}
@@ -80,6 +87,7 @@ public abstract class PackagePropertiesI
/**
* {@inheritDoc}
*/
+ @Override
public String getCreatedBy() {
return getProperty(NAME_CREATED_BY);
}
@@ -87,6 +95,7 @@ public abstract class PackagePropertiesI
/**
* {@inheritDoc}
*/
+ @Override
public Calendar getLastWrapped() {
return getDateProperty(NAME_LAST_WRAPPED);
}
@@ -94,6 +103,7 @@ public abstract class PackagePropertiesI
/**
* {@inheritDoc}
*/
+ @Override
public String getLastWrappedBy() {
return getProperty(NAME_LAST_WRAPPED_BY);
}
@@ -101,6 +111,7 @@ public abstract class PackagePropertiesI
/**
* {@inheritDoc}
*/
+ @Override
public String getDescription() {
return getProperty(NAME_DESCRIPTION);
}
@@ -108,6 +119,7 @@ public abstract class PackagePropertiesI
/**
* {@inheritDoc}
*/
+ @Override
public AccessControlHandling getACHandling() {
String ac = getProperty(NAME_AC_HANDLING);
if (ac == null) {
@@ -125,6 +137,7 @@ public abstract class PackagePropertiesI
/**
* {@inheritDoc}
*/
+ @Override
public SubPackageHandling getSubPackageHandling() {
return SubPackageHandling.fromString(getProperty(NAME_SUB_PACKAGE_HANDLING));
}
@@ -132,6 +145,7 @@ public abstract class PackagePropertiesI
/**
* {@inheritDoc}
*/
+ @Override
public boolean requiresRoot() {
return "true".equals(getProperty(NAME_REQUIRES_ROOT));
}
@@ -139,6 +153,7 @@ public abstract class PackagePropertiesI
/**
* {@inheritDoc}
*/
+ @Override
public Dependency[] getDependencies() {
String deps = getProperty(NAME_DEPENDENCIES);
if (deps == null) {
@@ -151,6 +166,7 @@ public abstract class PackagePropertiesI
/**
* {@inheritDoc}
*/
+ @Override
public Calendar getDateProperty(String name) {
try {
String p = getProperty(name);
@@ -166,6 +182,7 @@ public abstract class PackagePropertiesI
/**
* {@inheritDoc}
*/
+ @Override
public String getProperty(String name) {
try {
Properties props = getPropertiesMap();
@@ -175,6 +192,23 @@ public abstract class PackagePropertiesI
}
}
+ /**
+ * {@inheritDoc}
+ */
+ @Nullable
+ @Override
+ public PackageType getPackageType() {
+ final String pt = getProperty(NAME_PACKAGE_TYPE);
+ if (pt != null) {
+ try {
+ return PackageType.valueOf(pt.toUpperCase());
+ } catch (IllegalArgumentException e) {
+ log.warn("invalid package type configured: {}", pt);
+ }
+ }
+ return null;
+ }
+
protected abstract Properties getPropertiesMap();
Added: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestPackageTypes.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestPackageTypes.java?rev=1813728&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestPackageTypes.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestPackageTypes.java Mon Oct 30 07:11:59 2017
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jackrabbit.vault.packaging.integration;
+
+import java.io.IOException;
+
+import org.apache.jackrabbit.vault.packaging.PackageException;
+import org.apache.jackrabbit.vault.packaging.PackageExistsException;
+import org.apache.jackrabbit.vault.packaging.PackageId;
+import org.apache.jackrabbit.vault.packaging.PackageType;
+import org.apache.jackrabbit.vault.packaging.registry.PackageRegistry;
+import org.apache.jackrabbit.vault.packaging.registry.RegisteredPackage;
+import org.apache.jackrabbit.vault.packaging.registry.impl.JcrPackageRegistry;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Test the Package registry interface
+ */
+public class TestPackageTypes extends IntegrationTestBase {
+
+ private PackageRegistry registry;
+
+ @Override
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+
+ registry = new JcrPackageRegistry(admin);
+ }
+
+ private void verifyViaRegistry(String type) throws IOException, PackageExistsException {
+ PackageId id = registry.register(getStream("testpackages/packagetype/" + type + "-pkg.zip"), false);
+ RegisteredPackage pkg = registry.open(id);
+ PackageType result = pkg.getPackage().getProperties().getPackageType();
+ PackageType expected = "notype".equals(type)
+ ? null
+ : PackageType.valueOf(type.toUpperCase());
+ assertEquals("Package type", expected, result);
+ }
+
+ /**
+ * checks if 'application' package type is correct read from package using the registry.
+ */
+ @Test
+ public void test_type_application_via_registry() throws IOException, PackageException {
+ verifyViaRegistry("application");
+ }
+
+ /**
+ * checks if 'content' package type is correct read from package using the registry.
+ */
+ @Test
+ public void test_type_content_via_registry() throws IOException, PackageException {
+ verifyViaRegistry("content");
+ }
+
+ /**
+ * checks if 'container' package type is correct read from package using the registry.
+ */
+ @Test
+ public void test_type_container_via_registry() throws IOException, PackageException {
+ verifyViaRegistry("container");
+ }
+
+ /**
+ * checks if 'mixed' package type is correct read from package using the registry.
+ */
+ @Test
+ public void test_type_mixed_via_registry() throws IOException, PackageException {
+ verifyViaRegistry("mixed");
+ }
+
+ /**
+ * checks if missing package type is correct read from package using the registry.
+ */
+ @Test
+ public void test_missing_type_via_registry() throws IOException, PackageException {
+ verifyViaRegistry("notype");
+ }
+
+}
\ No newline at end of file
Added: jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/packagetype/application-pkg.zip
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/packagetype/application-pkg.zip?rev=1813728&view=auto
==============================================================================
Binary files jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/packagetype/application-pkg.zip (added) and jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/packagetype/application-pkg.zip Mon Oct 30 07:11:59 2017 differ
Added: jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/packagetype/container-pkg.zip
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/packagetype/container-pkg.zip?rev=1813728&view=auto
==============================================================================
Binary files jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/packagetype/container-pkg.zip (added) and jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/packagetype/container-pkg.zip Mon Oct 30 07:11:59 2017 differ
Added: jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/packagetype/content-pkg.zip
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/packagetype/content-pkg.zip?rev=1813728&view=auto
==============================================================================
Binary files jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/packagetype/content-pkg.zip (added) and jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/packagetype/content-pkg.zip Mon Oct 30 07:11:59 2017 differ
Added: jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/packagetype/mixed-pkg.zip
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/packagetype/mixed-pkg.zip?rev=1813728&view=auto
==============================================================================
Binary files jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/packagetype/mixed-pkg.zip (added) and jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/packagetype/mixed-pkg.zip Mon Oct 30 07:11:59 2017 differ
Added: jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/packagetype/notype-pkg.zip
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/packagetype/notype-pkg.zip?rev=1813728&view=auto
==============================================================================
Binary files jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/packagetype/notype-pkg.zip (added) and jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/packagetype/notype-pkg.zip Mon Oct 30 07:11:59 2017 differ