You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/10/18 23:26:56 UTC
[sling-org-apache-sling-installer-factory-packages] 02/11:
SLING-6111 allow to configure whether to create a snapshot prior to
installing a package
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-installer-factory-packages.git
commit 1df258b5f98f31181aa76c070e0fdd21acccc807
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Fri Oct 7 09:24:03 2016 +0000
SLING-6111 allow to configure whether to create a snapshot prior to installing a package
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1763710 13f79535-47bb-0310-9956-ffa450edef68
---
.../factory/packages/impl/PackageTransformer.java | 19 ++++++++++++---
.../impl/PackageTransformerConfiguration.java | 28 ++++++++++++++++++++++
2 files changed, 44 insertions(+), 3 deletions(-)
diff --git a/src/main/java/org/apache/sling/installer/factory/packages/impl/PackageTransformer.java b/src/main/java/org/apache/sling/installer/factory/packages/impl/PackageTransformer.java
index d46c905..1f9ff7e 100644
--- a/src/main/java/org/apache/sling/installer/factory/packages/impl/PackageTransformer.java
+++ b/src/main/java/org/apache/sling/installer/factory/packages/impl/PackageTransformer.java
@@ -48,6 +48,7 @@ import org.apache.sling.installer.api.tasks.TaskResourceGroup;
import org.apache.sling.installer.api.tasks.TransformationResult;
import org.apache.sling.jcr.api.SlingRepository;
import org.osgi.framework.Version;
+import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.slf4j.Logger;
@@ -84,6 +85,13 @@ public class PackageTransformer implements ResourceTransformer, InstallTaskFacto
@Reference
private RetryHandler retryHandler;
+ private PackageTransformerConfiguration configuration;
+
+ @Activate
+ private void activate(final PackageTransformerConfiguration configuration) {
+ this.configuration = configuration;
+ }
+
/**
* @see org.apache.sling.installer.api.tasks.ResourceTransformer#transform(org.apache.sling.installer.api.tasks.RegisteredResource)
*/
@@ -222,10 +230,15 @@ public class PackageTransformer implements ResourceTransformer, InstallTaskFacto
// finally, install package
final ImportOptions opts = new ImportOptions();
+ if (configuration.shouldCreateSnapshots()) {
+ pkg.install(opts);
+ ctx.log("Content package installed: {}", resource);
+ } else {
+ pkg.extract(opts);
+ ctx.log("Content package extracted: {}", resource);
+ }
- pkg.install(opts);
-
- ctx.log("Content package installed: {}", resource);
+
setFinishedState(ResourceState.INSTALLED);
// notify retry handler to install dependend packages.
diff --git a/src/main/java/org/apache/sling/installer/factory/packages/impl/PackageTransformerConfiguration.java b/src/main/java/org/apache/sling/installer/factory/packages/impl/PackageTransformerConfiguration.java
new file mode 100644
index 0000000..eb5689d
--- /dev/null
+++ b/src/main/java/org/apache/sling/installer/factory/packages/impl/PackageTransformerConfiguration.java
@@ -0,0 +1,28 @@
+/*
+ * 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.sling.installer.factory.packages.impl;
+
+import org.osgi.service.metatype.annotations.AttributeDefinition;
+import org.osgi.service.metatype.annotations.ObjectClassDefinition;
+
+@ObjectClassDefinition(name = "Apache Sling OSGi Installer Package Transformer", description = "Allows to configure how content packages are installed through the OSGi installer")
+public @interface PackageTransformerConfiguration {
+ @AttributeDefinition(name = "Create Snapshots", description = "Boolean flag indicating whether prior to the installation of the package a snapshot of the repository should be created.")
+ boolean shouldCreateSnapshots() default true;
+}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.