Author: rwesten
Date: Thu Oct 20 10:45:42 2011
New Revision: 1186729

URL: http://svn.apache.org/viewvc?rev=1186729&view=rev
Log:
2nd try to commit all the files ...

Summary: Fixes STANBOL-354; created three separate bundles out of 
"org.apache.commons.solr"; Adaption to several other modules to reflect this 
seperation.

Added:
    incubator/stanbol/trunk/commons/solr/core/pom.xml   (contents, props 
changed)
      - copied, changed from r1183014, 
incubator/stanbol/trunk/commons/solr/pom.xml
    incubator/stanbol/trunk/commons/solr/install/pom.xml   (with props)
    
incubator/stanbol/trunk/commons/solr/install/src/main/java/org/apache/stanbol/commons/solr/install/impl/IndexInstallTask.java
   (with props)
    
incubator/stanbol/trunk/commons/solr/install/src/main/java/org/apache/stanbol/commons/solr/install/impl/IndexRemoveTask.java
   (with props)
    
incubator/stanbol/trunk/commons/solr/install/src/main/java/org/apache/stanbol/commons/solr/install/impl/SolrIndexInstaller.java
   (with props)
    incubator/stanbol/trunk/commons/solr/web/pom.xml   (with props)
Modified:
    incubator/stanbol/trunk/entityhub/indexing/dblp/pom.xml
    incubator/stanbol/trunk/entityhub/indexing/dbpedia/pom.xml

Copied: incubator/stanbol/trunk/commons/solr/core/pom.xml (from r1183014, 
incubator/stanbol/trunk/commons/solr/pom.xml)
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/solr/core/pom.xml?p2=incubator/stanbol/trunk/commons/solr/core/pom.xml&p1=incubator/stanbol/trunk/commons/solr/pom.xml&r1=1183014&r2=1186729&rev=1186729&view=diff
==============================================================================
--- incubator/stanbol/trunk/commons/solr/pom.xml (original)
+++ incubator/stanbol/trunk/commons/solr/core/pom.xml Thu Oct 20 10:45:42 2011
@@ -24,16 +24,16 @@
     <groupId>org.apache.stanbol</groupId>
     <artifactId>stanbol-parent</artifactId>
     <version>0.9.0-incubating-SNAPSHOT</version>
-    <relativePath>../../parent</relativePath>
+    <relativePath>../../../parent</relativePath>
   </parent>
 
   <groupId>org.apache.stanbol</groupId>
-  <artifactId>org.apache.stanbol.commons.solr</artifactId>
+  <artifactId>org.apache.stanbol.commons.solr.core</artifactId>
   <packaging>bundle</packaging>
 
   <name>Apache Stanbol Solr Bundle</name>
-  <description>This bundle provides an OSGI bundle for Solr and in addition
-  utilities to create/initialise and manage SolrCores in an EmbeddedSolrServer.
+  <description>This bundle provides an OSGI bundle for Solr. This also includes
+  an utility that registers CoreContainer and SolrCores as OSGI services.
   </description>
 
   <inceptionYear>2010</inceptionYear>

Propchange: incubator/stanbol/trunk/commons/solr/core/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/stanbol/trunk/commons/solr/install/pom.xml
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/solr/install/pom.xml?rev=1186729&view=auto
==============================================================================
--- incubator/stanbol/trunk/commons/solr/install/pom.xml (added)
+++ incubator/stanbol/trunk/commons/solr/install/pom.xml Thu Oct 20 10:45:42 
2011
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.stanbol</groupId>
+    <artifactId>stanbol-parent</artifactId>
+    <version>0.9.0-incubating-SNAPSHOT</version>
+    <relativePath>../../../parent</relativePath>
+  </parent>
+
+  <groupId>org.apache.stanbol</groupId>
+  <artifactId>org.apache.stanbol.commons.solr.install</artifactId>
+  <packaging>bundle</packaging>
+
+  <name>Apache Stanbol Solr Installer Bundle</name>
+  <description>Provides support to Install Solr indexes by using the
+  Apache Sling Installer framework 
+  </description>
+
+  <inceptionYear>2010</inceptionYear>
+
+  <scm>
+    <connection>
+      
scm:svn:http://svn.apache.org/repos/asf/incubator/stanbol/trunk/commons/solr/install
+    </connection>
+    <developerConnection>
+      
scm:svn:https://svn.apache.org/repos/asf/incubator/stanbol/trunk/commons/solr/install
+    </developerConnection>
+    <url>http://incubator.apache.org/stanbol</url>
+  </scm>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <extensions>true</extensions>
+        <configuration>
+          <instructions>
+            <Export-Package>
+              
org.apache.stanbol.commons.solr.install;version=${project.version}
+            </Export-Package>
+            <Import-Package>
+              *
+            </Import-Package>
+            <Private-Package>
+              
org.apache.stanbol.commons.solr.install.impl;version=${project.version}
+            </Private-Package>
+            <Embed-Dependency>
+            </Embed-Dependency>
+          </instructions>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-scr-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </build>
+
+  <dependencies>
+    <!-- Stanbol Commomns dependencies -->
+    <dependency>
+      <groupId>org.apache.stanbol</groupId>
+      <artifactId>org.apache.stanbol.commons.solr.core</artifactId>
+    </dependency>
+    <!-- for the Solr Index Installer -->
+    <dependency>
+      <groupId>org.apache.sling</groupId>
+      <artifactId>org.apache.sling.installer.core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>commons-io</groupId>
+      <artifactId>commons-io</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-compress</artifactId>
+    </dependency>
+    <!--  OSGI framework dependencies -->
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.core</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.compendium</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.felix</groupId>
+      <artifactId>org.apache.felix.scr.annotations</artifactId>
+    </dependency>
+    <!-- Logging -->
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+    </dependency>
+    <!-- for tests -->
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-simple</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+</project>

Propchange: incubator/stanbol/trunk/commons/solr/install/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
incubator/stanbol/trunk/commons/solr/install/src/main/java/org/apache/stanbol/commons/solr/install/impl/IndexInstallTask.java
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/solr/install/src/main/java/org/apache/stanbol/commons/solr/install/impl/IndexInstallTask.java?rev=1186729&view=auto
==============================================================================
--- 
incubator/stanbol/trunk/commons/solr/install/src/main/java/org/apache/stanbol/commons/solr/install/impl/IndexInstallTask.java
 (added)
+++ 
incubator/stanbol/trunk/commons/solr/install/src/main/java/org/apache/stanbol/commons/solr/install/impl/IndexInstallTask.java
 Thu Oct 20 10:45:42 2011
@@ -0,0 +1,123 @@
+/*
+ * 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.stanbol.commons.solr.install.impl;
+
+import static 
org.apache.stanbol.commons.solr.IndexInstallerConstants.PROPERTY_ARCHIVE_FORMAT;
+import static 
org.apache.stanbol.commons.solr.IndexInstallerConstants.PROPERTY_INDEX_ARCHIVE;
+import static 
org.apache.stanbol.commons.solr.IndexInstallerConstants.PROPERTY_INDEX_NAME;
+
+import java.io.File;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.commons.compress.archivers.ArchiveInputStream;
+import org.apache.commons.io.IOUtils;
+import org.apache.sling.installer.api.tasks.InstallTask;
+import org.apache.sling.installer.api.tasks.InstallationContext;
+import org.apache.sling.installer.api.tasks.ResourceState;
+import org.apache.sling.installer.api.tasks.TaskResourceGroup;
+import org.apache.stanbol.commons.solr.SolrDirectoryManager;
+import org.apache.stanbol.commons.solr.utils.ConfigUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class IndexInstallTask extends InstallTask {
+
+    private static final Logger log = 
LoggerFactory.getLogger(IndexInstallTask.class);
+    /**
+     * use 19 because the config install uses 20 and the files MUST be 
installed before the config triggering
+     * the initialisation of the services.
+     */
+    private static final String CONFIG_INSTALL_ORDER = "19-";
+
+    private final SolrDirectoryManager solrDirectoryManager;
+
+    public IndexInstallTask(TaskResourceGroup trg, SolrDirectoryManager 
solrDirectoryManager) {
+        super(trg);
+        this.solrDirectoryManager = solrDirectoryManager;
+    }
+
+    @Override
+    public void execute(InstallationContext ctx) {
+        String indexName = (String) 
getResource().getAttribute(PROPERTY_INDEX_NAME);
+        Map<String,File> existingIndexes = 
solrDirectoryManager.getManagedIndices();
+        if (existingIndexes.containsKey(indexName)) {
+            // an Index with that name already exists -> ignore
+            ctx.log(
+                "Unable to install the Index with the name \"%s\" becuase an 
index with that name is already managed by the the SolrYard "
+                        + "(resource %s | location of the existing index 
%s)!", indexName, getResource()
+                        .getURL(), existingIndexes.get(indexName));
+            setFinishedState(ResourceState.IGNORED);
+        } else { // this index does not exist
+            String archiveFormat = (String) 
getResource().getAttribute(PROPERTY_ARCHIVE_FORMAT);
+            InputStream is = null;
+            try {
+                is = getResource().getInputStream();
+                if ("properties".equals(archiveFormat)) {
+                    InputStreamReader reader = new InputStreamReader(is, 
"UTF-8");
+                    Properties props = new Properties();
+                    try {
+                        props.load(reader);
+                    } finally {
+                        IOUtils.closeQuietly(reader);
+                    }
+                    String indexPath = 
props.getProperty(PROPERTY_INDEX_ARCHIVE);
+                    if (indexPath == null) {
+                        indexPath = indexName + '.' + 
ConfigUtils.SOLR_INDEX_ARCHIVE_EXTENSION;
+                        log.info("Property \""
+                                 + PROPERTY_INDEX_ARCHIVE
+                                 + "\" not present within the SolrIndex 
references file. Will use the default name \""
+                                 + indexPath + "\"");
+                    }
+                    solrDirectoryManager.createSolrDirectory(indexName, 
indexPath, props);
+                    setFinishedState(ResourceState.INSTALLED);
+                } else {
+                    ArchiveInputStream ais = null;
+                    try {
+                        ais = ConfigUtils.getArchiveInputStream(archiveFormat, 
is);
+                        solrDirectoryManager.createSolrIndex(indexName, ais);
+                        // we are done ... set the state to installed!
+                        setFinishedState(ResourceState.INSTALLED);
+                    } finally {
+                        IOUtils.closeQuietly(ais);
+                    }
+                }
+                // now we can copy the core!
+            } catch (Exception e) {
+                String message = String
+                        .format(
+                            "Unable to install SolrIndexArchive for index name 
\"%s\"! (resource=%s, arviceFormat=%s)",
+                            indexName, getResource().getURL(), archiveFormat);
+                log.error(message, e);
+                ctx.log("%s! Reason: %s", message, e.getMessage());
+                setFinishedState(ResourceState.IGNORED);
+            } finally {
+                IOUtils.closeQuietly(is);
+            }
+
+        }
+
+    }
+
+    @Override
+    public String getSortKey() {
+        return CONFIG_INSTALL_ORDER + getResource().getPriority() + "-" + 
getResource().getEntityId();
+    }
+
+}

Propchange: 
incubator/stanbol/trunk/commons/solr/install/src/main/java/org/apache/stanbol/commons/solr/install/impl/IndexInstallTask.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
incubator/stanbol/trunk/commons/solr/install/src/main/java/org/apache/stanbol/commons/solr/install/impl/IndexRemoveTask.java
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/solr/install/src/main/java/org/apache/stanbol/commons/solr/install/impl/IndexRemoveTask.java?rev=1186729&view=auto
==============================================================================
--- 
incubator/stanbol/trunk/commons/solr/install/src/main/java/org/apache/stanbol/commons/solr/install/impl/IndexRemoveTask.java
 (added)
+++ 
incubator/stanbol/trunk/commons/solr/install/src/main/java/org/apache/stanbol/commons/solr/install/impl/IndexRemoveTask.java
 Thu Oct 20 10:45:42 2011
@@ -0,0 +1,86 @@
+/*
+ * 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.stanbol.commons.solr.install.impl;
+
+import static 
org.apache.stanbol.commons.solr.IndexInstallerConstants.PROPERTY_INDEX_NAME;
+
+import java.io.File;
+
+import org.apache.sling.installer.api.tasks.InstallTask;
+import org.apache.sling.installer.api.tasks.InstallationContext;
+import org.apache.sling.installer.api.tasks.ResourceState;
+import org.apache.sling.installer.api.tasks.TaskResourceGroup;
+import org.apache.stanbol.commons.solr.SolrDirectoryManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * TODO: To remove a SolrIndex one would need first to close the SolrCore or 
shutdown the SolrContainer. This
+ * is currently not possible be cause the current architecture was not 
intended to support that.
+ * <p>
+ * To implement this one would need access to the CoreContainer with the core 
running on top of the Core to
+ * remove. Than one would need to call {@link CoreContainer#remove(String)} 
with the core and
+ * {@link CoreContainer#persist()} to remove the core also from the solr.xml. 
After that one can remove the
+ * files from the disk.
+ * <p>
+ * This would still have the problem that other components using an {@link 
EmbeddedSolrServer} that is based
+ * on this core would not be notified about such a change.
+ * 
+ * @author Rupert Westenthaler
+ * 
+ */
+public class IndexRemoveTask extends InstallTask {
+    
+    private static final Logger log = 
LoggerFactory.getLogger(IndexRemoveTask.class);
+    /**
+     * Use 11 because the RemoveConfiguration uses 10 and we need to ensure 
that the files are removed after
+     * the services are shut down.
+     */
+    private static final String CONFIG_INSTALL_ORDER = "11-";
+    
+    private final SolrDirectoryManager solrDirectoryManager;
+
+    public IndexRemoveTask(TaskResourceGroup trg, SolrDirectoryManager 
solrDirectoryManager) {
+        super(trg);
+        if(solrDirectoryManager == null){
+            throw new IllegalArgumentException("The parsed 
SolrDirectoryManager MUST NOT be NULL");
+        }
+        this.solrDirectoryManager = solrDirectoryManager;
+    }
+
+    @Override
+    public void execute(InstallationContext ctx) {
+        String indexName = (String) 
getResource().getAttribute(PROPERTY_INDEX_NAME);
+        File solrIndexDir = 
solrDirectoryManager.getSolrIndexDirectory(indexName);
+        if (solrIndexDir == null) {
+            // no index with that name installed -> nothing to do
+            ctx.log(String.format("SolrIndex '%s' not installed. Nothing to 
uninstall",
+                indexName));
+            setFinishedState(ResourceState.IGNORED);
+        } else { // this index does not exist
+            //solrDirectoryManager.removeSolrIndex()
+            log.warn("Uninstalling of SolrIndexes not yet Implemented -> 
marking as uninstalled (see STANBOL-287)");
+            setFinishedState(ResourceState.UNINSTALLED);
+        }
+    }
+
+    @Override
+    public String getSortKey() {
+        return CONFIG_INSTALL_ORDER + getResource().getEntityId();
+    }
+
+}

Propchange: 
incubator/stanbol/trunk/commons/solr/install/src/main/java/org/apache/stanbol/commons/solr/install/impl/IndexRemoveTask.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
incubator/stanbol/trunk/commons/solr/install/src/main/java/org/apache/stanbol/commons/solr/install/impl/SolrIndexInstaller.java
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/solr/install/src/main/java/org/apache/stanbol/commons/solr/install/impl/SolrIndexInstaller.java?rev=1186729&view=auto
==============================================================================
--- 
incubator/stanbol/trunk/commons/solr/install/src/main/java/org/apache/stanbol/commons/solr/install/impl/SolrIndexInstaller.java
 (added)
+++ 
incubator/stanbol/trunk/commons/solr/install/src/main/java/org/apache/stanbol/commons/solr/install/impl/SolrIndexInstaller.java
 Thu Oct 20 10:45:42 2011
@@ -0,0 +1,168 @@
+/*
+ * 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.stanbol.commons.solr.install.impl;
+
+import static 
org.apache.stanbol.commons.solr.IndexInstallerConstants.PROPERTY_ARCHIVE_FORMAT;
+import static 
org.apache.stanbol.commons.solr.IndexInstallerConstants.PROPERTY_INDEX_NAME;
+import static 
org.apache.stanbol.commons.solr.IndexInstallerConstants.SOLR_INDEX_ARCHIVE_RESOURCE_TYPE;
+import static 
org.apache.stanbol.commons.solr.utils.ConfigUtils.SOLR_INDEX_ARCHIVE_EXTENSION;
+import static 
org.apache.stanbol.commons.solr.utils.ConfigUtils.SUPPORTED_SOLR_ARCHIVE_FORMAT;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.io.FilenameUtils;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.felix.scr.annotations.Services;
+import org.apache.sling.installer.api.InstallableResource;
+import org.apache.sling.installer.api.tasks.InstallTask;
+import org.apache.sling.installer.api.tasks.InstallTaskFactory;
+import org.apache.sling.installer.api.tasks.RegisteredResource;
+import org.apache.sling.installer.api.tasks.ResourceState;
+import org.apache.sling.installer.api.tasks.ResourceTransformer;
+import org.apache.sling.installer.api.tasks.TaskResource;
+import org.apache.sling.installer.api.tasks.TaskResourceGroup;
+import org.apache.sling.installer.api.tasks.TransformationResult;
+import org.apache.stanbol.commons.solr.IndexInstallerConstants;
+import org.apache.stanbol.commons.solr.SolrDirectoryManager;
+import org.apache.stanbol.commons.solr.SolrServerProviderManager;
+import org.osgi.framework.Constants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The main class implementing the two core interfaces of the Apache Sling 
Installer framework.
+ * <p>
+ * The {@link ResourceTransformer} is needed to check if installed files 
actually SolrIndexes. Currently this
+ * check is done by checking if <code>'.'+{@link 
IndexInstallerConstants#SOLR_INDEX_ARCHIVE_EXTENSION}</code>
+ * is contained in the filename. In addition it is checked of the archive type 
is hinted by the Filename. If
+ * not than ".zip" (works also for ".jar") is assumed. Note also that for 
".gz" and ".bz2" it is assumed that
+ * ".tar" is used. File names such as "&lt;indexName&gt;.
+ * {@value IndexInstallerConstants#SOLR_INDEX_ARCHIVE_EXTENSION} 
[.&lt;archiveType&gt;]" are used by this
+ * implementation
+ * <p>
+ * The {@link InstallTaskFactory} interface is needed to create the actual 
install and remove task for
+ * transformed resources. Based on the requested activity instances of {@link 
IndexInstallTask} or
+ * {@link IndexRemoveTask} are created.
+ * <p>
+ * This implementation uses a {@link Constants#SERVICE_RANKING} of 100. This 
ensures that the this
+ * implementation is called before any {@link ResourceTransformer} directly 
part of the Apache Sling Installer
+ * framework. If {@link #transform(RegisteredResource)} returns 
<code>null</code> the Sling Installer
+ * framework will call the next registered {@link ResourceTransformer} 
instance. By returning a
+ * {@link TransformationResult} no further {@link ResourceTransformer} will be 
called.
+ * <p>
+ * 
+ * TODO: This package should move to an own bundle supporting Sling Install 
capabilities for Solr. Even the
+ * current version only on the {@link SolrDirectoryManager}. The reason why it 
is still inside the SolrYard
+ * Bundle is that the remove functionality would also need to stop currently 
running SolrServers. this is
+ * currently not possible with the current architecture because {@link 
SolrServer} instances returned by the
+ * {@link SolrServerProviderManager} are no OSGI components.
+ * 
+ * 
+ * @author Rupert Westenthaler
+ * 
+ */
+@Component(immediate = true)
+@Services(value = {@Service(value = InstallTaskFactory.class), @Service(value 
= ResourceTransformer.class)})
+@Property(name = Constants.SERVICE_RANKING, intValue = 100)
+// we need to be in front of the Sling Components
+public class SolrIndexInstaller implements InstallTaskFactory, 
ResourceTransformer {
+
+    private static final Logger log = 
LoggerFactory.getLogger(SolrIndexInstaller.class);
+
+    /**
+     * This service manages the SolrIndex Directory of the SolrYard. It is 
needed by the
+     * {@link IndexInstallTask} and {@link IndexRemoveTask} to do there work.
+     */
+    @Reference
+    private SolrDirectoryManager solrDirectoryManager;
+
+    public InstallTask createTask(TaskResourceGroup taskResourceGroup) {
+        TaskResource toActivate = taskResourceGroup.getActiveResource();
+        if (SOLR_INDEX_ARCHIVE_RESOURCE_TYPE.equals(toActivate.getType())) {
+            if (toActivate.getState() == ResourceState.UNINSTALL) {
+                return new IndexRemoveTask(taskResourceGroup, 
solrDirectoryManager);
+            } else {
+                return new IndexInstallTask(taskResourceGroup, 
solrDirectoryManager);
+            }
+        } else {
+            return null;
+        }
+    }
+
+    @Override
+    public TransformationResult[] transform(RegisteredResource 
registeredResource) {
+        if 
(InstallableResource.TYPE_FILE.equals(registeredResource.getType())) {
+            return checkIndex(registeredResource);
+        } else { // this processes only files
+            return null;
+        }
+    }
+
+    /**
+     * Checks if the installed resource is an Solr Index Archive
+     * 
+     * @param registeredResource
+     *            the registered resource parsed by the Apache Sling installer 
framework
+     * @return the transformed resource or <code>null</code> if the parsed 
resource is not an Solr Index
+     *         Archive.
+     */
+    private TransformationResult[] checkIndex(RegisteredResource 
registeredResource) {
+        // the URL is <schema>:<filePath>
+        // where the schema is the provider that registered the resource
+        Map<String,Object> properties = new HashMap<String,Object>();
+        String filePath = registeredResource.getURL().substring(
+            registeredResource.getURL().lastIndexOf(':') + 1);
+        // get the name of the index
+        String indexName = FilenameUtils.getBaseName(filePath);
+        // only the String until the first '.' -> multiple endings (e.g. 
slrindex.zip) expected
+        indexName = indexName.indexOf('.') > 0 ? indexName.substring(0, 
indexName.indexOf('.')) : indexName;
+        properties.put(PROPERTY_INDEX_NAME, indexName);
+        // now convert to lover case to ease the tests for file endings
+        filePath = filePath.toLowerCase();
+        if (!filePath.contains('.' + SOLR_INDEX_ARCHIVE_EXTENSION)) {
+            // not an solr index archive
+            return null; // -> can not transform
+        }
+        String extension = FilenameUtils.getExtension(filePath);
+        String archiveFormat = SUPPORTED_SOLR_ARCHIVE_FORMAT.get(extension);
+        if (archiveFormat == null) {
+            log.error("Unable to process Solr Index Archive from Resource " + 
registeredResource.getURL()
+                      + "because of unsupported archive format \"" + extension 
+ "\" (supported are "
+                      + SUPPORTED_SOLR_ARCHIVE_FORMAT.keySet() + ")");
+            return null;
+        } else {
+            properties.put(PROPERTY_ARCHIVE_FORMAT, archiveFormat);
+        }
+
+        TransformationResult tr = new TransformationResult();
+        // try {
+        // tr.setInputStream(registeredResource.getInputStream());
+        // } catch (IOException e) {
+        // log.error(String.format("Unable to transform RegisteredResource %s 
with type %s and scheme %s",
+        // registeredResource.getURL(), registeredResource.getType(), 
registeredResource.getScheme()),e);
+        // return null;
+        // }
+        tr.setId(indexName + '.' + SOLR_INDEX_ARCHIVE_EXTENSION + '.' + 
archiveFormat);
+        tr.setAttributes(properties);
+        tr.setResourceType(SOLR_INDEX_ARCHIVE_RESOURCE_TYPE);
+        return new TransformationResult[] {tr};
+    }
+}

Propchange: 
incubator/stanbol/trunk/commons/solr/install/src/main/java/org/apache/stanbol/commons/solr/install/impl/SolrIndexInstaller.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/stanbol/trunk/commons/solr/web/pom.xml
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/solr/web/pom.xml?rev=1186729&view=auto
==============================================================================
--- incubator/stanbol/trunk/commons/solr/web/pom.xml (added)
+++ incubator/stanbol/trunk/commons/solr/web/pom.xml Thu Oct 20 10:45:42 2011
@@ -0,0 +1,121 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.stanbol</groupId>
+    <artifactId>stanbol-parent</artifactId>
+    <version>0.9.0-incubating-SNAPSHOT</version>
+    <relativePath>../../../parent</relativePath>
+  </parent>
+
+  <groupId>org.apache.stanbol</groupId>
+  <artifactId>org.apache.stanbol.commons.solr.web</artifactId>
+  <packaging>bundle</packaging>
+
+  <name>Apache Stanbol Solr Bundle</name>
+  <description>This Bundle provide an integration of the Solr RESTful API to 
+  the Stanbol JerseyEndpoint.
+  </description>
+
+  <inceptionYear>2010</inceptionYear>
+
+  <scm>
+    <connection>
+      
scm:svn:http://svn.apache.org/repos/asf/incubator/stanbol/trunk/commons/solr/web
+    </connection>
+    <developerConnection>
+      
scm:svn:https://svn.apache.org/repos/asf/incubator/stanbol/trunk/commons/solr/web
+    </developerConnection>
+    <url>http://incubator.apache.org/stanbol</url>
+  </scm>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <extensions>true</extensions>
+        <configuration>
+          <instructions>
+            <Export-Package>
+              org.apache.stanbol.commons.solr.web;version=${project.version},
+              org.apache.stanbol.commons.solr.web.*;version=${project.version},
+            </Export-Package>
+            <Import-Package>
+              *
+            </Import-Package>
+            <Private-Package>
+              
org.apache.stanbol.commons.solr.web.impl;version=${project.version},
+              
org.apache.stanbol.commons.solr.web.impl.*;version=${project.version}
+            </Private-Package>
+            <Embed-Dependency>
+            </Embed-Dependency>
+          </instructions>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-scr-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </build>
+
+  <dependencies>
+    <!-- Stanbol Commomns dependencies -->
+    <dependency>
+      <groupId>org.apache.stanbol</groupId>
+      <artifactId>org.apache.stanbol.commons.solr.core</artifactId>
+    </dependency>
+    <!--  OSGI framework dependencies -->
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.core</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.compendium</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.felix</groupId>
+      <artifactId>org.apache.felix.scr.annotations</artifactId>
+    </dependency>
+    <!-- Logging -->
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+    </dependency>
+    <!-- for tests -->
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-simple</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+</project>

Propchange: incubator/stanbol/trunk/commons/solr/web/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/stanbol/trunk/entityhub/indexing/dblp/pom.xml
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/indexing/dblp/pom.xml?rev=1186729&r1=1186728&r2=1186729&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/indexing/dblp/pom.xml (original)
+++ incubator/stanbol/trunk/entityhub/indexing/dblp/pom.xml Thu Oct 20 10:45:42 
2011
@@ -149,7 +149,7 @@
                </dependency>
         <dependency>
             <groupId>org.apache.stanbol</groupId>
-            <artifactId>org.apache.stanbol.commons.solr</artifactId>
+            <artifactId>org.apache.stanbol.commons.solr.core</artifactId>
             <scope>runtime</scope>
         </dependency>
                <dependency>

Modified: incubator/stanbol/trunk/entityhub/indexing/dbpedia/pom.xml
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/indexing/dbpedia/pom.xml?rev=1186729&r1=1186728&r2=1186729&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/indexing/dbpedia/pom.xml (original)
+++ incubator/stanbol/trunk/entityhub/indexing/dbpedia/pom.xml Thu Oct 20 
10:45:42 2011
@@ -147,7 +147,7 @@
                </dependency>
         <dependency>
             <groupId>org.apache.stanbol</groupId>
-            <artifactId>org.apache.stanbol.commons.solr</artifactId>
+            <artifactId>org.apache.stanbol.commons.solr.core</artifactId>
             <scope>runtime</scope>
         </dependency>
                <dependency>


Reply via email to