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/11/07 09:43:34 UTC
[sling-org-apache-sling-installer-provider-file] annotated tag
org.apache.sling.installer.provider.file-1.0.2 created (now 2bacb0f)
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a change to annotated tag org.apache.sling.installer.provider.file-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-installer-provider-file.git.
at 2bacb0f (tag)
tagging f15b0bbdbc4c52bfda8986f1adfae4e490334288 (commit)
by Carsten Ziegeler
on Wed Aug 10 12:43:00 2011 +0000
- Log -----------------------------------------------------------------
org.apache.sling.installer.provider.file-1.0.2
-----------------------------------------------------------------------
This annotated tag includes the following new commits:
new e1c446c Add new file installer module
new a196974 Ignore target dir
new 46401b3 SLING-1689 : Change the OSGi installer interface
new 03be059 SLING-1737 : Add state management for resources
new 6b38c95 Collect changes before submitting them to the installer
new 8233905 Fixstartup problems and potential NPEs
new 25e3a72 Prepare release
new 13ec610 [maven-release-plugin] prepare release org.apache.sling.install.fileinstall-1.0.0
new 2e03276 [maven-release-plugin] prepare for next development iteration
new ac9aac6 Go back to latest snapshots
new 1c25e17 SLING-1787 : Unify symbolic names and check package names
new 5652096 SLING-1787 : Unify symbolic names and check package names
new 57f4f5c SLING-1787 : Unify symbolic names and check package names
new dd6c75c SLING-1787 : Unify symbolic names and check package names
new a2b8446 SLING-1787 : Unify symbolic names and check package names
new c1f7cd8 SLING-1787 : Unify symbolic names and check package names
new 90a6f93 Prepare release
new 2e33160 [maven-release-plugin] prepare release org.apache.sling.installer.provider.file-1.0.0
new 484aa04 [maven-release-plugin] prepare for next development iteration
new 3c318c6 Use snapshot dependencies until the release is out
new 2061cbe Use released version
new a0b7957 updating all modules to parent 10-SNAPSHOT in anticipation of emma additions to parent
new 7984960 fixing relativePaths
new 34cb3dc svn:ignore
new f7f41e3 Update to recent snapshots
new b41fc25 Use latest releases.
new 46ec0b9 SLING-2150 : Update plugins to use the latest available versions
new 7654827 SLING-2162 : Support write back of configurations
new b3aacb1 Update to recent snapshot
new 3509666 Using latest released parent pom
new 9b94397 SLING-2171 : Don't copy resources if they are always available (like from the file system)
new ff3c655 Prepare release
new 99cbb0c [maven-release-plugin] prepare release org.apache.sling.installer.provider.file-1.0.2
new f15b0bb [maven-release-plugin] copy for tag org.apache.sling.installer.provider.file-1.0.2
The 34 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
--
To stop receiving notification emails like this one, please contact
['"commits@sling.apache.org" <co...@sling.apache.org>'].
[sling-org-apache-sling-installer-provider-file] 02/16: Use
snapshot dependencies until the release is out
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.installer.provider.file-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-installer-provider-file.git
commit 3c318c65cc54d9b05fcf504337f74645a57737ce
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Tue Sep 21 07:29:16 2010 +0000
Use snapshot dependencies until the release is out
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/installer/providers/file@999258 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 0ed45ef..d508c6f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -79,7 +79,7 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.installer.core</artifactId>
- <version>3.0.0</version>
+ <version>3.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-installer-provider-file] 05/16: fixing
relativePaths
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.installer.provider.file-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-installer-provider-file.git
commit 7984960e4c44b3afcfa79720c9bb6ce934280b4f
Author: Justin Edelson <ju...@apache.org>
AuthorDate: Wed Oct 20 19:32:18 2010 +0000
fixing relativePaths
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/installer/providers/file@1025691 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 6d22811..588e02c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,7 +24,7 @@
<groupId>org.apache.sling</groupId>
<artifactId>sling</artifactId>
<version>10-SNAPSHOT</version>
- <relativePath>../../parent/pom.xml</relativePath>
+ <relativePath>../../../parent/pom.xml</relativePath>
</parent>
<artifactId>org.apache.sling.installer.provider.file</artifactId>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-installer-provider-file] 06/16: svn:ignore
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.installer.provider.file-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-installer-provider-file.git
commit 34cb3dc059cef939a87c4c9ae74c47eb5ec402e5
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Mon Nov 15 09:49:15 2010 +0000
svn:ignore
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/installer/providers/file@1035200 13f79535-47bb-0310-9956-ffa450edef68
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-installer-provider-file] 01/16:
[maven-release-plugin] prepare for next development iteration
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.installer.provider.file-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-installer-provider-file.git
commit 484aa04babd38af7cd9dbbaefbdbc70adfd99c05
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Tue Sep 21 07:24:45 2010 +0000
[maven-release-plugin] prepare for next development iteration
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/installer/providers/file@999255 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/pom.xml b/pom.xml
index 218cd8c..0ed45ef 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,7 @@
</parent>
<artifactId>org.apache.sling.installer.provider.file</artifactId>
- <version>1.0.0</version>
+ <version>1.0.1-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>Apache Sling File Installer</name>
@@ -37,9 +37,9 @@
</description>
<scm>
- <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.installer.provider.file-1.0.0</connection>
- <developerConnection> scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.installer.provider.file-1.0.0</developerConnection>
- <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.installer.provider.file-1.0.0</url>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/installer/providers/file</connection>
+ <developerConnection> scm:svn:https://svn.apache.org/repos/asf/sling/trunk/installer/providers/file</developerConnection>
+ <url>http://svn.apache.org/viewvc/sling/trunk/installer/providers/file/</url>
</scm>
<build>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-installer-provider-file] 09/16: SLING-2150
: Update plugins to use the latest available versions
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.installer.provider.file-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-installer-provider-file.git
commit 46ec0b95d621e6598b0eed760ace1692ed9dcb3a
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Jul 20 12:21:40 2011 +0000
SLING-2150 : Update plugins to use the latest available versions
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/installer/providers/file@1148722 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index d5d5636..a921f79 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.sling</groupId>
<artifactId>sling</artifactId>
- <version>10</version>
+ <version>11-SNAPSHOT</version>
<relativePath>../../../parent/pom.xml</relativePath>
</parent>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-installer-provider-file] 04/16: updating
all modules to parent 10-SNAPSHOT in anticipation of emma additions to
parent
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.installer.provider.file-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-installer-provider-file.git
commit a0b79575cdd4ba06a13b4ba2476290747f6fea02
Author: Justin Edelson <ju...@apache.org>
AuthorDate: Wed Oct 13 20:54:21 2010 +0000
updating all modules to parent 10-SNAPSHOT in anticipation of emma additions to parent
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/installer/providers/file@1022288 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 0ed45ef..6d22811 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.sling</groupId>
<artifactId>sling</artifactId>
- <version>9</version>
+ <version>10-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-installer-provider-file] 16/16:
[maven-release-plugin] copy for tag
org.apache.sling.installer.provider.file-1.0.2
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.installer.provider.file-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-installer-provider-file.git
commit f15b0bbdbc4c52bfda8986f1adfae4e490334288
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Aug 10 12:43:00 2011 +0000
[maven-release-plugin] copy for tag org.apache.sling.installer.provider.file-1.0.2
git-svn-id: https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.installer.provider.file-1.0.2@1156149 13f79535-47bb-0310-9956-ffa450edef68
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-installer-provider-file] 13/16: SLING-2171
: Don't copy resources if they are always available (like from the file
system)
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.installer.provider.file-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-installer-provider-file.git
commit 9b94397c49cd33f9b1e7be41b927c6bd9d464f9c
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Tue Aug 9 09:43:31 2011 +0000
SLING-2171 : Don't copy resources if they are always available (like from the file system)
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/installer/providers/file@1155290 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 2 +-
.../java/org/apache/sling/installer/provider/file/impl/Installer.java | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/pom.xml b/pom.xml
index 64f2c2e..95f70d3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -82,7 +82,7 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.installer.core</artifactId>
- <version>3.2.0</version>
+ <version>3.2.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- We use a class from the config admin implementation to read config files -->
diff --git a/src/main/java/org/apache/sling/installer/provider/file/impl/Installer.java b/src/main/java/org/apache/sling/installer/provider/file/impl/Installer.java
index 80ce7c2..cc6bddc 100644
--- a/src/main/java/org/apache/sling/installer/provider/file/impl/Installer.java
+++ b/src/main/java/org/apache/sling/installer/provider/file/impl/Installer.java
@@ -129,19 +129,19 @@ public class Installer
final InputStream is = new FileInputStream(file);
final String digest = String.valueOf(file.lastModified());
// if this is a bundle check for start level directory!
- Dictionary<String, Object> dict = null;
+ final Dictionary<String, Object> dict = new Hashtable<String, Object>();
if ( file.getName().endsWith(".jar") || file.getName().endsWith(".war") ) {
final String parentName = file.getParentFile().getName();
try {
final int startLevel = Integer.valueOf(parentName);
if ( startLevel > 0 ) {
- dict = new Hashtable<String, Object>();
dict.put(InstallableResource.BUNDLE_START_LEVEL, startLevel);
}
} catch (NumberFormatException nfe) {
// ignore this
}
}
+ dict.put(InstallableResource.RESOURCE_URI_HINT, file.toURI().toString());
return new InstallableResource(file.getAbsolutePath(), is, dict, digest,
null, null);
} catch (IOException io) {
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-installer-provider-file] 11/16: Update to
recent snapshot
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.installer.provider.file-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-installer-provider-file.git
commit b3aacb1c7d9dbb609f84f39318419a498cc37979
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Aug 3 09:01:37 2011 +0000
Update to recent snapshot
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/installer/providers/file@1153397 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index d0ee922..e8ec90b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.sling</groupId>
<artifactId>sling</artifactId>
- <version>11-SNAPSHOT</version>
+ <version>12-SNAPSHOT</version>
<relativePath>../../../parent/pom.xml</relativePath>
</parent>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-installer-provider-file] 10/16: SLING-2162
: Support write back of configurations
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.installer.provider.file-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-installer-provider-file.git
commit 7654827e1968049b46c352cfcb8ba1cf457e3a51
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Fri Jul 29 07:40:55 2011 +0000
SLING-2162 : Support write back of configurations
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/installer/providers/file@1152133 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 13 +-
.../installer/provider/file/impl/Activator.java | 12 +-
.../provider/file/impl/FileChangesListener.java | 2 +
.../provider/file/impl/FileInstaller.java | 228 +++++++++++++++++++++
.../installer/provider/file/impl/FileMonitor.java | 8 +
.../installer/provider/file/impl/Installer.java | 15 +-
.../provider/file/impl/ServicesListener.java | 65 +++---
7 files changed, 298 insertions(+), 45 deletions(-)
diff --git a/pom.xml b/pom.xml
index a921f79..d0ee922 100644
--- a/pom.xml
+++ b/pom.xml
@@ -57,6 +57,9 @@
<Private-Package>
org.apache.sling.installer.provider.file.impl.*
</Private-Package>
+ <Embed-Dependency>
+ org.apache.felix.configadmin;inline="org/apache/felix/cm/file/ConfigurationHandler.*"
+ </Embed-Dependency>
</instructions>
</configuration>
</plugin>
@@ -79,7 +82,15 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.installer.core</artifactId>
- <version>3.0.0</version>
+ <version>3.2.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <!-- We use a class from the config admin implementation to read config files -->
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.configadmin</artifactId>
+ <version>1.2.8</version>
+ <scope>provided</scope>
</dependency>
</dependencies>
</project>
diff --git a/src/main/java/org/apache/sling/installer/provider/file/impl/Activator.java b/src/main/java/org/apache/sling/installer/provider/file/impl/Activator.java
index 32c707b..2b06592 100644
--- a/src/main/java/org/apache/sling/installer/provider/file/impl/Activator.java
+++ b/src/main/java/org/apache/sling/installer/provider/file/impl/Activator.java
@@ -32,6 +32,7 @@ public class Activator implements BundleActivator {
public static final String KEY_DIR = "sling.fileinstall.dir";
public static final String KEY_DELAY = "sling.fileinstall.interval";
+ public static final String KEY_WRITEBACK = "sling.fileinstall.writeback";
/** The services listener will activate the installer. */
private ServicesListener servicesListener;
@@ -42,10 +43,10 @@ public class Activator implements BundleActivator {
public void start(final BundleContext context) {
// read initial scan configurations
final List<ScanConfiguration> configs = new ArrayList<ScanConfiguration>();
- final Object dir = this.getProp(context, KEY_DIR);
+ final Object dir = getProp(context, KEY_DIR);
if ( dir != null ) {
Long delay = null;
- final Object interval = this.getProp(context, KEY_DELAY);
+ final Object interval = getProp(context, KEY_DELAY);
if ( interval != null ) {
if ( interval instanceof Number ) {
delay = ((Number)interval).longValue();
@@ -73,10 +74,13 @@ public class Activator implements BundleActivator {
this.servicesListener = null;
}
- private Object getProp(final BundleContext bundleContext, final String key) {
+ public static Object getProp(final BundleContext bundleContext, final String key) {
Object o = bundleContext.getProperty(key);
if (o == null) {
- o = System.getProperty(key.toUpperCase().replace('.', '_'));
+ o = System.getProperty(key);
+ if ( o == null ) {
+ o = System.getProperty(key.toUpperCase().replace('.', '_'));
+ }
}
return o;
}
diff --git a/src/main/java/org/apache/sling/installer/provider/file/impl/FileChangesListener.java b/src/main/java/org/apache/sling/installer/provider/file/impl/FileChangesListener.java
index b9c16f2..2fd34d5 100644
--- a/src/main/java/org/apache/sling/installer/provider/file/impl/FileChangesListener.java
+++ b/src/main/java/org/apache/sling/installer/provider/file/impl/FileChangesListener.java
@@ -26,4 +26,6 @@ public interface FileChangesListener {
void initialSet(List<File> files);
void updated(List<File> added, List<File> changed, List<File> removed);
+
+ String getScheme();
}
diff --git a/src/main/java/org/apache/sling/installer/provider/file/impl/FileInstaller.java b/src/main/java/org/apache/sling/installer/provider/file/impl/FileInstaller.java
new file mode 100644
index 0000000..3726746
--- /dev/null
+++ b/src/main/java/org/apache/sling/installer/provider/file/impl/FileInstaller.java
@@ -0,0 +1,228 @@
+/*
+ * 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.provider.file.impl;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.math.BigInteger;
+import java.security.MessageDigest;
+import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.felix.cm.file.ConfigurationHandler;
+import org.apache.sling.installer.api.InstallableResource;
+import org.apache.sling.installer.api.OsgiInstaller;
+import org.apache.sling.installer.api.UpdateHandler;
+import org.apache.sling.installer.api.UpdateResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The <code>FileInstaller</code> manages the file installers and
+ * handles updates.
+ *
+ */
+public class FileInstaller
+ implements UpdateHandler {
+
+ /** The scheme we use to register our resources. */
+ public static final String SCHEME_PREFIX = "fileinstall";
+
+ /** Logger. */
+ private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+ /** All active scan configurations. */
+ private final List<ScanConfiguration> scanConfigurations = new ArrayList<ScanConfiguration>();
+
+ /** All monitors. */
+ private final List<FileMonitor> monitors = new ArrayList<FileMonitor>();
+
+ private final boolean writeBack;
+
+ public FileInstaller(final List<ScanConfiguration> configs, final boolean writeBack) {
+ this.writeBack = writeBack;
+ if ( configs != null ) {
+ scanConfigurations.addAll(configs);
+ }
+ }
+
+ public boolean hasConfigurations() {
+ return !this.scanConfigurations.isEmpty();
+ }
+
+ public void start(final OsgiInstaller installer) {
+ for(final ScanConfiguration config : this.scanConfigurations) {
+ logger.debug("Starting monitor for {}", config.directory);
+ this.monitors.add(new FileMonitor(new File(config.directory),
+ config.scanInterval, new Installer(installer, hash(config.directory))));
+ }
+ }
+
+ public void stop() {
+ for(final FileMonitor monitor : this.monitors) {
+ monitor.stop();
+ }
+ this.monitors.clear();
+
+ }
+
+ public String[] getSchemes() {
+ final String[] schemes = new String[this.monitors.size()];
+ int index = 0;
+
+ for(final FileMonitor m : this.monitors) {
+ schemes[index] = m.getListener().getScheme();
+ index++;
+ }
+
+ return schemes;
+ }
+
+ /**
+ * @see org.apache.sling.installer.api.UpdateHandler#handleRemoval(java.lang.String, java.lang.String, java.lang.String)
+ */
+ public UpdateResult handleRemoval(final String resourceType,
+ final String id,
+ final String url) {
+ if ( !this.writeBack ) {
+ return null;
+ }
+ final int pos = url.indexOf(':');
+ final String path = url.substring(pos + 1);
+ // remove
+ logger.debug("Removal of {}", path);
+ final File file = new File(path);
+ if ( file.exists() ) {
+ file.delete();
+ }
+ return new UpdateResult(url);
+ }
+
+ /**
+ * @see org.apache.sling.installer.api.UpdateHandler#handleUpdate(java.lang.String, java.lang.String, java.lang.String, java.util.Dictionary, Map)
+ */
+ public UpdateResult handleUpdate(final String resourceType,
+ final String id,
+ final String url,
+ final Dictionary<String, Object> dict,
+ final Map<String, Object> attributes) {
+ return this.handleUpdate(resourceType, id, url, null, dict, attributes);
+ }
+
+ /**
+ * @see org.apache.sling.installer.api.UpdateHandler#handleUpdate(java.lang.String, java.lang.String, java.lang.String, java.io.InputStream, Map)
+ */
+ public UpdateResult handleUpdate(final String resourceType,
+ final String id,
+ final String url,
+ final InputStream is,
+ final Map<String, Object> attributes) {
+ return this.handleUpdate(resourceType, id, url, is, null, attributes);
+ }
+
+ /**
+ * Internal implementation of update handling
+ */
+ private UpdateResult handleUpdate(final String resourceType,
+ final String id,
+ final String url,
+ final InputStream is,
+ final Dictionary<String, Object> dict,
+ final Map<String, Object> attributes) {
+ if ( !this.writeBack ) {
+ return null;
+ }
+
+ // we only handle add/update of configs for now
+ if ( !resourceType.equals(InstallableResource.TYPE_CONFIG) ) {
+ return null;
+ }
+
+ try {
+ final String path;
+ final String prefix;
+ if ( url != null ) {
+ // update
+ final int pos = url.indexOf(':');
+ final String oldPath = url.substring(pos + 1);
+ prefix = url.substring(0, pos);
+ // ensure extension 'config'
+ if ( !oldPath.endsWith(".config") ) {
+ final File file = new File(oldPath);
+ if ( file.exists() ) {
+ file.delete();
+ }
+ final int lastDot = oldPath.lastIndexOf('.');
+ final int lastSlash = oldPath.lastIndexOf('/');
+ if ( lastDot <= lastSlash ) {
+ path = oldPath + ".config";
+ } else {
+ path = oldPath.substring(0, lastDot) + ".config";
+ }
+ } else {
+ path = oldPath;
+ }
+ logger.debug("Update of {} at {}", resourceType, path);
+ } else {
+ // add
+ final FileMonitor first = this.monitors.get(0);
+ path = first.getRoot().getAbsolutePath() + '/' + id + ".config";
+ prefix = first.getListener().getScheme();
+ logger.debug("Add of {} at {}", resourceType, path);
+ }
+
+ final File file = new File(path);
+ file.getParentFile().mkdirs();
+ final FileOutputStream fos = new FileOutputStream(file);
+ try {
+ ConfigurationHandler.write(fos, dict);
+ } finally {
+ try {
+ fos.close();
+ } catch (final IOException ignore) {}
+ }
+
+ final UpdateResult result = new UpdateResult(prefix + ':' + path);
+ result.setResourceIsMoved(true);
+ return result;
+ } catch (final IOException e) {
+ logger.error("Unable to add/update resource " + resourceType + ':' + id, e);
+ return null;
+ }
+ }
+
+ /**
+ * Hash the string
+ */
+ private static String hash(String value) {
+ try {
+ final MessageDigest d = MessageDigest.getInstance("MD5");
+ d.update(value.getBytes("UTF-8"));
+ final BigInteger bigInt = new BigInteger(1, d.digest());
+ return new String(bigInt.toString(16));
+ } catch (Exception ignore) {
+ // if anything goes wrong we just return the value
+ return value;
+ }
+ }
+}
diff --git a/src/main/java/org/apache/sling/installer/provider/file/impl/FileMonitor.java b/src/main/java/org/apache/sling/installer/provider/file/impl/FileMonitor.java
index 0c16ce7..085d07e 100644
--- a/src/main/java/org/apache/sling/installer/provider/file/impl/FileMonitor.java
+++ b/src/main/java/org/apache/sling/installer/provider/file/impl/FileMonitor.java
@@ -59,6 +59,14 @@ public class FileMonitor extends TimerTask {
timer.schedule(this, 0, (interval != null ? interval : 5000));
}
+ public File getRoot() {
+ return this.root.file;
+ }
+
+ public FileChangesListener getListener() {
+ return this.listener;
+ }
+
private void collect(final File file, final List<File> files) {
if ( file.exists() ) {
if ( file.isDirectory() ) {
diff --git a/src/main/java/org/apache/sling/installer/provider/file/impl/Installer.java b/src/main/java/org/apache/sling/installer/provider/file/impl/Installer.java
index 3113208..80ce7c2 100644
--- a/src/main/java/org/apache/sling/installer/provider/file/impl/Installer.java
+++ b/src/main/java/org/apache/sling/installer/provider/file/impl/Installer.java
@@ -37,10 +37,8 @@ import org.slf4j.LoggerFactory;
* OSGi installer
*
*/
-public class Installer implements FileChangesListener {
-
- /** The scheme we use to register our resources. */
- private static final String SCHEME_PREFIX = "fileinstall";
+public class Installer
+ implements FileChangesListener {
/** Logger. */
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@@ -53,11 +51,18 @@ public class Installer implements FileChangesListener {
public Installer(final OsgiInstaller installer,
final String id) {
- this.scheme = SCHEME_PREFIX + id;
+ this.scheme = FileInstaller.SCHEME_PREFIX + id;
this.installer = installer;
}
/**
+ * @see org.apache.sling.installer.provider.file.impl.FileChangesListener#getScheme()
+ */
+ public String getScheme() {
+ return this.scheme;
+ }
+
+ /**
* @see org.apache.sling.installer.provider.file.impl.FileChangesListener#initialSet(java.util.List)
*/
public void initialSet(final List<File> files) {
diff --git a/src/main/java/org/apache/sling/installer/provider/file/impl/ServicesListener.java b/src/main/java/org/apache/sling/installer/provider/file/impl/ServicesListener.java
index 01e3c58..c71bfca 100644
--- a/src/main/java/org/apache/sling/installer/provider/file/impl/ServicesListener.java
+++ b/src/main/java/org/apache/sling/installer/provider/file/impl/ServicesListener.java
@@ -18,19 +18,19 @@
*/
package org.apache.sling.installer.provider.file.impl;
-import java.io.File;
-import java.math.BigInteger;
-import java.security.MessageDigest;
-import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.Hashtable;
import java.util.List;
import org.apache.sling.installer.api.OsgiInstaller;
+import org.apache.sling.installer.api.UpdateHandler;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceEvent;
import org.osgi.framework.ServiceListener;
import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -53,26 +53,29 @@ public class ServicesListener {
/** The listener for the installer. */
private final Listener installerListener;
- /** All active scan configurations. */
- private final List<ScanConfiguration> scanConfigurations = new ArrayList<ScanConfiguration>();
+ /** The file installer. */
+ private final FileInstaller installer;
- /** All monitors. */
- private final List<FileMonitor> monitors = new ArrayList<FileMonitor>();
+ /** Service registration. */
+ private ServiceRegistration registration;
private boolean running = false;
public ServicesListener(final BundleContext bundleContext,
final List<ScanConfiguration> configs) {
- if ( configs != null ) {
- scanConfigurations.addAll(configs);
- }
this.bundleContext = bundleContext;
+ boolean writeBack = true;
+ final Object writeBackObj = Activator.getProp(this.bundleContext, Activator.KEY_WRITEBACK);
+ if ( writeBackObj != null && "false".equalsIgnoreCase(writeBackObj.toString())) {
+ writeBack = false;
+ }
+ this.installer = new FileInstaller(configs, writeBack);
this.installerListener = new Listener(INSTALLER_SERVICE_NAME);
this.installerListener.start();
}
public synchronized void notifyChange() {
- final boolean shouldRun = !this.scanConfigurations.isEmpty();
+ final boolean shouldRun = this.installer.hasConfigurations();
if ( (shouldRun && !running) || (!shouldRun && running) ) {
final OsgiInstaller installer = (OsgiInstaller)this.installerListener.getService();
@@ -94,23 +97,30 @@ public class ServicesListener {
this.stopScanner();
}
+ /** Vendor of all registered services. */
+ public static final String VENDOR = "The Apache Software Foundation";
+
private void startScanner(final OsgiInstaller installer) {
if ( !running ) {
- for(final ScanConfiguration config : this.scanConfigurations) {
- logger.debug("Starting monitor for {}", config.directory);
- this.monitors.add(new FileMonitor(new File(config.directory),
- config.scanInterval, new Installer(installer, hash(config.directory))));
- }
+ this.installer.start(installer);
+ final Dictionary<String, Object> props = new Hashtable<String, Object>();
+ props.put(Constants.SERVICE_DESCRIPTION, "Apache Sling File Installer Controller Service");
+ props.put(Constants.SERVICE_VENDOR, VENDOR);
+ props.put(UpdateHandler.PROPERTY_SCHEMES, this.installer.getSchemes());
+
+ this.registration = this.bundleContext.registerService(UpdateHandler.class.getName(),
+ this.installer, props);
running = true;
}
}
private void stopScanner() {
if ( running ) {
- for(final FileMonitor monitor : this.monitors) {
- monitor.stop();
+ if ( this.registration != null ) {
+ this.registration.unregister();
+ this.registration = null;
}
- this.monitors.clear();
+ this.installer.stop();
running = false;
}
}
@@ -178,19 +188,4 @@ public class ServicesListener {
}
}
}
-
- /**
- * Hash the string
- */
- private static String hash(String value) {
- try {
- final MessageDigest d = MessageDigest.getInstance("MD5");
- d.update(value.getBytes("UTF-8"));
- final BigInteger bigInt = new BigInteger(1, d.digest());
- return new String(bigInt.toString(16));
- } catch (Exception ignore) {
- // if anything goes wrong we just return the value
- return value;
- }
- }
}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-installer-provider-file] 03/16: Use
released version
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.installer.provider.file-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-installer-provider-file.git
commit 2061cbeb00cbfc3caa38b44f6c895fc55f389983
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Fri Sep 24 13:11:46 2010 +0000
Use released version
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/installer/providers/file@1000857 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index d508c6f..0ed45ef 100644
--- a/pom.xml
+++ b/pom.xml
@@ -79,7 +79,7 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.installer.core</artifactId>
- <version>3.0.1-SNAPSHOT</version>
+ <version>3.0.0</version>
</dependency>
</dependencies>
</project>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-installer-provider-file] 12/16: Using
latest released parent pom
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.installer.provider.file-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-installer-provider-file.git
commit 350966696cae4d5a725d74f3cb673985e2610452
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Aug 8 11:31:38 2011 +0000
Using latest released parent pom
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/installer/providers/file@1154924 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index e8ec90b..64f2c2e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.sling</groupId>
<artifactId>sling</artifactId>
- <version>12-SNAPSHOT</version>
+ <version>11</version>
<relativePath>../../../parent/pom.xml</relativePath>
</parent>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-installer-provider-file] 14/16: Prepare
release
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.installer.provider.file-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-installer-provider-file.git
commit ff3c6553eee9f143c529942ca28df83c99835080
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Aug 10 12:34:19 2011 +0000
Prepare release
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/installer/providers/file@1156140 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 95f70d3..ead2355 100644
--- a/pom.xml
+++ b/pom.xml
@@ -82,7 +82,7 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.installer.core</artifactId>
- <version>3.2.1-SNAPSHOT</version>
+ <version>3.2.2</version>
<scope>provided</scope>
</dependency>
<!-- We use a class from the config admin implementation to read config files -->
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-installer-provider-file] 15/16:
[maven-release-plugin] prepare release
org.apache.sling.installer.provider.file-1.0.2
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.installer.provider.file-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-installer-provider-file.git
commit 99cbb0ce61c11a04291bcb5e1113e188659a1a03
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Aug 10 12:42:41 2011 +0000
[maven-release-plugin] prepare release org.apache.sling.installer.provider.file-1.0.2
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/installer/providers/file@1156148 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/pom.xml b/pom.xml
index ead2355..55c5272 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,7 @@
</parent>
<artifactId>org.apache.sling.installer.provider.file</artifactId>
- <version>1.0.1-SNAPSHOT</version>
+ <version>1.0.2</version>
<packaging>bundle</packaging>
<name>Apache Sling File Installer</name>
@@ -37,9 +37,9 @@
</description>
<scm>
- <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/installer/providers/file</connection>
- <developerConnection> scm:svn:https://svn.apache.org/repos/asf/sling/trunk/installer/providers/file</developerConnection>
- <url>http://svn.apache.org/viewvc/sling/trunk/installer/providers/file/</url>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.installer.provider.file-1.0.2</connection>
+ <developerConnection> scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.installer.provider.file-1.0.2</developerConnection>
+ <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.installer.provider.file-1.0.2</url>
</scm>
<build>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-installer-provider-file] 08/16: Use latest
releases.
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.installer.provider.file-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-installer-provider-file.git
commit b41fc257957a5a1b3484ae8b2f97e3f3ef425ee1
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Dec 13 08:55:35 2010 +0000
Use latest releases.
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/installer/providers/file@1045037 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index a921f79..d5d5636 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.sling</groupId>
<artifactId>sling</artifactId>
- <version>11-SNAPSHOT</version>
+ <version>10</version>
<relativePath>../../../parent/pom.xml</relativePath>
</parent>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-installer-provider-file] 07/16: Update to
recent snapshots
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.installer.provider.file-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-installer-provider-file.git
commit f7f41e3138e5ae06ba2344dc70b7468df51ce019
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Dec 8 16:37:27 2010 +0000
Update to recent snapshots
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/installer/providers/file@1043504 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 588e02c..a921f79 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.sling</groupId>
<artifactId>sling</artifactId>
- <version>10-SNAPSHOT</version>
+ <version>11-SNAPSHOT</version>
<relativePath>../../../parent/pom.xml</relativePath>
</parent>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.