Author: ito
Date: Tue Apr 26 13:13:31 2011
New Revision: 1096743

URL: http://svn.apache.org/viewvc?rev=1096743&view=rev
Log:
CLEREZZA-501: license header updated and some minor class renamings

Added:
    
incubator/clerezza/issues/CLEREZZA-501/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/LuceneTools.java
      - copied, changed from r1095456, 
incubator/clerezza/issues/CLEREZZA-501/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/Lucene.java
Removed:
    
incubator/clerezza/issues/CLEREZZA-501/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/Lucene.java
Modified:
    
incubator/clerezza/issues/CLEREZZA-501/platform.cris/src/main/java/org/apache/clerezza/platform/cris/IndexService.java
    incubator/clerezza/issues/CLEREZZA-501/rdf.cris/core/   (props changed)
    
incubator/clerezza/issues/CLEREZZA-501/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/GraphIndexer.java
    
incubator/clerezza/issues/CLEREZZA-501/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/PropertyHolder.java
    
incubator/clerezza/issues/CLEREZZA-501/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/ResourceFinder.java

Modified: 
incubator/clerezza/issues/CLEREZZA-501/platform.cris/src/main/java/org/apache/clerezza/platform/cris/IndexService.java
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-501/platform.cris/src/main/java/org/apache/clerezza/platform/cris/IndexService.java?rev=1096743&r1=1096742&r2=1096743&view=diff
==============================================================================
--- 
incubator/clerezza/issues/CLEREZZA-501/platform.cris/src/main/java/org/apache/clerezza/platform/cris/IndexService.java
 (original)
+++ 
incubator/clerezza/issues/CLEREZZA-501/platform.cris/src/main/java/org/apache/clerezza/platform/cris/IndexService.java
 Tue Apr 26 13:13:31 2011
@@ -38,6 +38,8 @@ import org.apache.felix.scr.annotations.
 import org.apache.lucene.queryParser.ParseException;
 import org.apache.lucene.store.FSDirectory;
 import org.osgi.service.component.ComponentContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  *
@@ -46,6 +48,9 @@ import org.osgi.service.component.Compon
 @Component
 @Service(IndexService.class)
 public class IndexService extends ResourceFinder {
+
+       private final Logger logger = LoggerFactory.getLogger(getClass());
+
        IndexDefinitionManager indexDefinitionManager = null;
 
        GraphIndexer graphIndexer  = null;
@@ -69,7 +74,7 @@ public class IndexService extends Resour
                }
                File luceneIndexDir = 
context.getBundleContext().getDataFile("lucene-index");
                boolean createNewIndex = luceneIndexDir.exists();
-               System.out.println("!!!!! "+createNewIndex);
+               logger.info("Create new index: {}", !createNewIndex);
 
                indexDefinitionManager = new 
IndexDefinitionManager(definitionGraph);
                try {

Propchange: incubator/clerezza/issues/CLEREZZA-501/rdf.cris/core/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Apr 26 13:13:31 2011
@@ -0,0 +1 @@
+target

Modified: 
incubator/clerezza/issues/CLEREZZA-501/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/GraphIndexer.java
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-501/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/GraphIndexer.java?rev=1096743&r1=1096742&r2=1096743&view=diff
==============================================================================
--- 
incubator/clerezza/issues/CLEREZZA-501/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/GraphIndexer.java
 (original)
+++ 
incubator/clerezza/issues/CLEREZZA-501/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/GraphIndexer.java
 Tue Apr 26 13:13:31 2011
@@ -73,7 +73,7 @@ public class GraphIndexer extends Resour
        private Directory currentIndex;
        private int maxHitsPerPage;
        private Analyzer analyzer;
-       private Lucene lucene;
+       private LuceneTools luceneTools;
        private static final String URI_FIELD_NAME = "resource-uri";
        private Map<UriRef, Set<VirtualProperty>> type2IndexedProperties = null;
        private Map<VirtualProperty, Set<UriRef>> property2TypeMap = new 
HashMap<VirtualProperty, Set<UriRef>>();
@@ -114,9 +114,9 @@ public class GraphIndexer extends Resour
                                                        }
                                                        for (Resource resource 
: set) {
                                                                
logger.info("EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE" + resource);
-                                                               
indexResource(resource, lucene.getIndexWriter());
+                                                               
indexResource(resource, luceneTools.getIndexWriter());
                                                        }
-                                                       lucene.commitChanges();
+                                                       
luceneTools.commitChanges();
 
                                                }
                                        }
@@ -139,7 +139,7 @@ public class GraphIndexer extends Resour
                this.maxHitsPerPage = maxHitsPerPage;
                analyzer = new StandardAnalyzer(Version.LUCENE_30);
 
-               lucene = new Lucene(this.currentIndex, analyzer);
+               luceneTools = new LuceneTools(this.currentIndex, analyzer);
                processDefinitions();
 
                this.reindexer = new ReindexThread();
@@ -226,8 +226,8 @@ public class GraphIndexer extends Resour
        }
 
        public void closeLuceneIndex() {
-               this.lucene.closeIndexSearcher();
-               this.lucene.closeIndexWriter();
+               this.luceneTools.closeIndexSearcher();
+               this.luceneTools.closeIndexWriter();
        }
 
        protected void scheduleForReindex(Resource r) {
@@ -354,11 +354,11 @@ public class GraphIndexer extends Resour
        @Override
        public void optimizeIndex() {
                try {
-                       lucene.getIndexWriter(false).optimize();
+                       luceneTools.getIndexWriter(false).optimize();
                } catch (CorruptIndexException ex) {
                } catch (IOException ex) {
                } finally {
-                       lucene.commitChanges();
+                       luceneTools.commitChanges();
                }
 
        }
@@ -384,11 +384,11 @@ public class GraphIndexer extends Resour
                }
                logger.debug("instances " + instances.size());
                //val writer = new IndexWriter(index, analyzer, true, 
IndexWriter.MaxFieldLength.UNLIMITED);
-               IndexWriter writer = lucene.getIndexWriter(true);
+               IndexWriter writer = luceneTools.getIndexWriter(true);
                for (NonLiteral instance : instances) {
                        indexResource(instance, writer);
                }
-               lucene.commitChanges();
+               luceneTools.commitChanges();
        }
 
        @Override
@@ -400,7 +400,7 @@ public class GraphIndexer extends Resour
                        booleanQuery.add(c.query(), BooleanClause.Occur.MUST);
                }
                //val searcher = new IndexSearcher(index, true);
-               IndexSearcher searcher = lucene.getIndexSearcher();
+               IndexSearcher searcher = luceneTools.getIndexSearcher();
                TopScoreDocCollector testCollector = 
TopScoreDocCollector.create(1, true);
                try {
                        searcher.search(booleanQuery, testCollector);
@@ -462,7 +462,7 @@ public class GraphIndexer extends Resour
        private void indexNamedResource(UriRef uriRef, IndexWriter writer)
                        throws IOException {
                //val searcher = new IndexSearcher(index, true);
-               IndexSearcher searcher = lucene.getIndexSearcher();
+               IndexSearcher searcher = luceneTools.getIndexSearcher();
                Term term = new Term(URI_FIELD_NAME, uriRef.getUnicodeString());
                writer.deleteDocuments(term);
                //the reindexing might be caused by the removal of a type 
statement

Copied: 
incubator/clerezza/issues/CLEREZZA-501/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/LuceneTools.java
 (from r1095456, 
incubator/clerezza/issues/CLEREZZA-501/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/Lucene.java)
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-501/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/LuceneTools.java?p2=incubator/clerezza/issues/CLEREZZA-501/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/LuceneTools.java&p1=incubator/clerezza/issues/CLEREZZA-501/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/Lucene.java&r1=1095456&r2=1096743&rev=1096743&view=diff
==============================================================================
--- 
incubator/clerezza/issues/CLEREZZA-501/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/Lucene.java
 (original)
+++ 
incubator/clerezza/issues/CLEREZZA-501/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/LuceneTools.java
 Tue Apr 26 13:13:31 2011
@@ -1,18 +1,20 @@
 /*
- *  Copyright (c) 2010 trialox.org (trialox AG, Switzerland).
+ * 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
  *
- *  Licensed 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
  *
- *       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.
- *  under the License.
+ * 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.clerezza.rdf.cris;
@@ -35,7 +37,7 @@ import org.slf4j.LoggerFactory;
  *
  * @author tio
  */
-public class Lucene {
+public class LuceneTools {
 
        private final Logger logger = LoggerFactory.getLogger(getClass());
 
@@ -50,32 +52,6 @@ public class Lucene {
 
        private long lastOptimizationTimeStamp;
 
-
-
-       public Lucene(Directory indexDir, Analyzer analyzer) {
-               logger.info("activate lucene utils");
-               lastOptimizationTimeStamp = System.currentTimeMillis();
-               //luceneIndexDir = indexDir;
-               indexDirectory = indexDir;
-               if(indexDirectory instanceof FSDirectory) {
-                       luceneIndexDir = ((FSDirectory) 
indexDirectory).getFile();
-               }
-               this.analyzer = analyzer;
-       }
-
-       @Override
-       protected void finalize() {
-               logger.warn("lucene search in finalized method closed");
-               closeIndexSearcher();
-               closeIndexWriter();
-               luceneIndexDir = null;
-       }
-
-       private void close() {
-               logger.info("deactivate lucene search");
-               closeIndexSearcher();
-               closeIndexWriter();
-       }
        class IndexWriterWrapper extends IndexWriter {
 
                private boolean invokeClose;
@@ -87,10 +63,13 @@ public class Lucene {
 
                @Override
                protected void finalize() throws Throwable {
-                       super.finalize();
-                       if(invokeClose) {
-                               logger.warn("Lucene Indexwriter not explicitly 
closed.");
-                               this.close();
+                       try {
+                               if(invokeClose) {
+                                       logger.warn("Lucene Indexwriter not 
explicitly closed.");
+                                       this.close();
+                               }
+                       } finally {
+                               super.finalize();
                        }
                }
 
@@ -114,6 +93,28 @@ public class Lucene {
        }
 
 
+       public LuceneTools(Directory indexDir, Analyzer analyzer) {
+               logger.info("activate lucene tools");
+               lastOptimizationTimeStamp = System.currentTimeMillis();
+               indexDirectory = indexDir;
+               if(indexDirectory instanceof FSDirectory) {
+                       luceneIndexDir = ((FSDirectory) 
indexDirectory).getFile();
+               }
+               this.analyzer = analyzer;
+       }
+
+       @Override
+       protected void finalize() throws Throwable {
+               try {
+                       logger.warn("lucene search in finalized method closed");
+                       closeIndexSearcher();
+                       closeIndexWriter();
+                       luceneIndexDir = null;
+               } finally {
+                       super.finalize();
+               }
+       }
+
        /**
         * Return a IndexWriter
         *

Modified: 
incubator/clerezza/issues/CLEREZZA-501/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/PropertyHolder.java
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-501/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/PropertyHolder.java?rev=1096743&r1=1096742&r2=1096743&view=diff
==============================================================================
--- 
incubator/clerezza/issues/CLEREZZA-501/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/PropertyHolder.java
 (original)
+++ 
incubator/clerezza/issues/CLEREZZA-501/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/PropertyHolder.java
 Tue Apr 26 13:13:31 2011
@@ -1,18 +1,20 @@
 /*
- *  Copyright (c) 2010 trialox.org (trialox AG, Switzerland).
+ * 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
  *
- *  Licensed 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
  *
- *       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.
- *  under the License.
+ * 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.clerezza.rdf.cris;

Modified: 
incubator/clerezza/issues/CLEREZZA-501/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/ResourceFinder.java
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-501/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/ResourceFinder.java?rev=1096743&r1=1096742&r2=1096743&view=diff
==============================================================================
--- 
incubator/clerezza/issues/CLEREZZA-501/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/ResourceFinder.java
 (original)
+++ 
incubator/clerezza/issues/CLEREZZA-501/rdf.cris/core/src/main/java/org/apache/clerezza/rdf/cris/ResourceFinder.java
 Tue Apr 26 13:13:31 2011
@@ -1,18 +1,20 @@
 /*
- *  Copyright (c) 2010 trialox.org (trialox AG, Switzerland).
+ * 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
  *
- *  Licensed 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
  *
- *       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.
- *  under the License.
+ * 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.clerezza.rdf.cris;


Reply via email to