exo-jcr SVN: r5447 - ws/branches/2.3.x/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/resource.
by do-not-reply@jboss.org
Author: tolusha
Date: 2012-01-13 02:41:37 -0500 (Fri, 13 Jan 2012)
New Revision: 5447
Modified:
ws/branches/2.3.x/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/resource/ResourceDescriptorTest.java
Log:
EXOJCR-1695: cleanup sonar runtime data
Modified: ws/branches/2.3.x/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/resource/ResourceDescriptorTest.java
===================================================================
--- ws/branches/2.3.x/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/resource/ResourceDescriptorTest.java 2012-01-12 14:30:07 UTC (rev 5446)
+++ ws/branches/2.3.x/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/resource/ResourceDescriptorTest.java 2012-01-13 07:41:37 UTC (rev 5447)
@@ -477,6 +477,9 @@
{
AbstractResourceDescriptor resource = new AbstractResourceDescriptorImpl(SampleResource.class);
List<FieldInjector> fields = resource.getFieldInjectors();
+
+ cleanupSonarRuntimeData(fields);
+
assertEquals(1, fields.size());
FieldInjector f = fields.get(0);
assertEquals(String.class, f.getParameterClass());
@@ -759,9 +762,29 @@
public void testInitializeFieldSuperClass()
{
AbstractResourceDescriptor resource = new AbstractResourceDescriptorImpl(EndResource.class);
- assertEquals(6, resource.getFieldInjectors().size());
+
+ List<FieldInjector> fields = resource.getFieldInjectors();
+ cleanupSonarRuntimeData(fields);
+
+ assertEquals(6, fields.size());
}
+ /**
+ * Workaround for sonar.
+ */
+ private void cleanupSonarRuntimeData(List<FieldInjector> fields)
+ {
+ Iterator<FieldInjector> iter = fields.iterator();
+ while (iter.hasNext())
+ {
+ FieldInjector field = iter.next();
+ if (field.getName().equals("$jacocoData"))
+ {
+ iter.remove();
+ }
+ }
+ }
+
public abstract static class AbstractResource
{
@Context
14 years, 3 months
exo-jcr SVN: r5446 - core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/impl.
by do-not-reply@jboss.org
Author: tolusha
Date: 2012-01-12 09:30:07 -0500 (Thu, 12 Jan 2012)
New Revision: 5446
Modified:
core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/impl/XAPoolTxSupportDatabaseService.java
Log:
EXOJCR-1695: execute code in privileged block
Modified: core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/impl/XAPoolTxSupportDatabaseService.java
===================================================================
--- core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/impl/XAPoolTxSupportDatabaseService.java 2012-01-12 12:32:07 UTC (rev 5445)
+++ core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/impl/XAPoolTxSupportDatabaseService.java 2012-01-12 14:30:07 UTC (rev 5446)
@@ -20,12 +20,14 @@
import org.enhydra.jdbc.pool.StandardXAPoolDataSource;
import org.enhydra.jdbc.standard.StandardXADataSource;
+import org.exoplatform.commons.utils.SecurityHelper;
import org.exoplatform.container.xml.InitParams;
import org.exoplatform.container.xml.PropertiesParam;
import org.exoplatform.services.database.DatabaseService;
import org.exoplatform.services.database.ExoDatasource;
import org.exoplatform.services.transaction.TransactionService;
+import java.security.PrivilegedAction;
import java.sql.Connection;
import java.util.HashMap;
import java.util.Iterator;
@@ -94,7 +96,14 @@
private DataSource createDatasource(Map<String, String> props) throws Exception
{
- StandardXADataSource ds = new StandardXADataSource();
+ StandardXADataSource ds = SecurityHelper.doPrivilegedAction(new PrivilegedAction<StandardXADataSource>()
+ {
+ public StandardXADataSource run()
+ {
+ return new StandardXADataSource();
+ }
+ });
+
ds.setDriverName(props.get("connection.driver"));
ds.setUrl(props.get("connection.url"));
ds.setUser(props.get("connection.login"));
14 years, 3 months
exo-jcr SVN: r5445 - ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/resource.
by do-not-reply@jboss.org
Author: tolusha
Date: 2012-01-12 07:32:07 -0500 (Thu, 12 Jan 2012)
New Revision: 5445
Modified:
ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/resource/ResourceDescriptorTest.java
Log:
EXOJCR-1695: cleanup sonar runtime data
Modified: ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/resource/ResourceDescriptorTest.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/resource/ResourceDescriptorTest.java 2012-01-12 08:38:11 UTC (rev 5444)
+++ ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/resource/ResourceDescriptorTest.java 2012-01-12 12:32:07 UTC (rev 5445)
@@ -477,6 +477,9 @@
{
AbstractResourceDescriptor resource = new AbstractResourceDescriptorImpl(SampleResource.class);
List<FieldInjector> fields = resource.getFieldInjectors();
+
+ cleanupSonarRuntimeData(fields);
+
assertEquals(1, fields.size());
FieldInjector f = fields.get(0);
assertEquals(String.class, f.getParameterClass());
@@ -759,9 +762,29 @@
public void testInitializeFieldSuperClass()
{
AbstractResourceDescriptor resource = new AbstractResourceDescriptorImpl(EndResource.class);
- assertEquals(6, resource.getFieldInjectors().size());
+
+ List<FieldInjector> fields = resource.getFieldInjectors();
+ cleanupSonarRuntimeData(fields);
+
+ assertEquals(6, fields.size());
}
+ /**
+ * Workaround for sonar.
+ */
+ private void cleanupSonarRuntimeData(List<FieldInjector> fields)
+ {
+ Iterator<FieldInjector> iter = fields.iterator();
+ while (iter.hasNext())
+ {
+ FieldInjector field = iter.next();
+ if (field.getName().equals("$jacocoData"))
+ {
+ iter.remove();
+ }
+ }
+ }
+
public abstract static class AbstractResource
{
@Context
14 years, 3 months
exo-jcr SVN: r5444 - in jcr/branches/1.15.x/exo.jcr.component.core/src: test/java/org/exoplatform/services/jcr/api/core/query/lucene and 1 other directory.
by do-not-reply@jboss.org
Author: dkuleshov
Date: 2012-01-12 03:38:11 -0500 (Thu, 12 Jan 2012)
New Revision: 5444
Added:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/TextFieldExtractor.java
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractIndex.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexingQueue.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexingQueueStore.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/LazyTextExtractorField.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NodeIndexer.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/OfflinePersistentIndex.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/PersistentIndex.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/TextExtractorJob.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/TextExtractorReader.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/Util.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/VolatileIndex.java
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/core/query/lucene/IndexingAggregateTest.java
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/core/query/lucene/IndexingQueueTest.java
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/core/query/lucene/TestAll.java
Log:
EXOJCR-1629:
Removed some unnecessary classes:
- IndexingQueue
- TextExctractorReader
and all dependenant classes and tests
Reorganized LazyTextExctractorField class to TextFieldExtractor to keep the ability to serialize fields (for clustering)
Some code cleaning
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractIndex.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractIndex.java 2012-01-12 08:07:55 UTC (rev 5443)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractIndex.java 2012-01-12 08:38:11 UTC (rev 5444)
@@ -31,9 +31,7 @@
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
-import java.io.StringReader;
import java.util.BitSet;
-import java.util.Iterator;
/**
* Implements common functionality for a lucene index.
@@ -99,11 +97,6 @@
private ReadOnlyIndexReader readOnlyReader;
/**
- * The indexing queue.
- */
- private IndexingQueue indexingQueue;
-
- /**
* Flag that indicates whether there was an index present in the directory
* when this AbstractIndex was created.
*/
@@ -119,17 +112,15 @@
* @param cache the document number cache if this index should use
* one; otherwise <code>cache</code> is
* <code>null</code>.
- * @param indexingQueue the indexing queue.
* @throws IOException if the index cannot be initialized.
*/
- AbstractIndex(final Analyzer analyzer, Similarity similarity, final Directory directory, DocNumberCache cache,
- IndexingQueue indexingQueue) throws IOException
+ AbstractIndex(final Analyzer analyzer, Similarity similarity, final Directory directory, DocNumberCache cache)
+ throws IOException
{
this.analyzer = analyzer;
this.similarity = similarity;
this.directory = directory;
this.cache = cache;
- this.indexingQueue = indexingQueue;
AbstractIndex.this.isExisting = IndexReader.indexExists(directory);
@@ -177,8 +168,7 @@
DynamicPooledExecutor.Command[] commands = new DynamicPooledExecutor.Command[docs.length];
for (int i = 0; i < docs.length; i++)
{
- // check if text extractor completed its work
- final Document doc = getFinishedDocument(docs[i]);
+ final Document doc = docs[i];
// create a command for inverting the document
commands[i] = new DynamicPooledExecutor.Command()
{
@@ -516,64 +506,6 @@
}
}
- /**
- * Returns a document that is finished with text extraction and is ready to
- * be added to the index.
- *
- * @param doc the document to check.
- * @return <code>doc</code> if it is finished already or a stripped down
- * copy of <code>doc</code> without text extractors.
- * @throws IOException if the document cannot be added to the indexing
- * queue.
- */
- private Document getFinishedDocument(Document doc) throws IOException
- {
- if (!Util.isDocumentReady(doc))
- {
- Document copy = new Document();
- // mark the document that reindexing is required
- copy.add(new Field(FieldNames.REINDEXING_REQUIRED, "", Field.Store.NO, Field.Index.NOT_ANALYZED_NO_NORMS));
- Iterator fields = doc.getFields().iterator();
- while (fields.hasNext())
- {
- Fieldable f = (Fieldable)fields.next();
- Fieldable field = null;
- Field.TermVector tv = getTermVectorParameter(f);
- Field.Store stored = getStoreParameter(f);
- Field.Index indexed = getIndexParameter(f);
- if (f instanceof LazyTextExtractorField || f.readerValue() != null)
- {
- // replace all readers with empty string reader
- field = new Field(f.name(), new StringReader(""), tv);
- }
- else if (f.stringValue() != null)
- {
- field = new Field(f.name(), f.stringValue(), stored, indexed, tv);
- }
- else if (f.isBinary())
- {
- field = new Field(f.name(), f.binaryValue(), stored);
- }
- if (field != null)
- {
- field.setOmitNorms(f.getOmitNorms());
- copy.add(field);
- }
- }
- // schedule the original document for later indexing
- Document existing = indexingQueue.addDocument(doc);
- if (existing != null)
- {
- // the queue already contained a pending document for this
- // node. -> dispose the document
- Util.disposeDocument(existing);
- }
- // use the stripped down copy for now
- doc = copy;
- }
- return doc;
- }
-
//-------------------------< properties >-----------------------------------
/**
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexingQueue.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexingQueue.java 2012-01-12 08:07:55 UTC (rev 5443)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexingQueue.java 2012-01-12 08:38:11 UTC (rev 5444)
@@ -1,238 +0,0 @@
-/*
- * 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.exoplatform.services.jcr.impl.core.query.lucene;
-
-import org.apache.lucene.document.Document;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.index.TermDocs;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.jcr.RepositoryException;
-
-/**
- * <code>IndexingQueue</code> implements a queue which contains all the
- * documents with pending text extractor jobs.
- */
-public class IndexingQueue
-{
-
- /**
- * Logger instance for this class.
- */
- private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.IndexingQueue");
-
- /**
- * The store to persist uuids of pending documents.
- */
- private final IndexingQueueStore queueStore;
-
- /**
- * Maps UUID {@link String}s to {@link Document}s.
- */
- private final Map pendingDocuments = new HashMap(1);
-
- /**
- * Flag that indicates whether this indexing queue had been
- * {@link #initialize(MultiIndex) initialized}.
- */
- private volatile boolean initialized = false;
-
- /**
- * Creates an indexing queue.
- *
- * @param queueStore the store where to read the pending extraction jobs.
- */
- IndexingQueue(IndexingQueueStore queueStore)
- {
- this.queueStore = queueStore;
- }
-
- /**
- * Initializes the indexing queue.
- *
- * @param index the multi index this indexing queue belongs to.
- * @throws IOException if an error occurs while reading from the index.
- */
- void initialize(final MultiIndex index) throws IOException
- {
- if (initialized)
- {
- throw new IllegalStateException("already initialized");
- }
- // check index for nodes that need to be reindexed
- CachingMultiIndexReader reader = index.getIndexReader();
- try
- {
- TermDocs tDocs = reader.termDocs(new Term(FieldNames.REINDEXING_REQUIRED, ""));
- try
- {
- while (tDocs.next())
- {
- queueStore.addUUID(reader.document(tDocs.doc(), FieldSelectors.UUID).get(FieldNames.UUID));
- }
- }
- finally
- {
- tDocs.close();
- }
- }
- finally
- {
- reader.release();
- }
- String[] uuids = queueStore.getPending();
- for (int i = 0; i < uuids.length; i++)
- {
- try
- {
- Document doc = index.createDocument(uuids[i]);
- pendingDocuments.put(uuids[i], doc);
- log.debug("added node {}. New size of indexing queue: {}", uuids[i], new Integer(pendingDocuments.size()));
- }
- catch (IllegalArgumentException e)
- {
- log.warn("Invalid UUID in indexing queue store: " + uuids[i]);
- }
- catch (RepositoryException e)
- {
- // node does not exist anymore
- log.debug("Node with uuid {} does not exist anymore", uuids[i]);
- queueStore.removeUUID(uuids[i]);
- }
- }
- initialized = true;
- }
-
- /**
- * Returns the {@link Document}s that are finished.
- *
- * @return the {@link Document}s that are finished.
- */
- public Document[] getFinishedDocuments()
- {
- checkInitialized();
- List finished = new ArrayList(1);
- synchronized (this)
- {
- finished.addAll(pendingDocuments.values());
- }
-
- Iterator it = finished.iterator();
- while (it.hasNext())
- {
- Document doc = (Document)it.next();
- if (!Util.isDocumentReady(doc))
- {
- it.remove();
- }
- }
- return (Document[])finished.toArray(new Document[finished.size()]);
- }
-
- /**
- * Removes the document with the given <code>uuid</code> from the indexing
- * queue.
- *
- * @param uuid the uuid of the document to return.
- * @return the document for the given <code>uuid</code> or <code>null</code>
- * if this queue does not contain a document with the given
- * <code>uuid</code>.
- */
- public synchronized Document removeDocument(String uuid)
- {
- checkInitialized();
- Document doc = (Document)pendingDocuments.remove(uuid);
- if (doc != null)
- {
- queueStore.removeUUID(uuid);
- log.debug("removed node {}. New size of indexing queue: {}", uuid, new Integer(pendingDocuments.size()));
- }
- return doc;
- }
-
- /**
- * Adds a document to this indexing queue.
- *
- * @param doc the document to add.
- * @return an existing document in the queue with the same uuid as the one
- * in <code>doc</code> or <code>null</code> if there was no such
- * document.
- */
- public synchronized Document addDocument(Document doc)
- {
- checkInitialized();
- String uuid = doc.get(FieldNames.UUID);
- Document existing = (Document)pendingDocuments.put(uuid, doc);
- log.debug("added node {}. New size of indexing queue: {}", uuid, new Integer(pendingDocuments.size()));
- if (existing == null)
- {
- // document wasn't present, add it to the queue store
- queueStore.addUUID(uuid);
- }
- // return existing if any
- return existing;
- }
-
- /**
- * Closes this indexing queue and disposes all pending documents.
- */
- public synchronized void close()
- {
- checkInitialized();
- // go through pending documents and close readers
- Iterator it = pendingDocuments.values().iterator();
- while (it.hasNext())
- {
- Document doc = (Document)it.next();
- Util.disposeDocument(doc);
- it.remove();
- }
- queueStore.close();
- }
-
- /**
- * Checks if this indexing queue is initialized and otherwise throws a
- * {@link IllegalStateException}.
- */
- private void checkInitialized()
- {
- if (!initialized)
- {
- throw new IllegalStateException("not initialized");
- }
- }
-
- //----------------------------< testing only >------------------------------
-
- /**
- * <b>This method is for testing only!</b>
- *
- * @return the number of the currently pending documents.
- */
- public synchronized int getNumPendingDocuments()
- {
- return pendingDocuments.size();
- }
-}
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexingQueueStore.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexingQueueStore.java 2012-01-12 08:07:55 UTC (rev 5443)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexingQueueStore.java 2012-01-12 08:38:11 UTC (rev 5444)
@@ -1,188 +0,0 @@
-/*
- * 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.exoplatform.services.jcr.impl.core.query.lucene;
-
-import org.apache.lucene.store.Directory;
-import org.exoplatform.services.jcr.impl.core.query.lucene.directory.IndexInputStream;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * <code>IndexingQueueStore</code> implements a store that keeps the uuids of
- * nodes that are pending in the indexing queue. Until Jackrabbit 1.4 this store
- * was also persisted to disk. Starting with 1.5 the pending
- * nodes are marked directly in the index with a special field.
- * See {@link FieldNames#REINDEXING_REQUIRED}.
- */
-class IndexingQueueStore
-{
-
- /**
- * The logger instance for this class.
- */
- private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.IndexingQueueStore");
-
- /**
- * Encoding of the indexing queue store.
- */
- private static final String ENCODING = "UTF-8";
-
- /**
- * Operation identifier for an added node.
- */
- private static final String ADD = "ADD";
-
- /**
- * Operation identifier for an removed node.
- */
- private static final String REMOVE = "REMOVE";
-
- /**
- * Name of the file that contains the indexing queue log.
- */
- private static final String INDEXING_QUEUE_FILE = "indexing_queue.log";
-
- /**
- * The UUID Strings of the pending documents.
- */
- private final Set pending = new HashSet();
-
- /**
- * The directory from where to read pending document UUIDs.
- */
- private final Directory dir;
-
- /**
- * Creates a new <code>IndexingQueueStore</code> using the given directory.
- *
- * @param directory the directory to use.
- * @throws IOException if an error ocurrs while reading pending UUIDs.
- */
- IndexingQueueStore(Directory directory) throws IOException
- {
- this.dir = directory;
- readStore();
- }
-
- /**
- * @return the UUIDs of the pending text extraction jobs.
- */
- public String[] getPending()
- {
- return (String[])pending.toArray(new String[pending.size()]);
- }
-
- /**
- * Adds a <code>uuid</code> to the store.
- *
- * @param uuid the uuid to add.
- */
- public void addUUID(String uuid)
- {
- pending.add(uuid);
- }
-
- /**
- * Removes a <code>uuid</code> from the store.
- *
- * @param uuid the uuid to add.
- */
- public void removeUUID(String uuid)
- {
- pending.remove(uuid);
- }
-
- /**
- * Closes this queue store.
- */
- public void close()
- {
- if (pending.isEmpty())
- {
- try
- {
- if (dir.fileExists(INDEXING_QUEUE_FILE))
- {
- dir.deleteFile(INDEXING_QUEUE_FILE);
- }
- }
- catch (IOException e)
- {
- log.warn("unable to delete " + INDEXING_QUEUE_FILE);
- }
- }
- }
-
- //----------------------------< internal >----------------------------------
-
- /**
- * Reads all pending UUIDs from the file and puts them into {@link
- * #pending}.
- *
- * @throws IOException if an error occurs while reading.
- */
- private void readStore() throws IOException
- {
- if (dir.fileExists(INDEXING_QUEUE_FILE))
- {
- InputStream in = new IndexInputStream(dir.openInput(INDEXING_QUEUE_FILE));
- BufferedReader reader = new BufferedReader(new InputStreamReader(in, ENCODING));
- try
- {
- String line;
- while ((line = reader.readLine()) != null)
- {
- int idx = line.indexOf(' ');
- if (idx == -1)
- {
- // invalid line
- log.warn("invalid line in {}: {}", INDEXING_QUEUE_FILE, line);
- }
- else
- {
- String cmd = line.substring(0, idx);
- String uuid = line.substring(idx + 1, line.length());
- if (ADD.equals(cmd))
- {
- pending.add(uuid);
- }
- else if (REMOVE.equals(cmd))
- {
- pending.remove(uuid);
- }
- else
- {
- // invalid line
- log.warn("invalid line in {}: {}", INDEXING_QUEUE_FILE, line);
- }
- }
- }
- }
- finally
- {
- in.close();
- }
- }
- }
-}
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/LazyTextExtractorField.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/LazyTextExtractorField.java 2012-01-12 08:07:55 UTC (rev 5443)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/LazyTextExtractorField.java 2012-01-12 08:38:11 UTC (rev 5444)
@@ -1,167 +0,0 @@
-/*
- * 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.exoplatform.services.jcr.impl.core.query.lucene;
-
-import org.apache.lucene.analysis.TokenStream;
-import org.apache.lucene.document.AbstractField;
-import org.apache.lucene.document.Field;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.io.Reader;
-
-/**
- * <code>LazyTextExtractorField</code> implements a Lucene field with a String
- * value that is lazily initialized from a given {@link Reader}. In addition
- * this class provides a method to find out whether the purpose of the reader
- * is to extract text and whether the extraction process is already finished.
- *
- * @see #isExtractorFinished()
- */
-public class LazyTextExtractorField extends AbstractField
-{
-
- /**
- * The serial version UID.
- */
- private static final long serialVersionUID = -2707986404659820071L;
-
- /**
- * The logger instance for this class.
- */
- private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.LazyTextExtractorField");
-
- /**
- * The reader from where to read the text extract.
- */
- private final Reader reader;
-
- /**
- * The extract as obtained lazily from {@link #reader}.
- */
- volatile private String extract;
-
- /**
- * Creates a new <code>LazyTextExtractorField</code> with the given
- * <code>name</code>.
- *
- * @param name the name of the field.
- * @param reader the reader where to obtain the string from.
- * @param store when set <code>true</code> the string value is stored in the
- * index.
- * @param withOffsets when set <code>true</code> a term vector with offsets
- * is written into the index.
- */
- public LazyTextExtractorField(String name, Reader reader, boolean store, boolean withOffsets)
- {
- super(name, store ? Field.Store.YES : Field.Store.NO, Field.Index.ANALYZED, withOffsets
- ? Field.TermVector.WITH_OFFSETS : Field.TermVector.NO);
- this.reader = reader;
- }
-
- /**
- * @return the string value of this field.
- */
- public String stringValue()
- {
- if (extract == null)
- {
- synchronized (this)
- {
- if (extract == null)
- {
- StringBuffer textExtract = new StringBuffer();
- char[] buffer = new char[1024];
- int len;
- try
- {
- while ((len = reader.read(buffer)) > -1)
- {
- textExtract.append(buffer, 0, len);
- }
- }
- catch (IOException e)
- {
- log.warn("Exception reading value for field: " + e.getMessage());
- log.debug("Dump:", e);
- }
- finally
- {
- try
- {
- reader.close();
- }
- catch (IOException e)
- {
- log.error(e.getLocalizedMessage(), e);
- }
- }
- extract = textExtract.toString();
- }
- }
- }
- return extract;
- }
-
- /**
- * @return always <code>null</code>.
- */
- public Reader readerValue()
- {
- return null;
- }
-
- /**
- * @return always <code>null</code>.
- */
- public byte[] binaryValue()
- {
- return null;
- }
-
- /**
- * @return always <code>null</code>.
- */
- public TokenStream tokenStreamValue()
- {
- return null;
- }
-
- /**
- * @return <code>true</code> if the underlying reader is ready to provide
- * extracted text.
- */
- public boolean isExtractorFinished()
- {
- if (reader instanceof TextExtractorReader)
- {
- return ((TextExtractorReader)reader).isExtractorFinished();
- }
- return true;
- }
-
- /**
- * Disposes this field and closes the underlying reader.
- *
- * @throws IOException if an error occurs while closing the reader.
- */
- public void dispose() throws IOException
- {
- reader.close();
- }
-}
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java 2012-01-12 08:07:55 UTC (rev 5443)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java 2012-01-12 08:38:11 UTC (rev 5444)
@@ -217,11 +217,6 @@
private RedoLog redoLog = null;
/**
- * The indexing queue with pending text extraction jobs.
- */
- private IndexingQueue indexingQueue;
-
- /**
* Set<NodeId> of uuids that should not be indexed.
*/
private final IndexingTree indexingTree;
@@ -332,20 +327,13 @@
continue;
}
PersistentIndex index =
- new PersistentIndex(name, handler.getTextAnalyzer(), handler.getSimilarity(), cache, indexingQueue,
- directoryManager);
+ new PersistentIndex(name, handler.getTextAnalyzer(), handler.getSimilarity(), cache, directoryManager);
index.setMaxFieldLength(handler.getMaxFieldLength());
index.setUseCompoundFile(handler.getUseCompoundFile());
index.setTermInfosIndexDivisor(handler.getTermInfosIndexDivisor());
indexes.add(index);
}
- // this method is run in privileged mode internally
- IndexingQueueStore store = new IndexingQueueStore(indexDir);
-
- // initialize indexing queue
- this.indexingQueue = new IndexingQueue(store);
-
// init volatile index
resetVolatileIndex();
@@ -360,7 +348,6 @@
{
reader.release();
}
- indexingQueue.initialize(this);
if (modeHandler.getMode() == IndexerIoMode.READ_WRITE)
{
// will also initialize IndexMerger
@@ -1082,7 +1069,7 @@
try
{
index =
- new PersistentIndex(indexName, handler.getTextAnalyzer(), handler.getSimilarity(), cache, indexingQueue,
+ new PersistentIndex(indexName, handler.getTextAnalyzer(), handler.getSimilarity(), cache,
directoryManager);
}
catch (IOException e)
@@ -1391,9 +1378,6 @@
(indexes.get(i)).close();
}
- // close indexing queue
- indexingQueue.close();
-
// finally close directory
try
{
@@ -1438,16 +1422,6 @@
}
/**
- * Returns the indexing queue for this multi index.
- *
- * @return the indexing queue for this multi index.
- */
- public IndexingQueue getIndexingQueue()
- {
- return indexingQueue;
- }
-
- /**
* Returns a lucene Document for the <code>node</code>.
*
* @param node
@@ -1680,8 +1654,6 @@
@Override
public void run()
{
- // check if there are any indexing jobs finished
- checkIndexingQueue();
// check if volatile index should be flushed
checkFlush();
}
@@ -1696,7 +1668,7 @@
*/
private void resetVolatileIndex() throws IOException
{
- volatileIndex = new VolatileIndex(handler.getTextAnalyzer(), handler.getSimilarity(), indexingQueue);
+ volatileIndex = new VolatileIndex(handler.getTextAnalyzer(), handler.getSimilarity());
volatileIndex.setUseCompoundFile(handler.getUseCompoundFile());
volatileIndex.setMaxFieldLength(handler.getMaxFieldLength());
volatileIndex.setBufferSize(handler.getBufferSize());
@@ -1847,10 +1819,6 @@
synchronized (this)
{
- if (count.get() % 10 == 0)
- {
- checkIndexingQueue(true);
- }
checkVolatileCommit();
}
@@ -1977,10 +1945,6 @@
synchronized (this)
{
- if (count.get() % 10 == 0)
- {
- checkIndexingQueue(true);
- }
checkVolatileCommit();
}
}
@@ -2119,76 +2083,6 @@
}
}
- /**
- * Checks the indexing queue for finished text extrator jobs and updates the
- * index accordingly if there are any new ones. This method is synchronized
- * and should only be called by the timer task that periodically checks if
- * there are documents ready in the indexing queue. A new transaction is
- * used when documents are transfered from the indexing queue to the index.
- */
- private synchronized void checkIndexingQueue()
- {
- checkIndexingQueue(false);
- }
-
- /**
- * Checks the indexing queue for finished text extrator jobs and updates the
- * index accordingly if there are any new ones.
- *
- * @param transactionPresent
- * whether a transaction is in progress and the current
- * {@link #getTransactionId()} should be used. If
- * <code>false</code> a new transaction is created when documents
- * are transfered from the indexing queue to the index.
- */
- private void checkIndexingQueue(boolean transactionPresent)
- {
- // EXOJCR-1337, have been commented since it is not used
- // Document[] docs = indexingQueue.getFinishedDocuments();
- // Map<String, Document> finished = new HashMap<String, Document>();
- // for (int i = 0; i < docs.length; i++)
- // {
- // String uuid = docs[i].get(FieldNames.UUID);
- // finished.put(uuid, docs[i]);
- // }
- //
- // // now update index with the remaining ones if there are any
- // if (!finished.isEmpty())
- // {
- // log.info("updating index with {} nodes from indexing queue.", new Long(finished.size()));
- //
- // // remove documents from the queue
- // for (Iterator<String> it = finished.keySet().iterator(); it.hasNext();)
- // {
- // indexingQueue.removeDocument(it.next().toString());
- // }
- //
- // try
- // {
- // if (transactionPresent)
- // {
- // for (Iterator<String> it = finished.keySet().iterator(); it.hasNext();)
- // {
- // executeAndLog(new DeleteNode(getTransactionId(), it.next()));
- // }
- // for (Iterator<Document> it = finished.values().iterator(); it.hasNext();)
- // {
- // executeAndLog(new AddNode(getTransactionId(), it.next()));
- // }
- // }
- // else
- // {
- // update(finished.keySet(), finished.values());
- // }
- // }
- // catch (IOException e)
- // {
- // // update failed
- // log.warn("Failed to update index with deferred text extraction", e);
- // }
- // }
- }
-
// ------------------------< Actions
// >---------------------------------------
@@ -3001,13 +2895,6 @@
public void execute(MultiIndex index) throws IOException
{
String uuidString = uuid.toString();
- // check if indexing queue is still working on
- // this node from a previous update
- Document doc = index.indexingQueue.removeDocument(uuidString);
- if (doc != null)
- {
- Util.disposeDocument(doc);
- }
Term idTerm = new Term(FieldNames.UUID, uuidString);
// if the document cannot be deleted from the volatile index
// delete it from one of the persistent indexes.
@@ -3363,7 +3250,7 @@
continue;
}
PersistentIndex index =
- new PersistentIndex(name, handler.getTextAnalyzer(), handler.getSimilarity(), cache, indexingQueue,
+ new PersistentIndex(name, handler.getTextAnalyzer(), handler.getSimilarity(), cache,
directoryManager);
index.setMaxFieldLength(handler.getMaxFieldLength());
index.setUseCompoundFile(handler.getUseCompoundFile());
@@ -3456,8 +3343,7 @@
merger = null;
}
offlineIndex =
- new OfflinePersistentIndex(handler.getTextAnalyzer(), handler.getSimilarity(), cache, indexingQueue,
- directoryManager);
+ new OfflinePersistentIndex(handler.getTextAnalyzer(), handler.getSimilarity(), cache, directoryManager);
if (modeHandler.getMode() == IndexerIoMode.READ_WRITE)
{
flush();
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NodeIndexer.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NodeIndexer.java 2012-01-12 08:07:55 UTC (rev 5443)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NodeIndexer.java 2012-01-12 08:38:11 UTC (rev 5444)
@@ -884,11 +884,11 @@
{
if (supportHighlighting)
{
- return new LazyTextExtractorField(FieldNames.FULLTEXT, value, true, true);
+ return new TextFieldExtractor(FieldNames.FULLTEXT, value, true, true);
}
else
{
- return new LazyTextExtractorField(FieldNames.FULLTEXT, value, false, false);
+ return new TextFieldExtractor(FieldNames.FULLTEXT, value, false, false);
}
}
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/OfflinePersistentIndex.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/OfflinePersistentIndex.java 2012-01-12 08:07:55 UTC (rev 5443)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/OfflinePersistentIndex.java 2012-01-12 08:38:11 UTC (rev 5444)
@@ -50,15 +50,14 @@
* @param analyzer the analyzer for text tokenizing.
* @param similarity the similarity implementation.
* @param cache the document number cache
- * @param indexingQueue the indexing queue.
* @param directoryManager the directory manager.
* @throws IOException if an error occurs while opening / creating the
* index.
*/
- OfflinePersistentIndex(Analyzer analyzer, Similarity similarity, DocNumberCache cache, IndexingQueue indexingQueue,
+ OfflinePersistentIndex(Analyzer analyzer, Similarity similarity, DocNumberCache cache,
DirectoryManager directoryManager) throws IOException
{
- super(NAME, analyzer, similarity, cache, indexingQueue, directoryManager);
+ super(NAME, analyzer, similarity, cache, directoryManager);
this.processedIDs = new ArrayList<String>();
}
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/PersistentIndex.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/PersistentIndex.java 2012-01-12 08:07:55 UTC (rev 5443)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/PersistentIndex.java 2012-01-12 08:38:11 UTC (rev 5444)
@@ -50,15 +50,14 @@
* @param analyzer the analyzer for text tokenizing.
* @param similarity the similarity implementation.
* @param cache the document number cache
- * @param indexingQueue the indexing queue.
* @param directoryManager the directory manager.
* @throws IOException if an error occurs while opening / creating the
* index.
*/
PersistentIndex(String name, Analyzer analyzer, Similarity similarity, DocNumberCache cache,
- IndexingQueue indexingQueue, final DirectoryManager directoryManager) throws IOException
+ final DirectoryManager directoryManager) throws IOException
{
- super(analyzer, similarity, directoryManager.getDirectory(name), cache, indexingQueue);
+ super(analyzer, similarity, directoryManager.getDirectory(name), cache);
this.name = name;
if (isExisting())
{
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/TextExtractorJob.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/TextExtractorJob.java 2012-01-12 08:07:55 UTC (rev 5443)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/TextExtractorJob.java 2012-01-12 08:38:11 UTC (rev 5444)
@@ -1,274 +0,0 @@
-/*
- * 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.exoplatform.services.jcr.impl.core.query.lucene;
-
-import EDU.oswego.cs.dl.util.concurrent.Callable;
-import EDU.oswego.cs.dl.util.concurrent.FutureResult;
-
-import org.exoplatform.commons.utils.PrivilegedFileHelper;
-import org.exoplatform.services.document.DocumentReader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.io.Reader;
-import java.io.StringReader;
-import java.io.Writer;
-import java.lang.reflect.InvocationTargetException;
-
-/**
- * <code>TextExtractorJob</code> implements a future result and is runnable
- * in a background thread.
- */
-public class TextExtractorJob extends FutureResult implements Runnable
-{
-
- /**
- * UTF-8 encoding.
- */
- private static final String ENCODING_UTF8 = "UTF-8";
-
- /**
- * The logger instance for this class.
- */
- private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.TextExtractorJob");
-
- /**
- * The command of the future result.
- */
- private final Runnable cmd;
-
- /**
- * The mime type of the resource to extract text from.
- */
- private final String type;
-
- /**
- * Set to <code>true</code> if this job timed out.
- */
- private transient boolean timedOut = false;
-
- /**
- * <code>true</code> if this extractor job has been flaged as discarded.
- */
- private transient boolean discarded = false;
-
- /**
- * Creates a new <code>TextExtractorJob</code> with the given
- * <code>extractor</code> on the <code>stream</code>.
- *
- * @param extractor the text extractor
- * @param stream the stream of the binary property.
- * @param type the mime-type of the binary content.
- * @param encoding the encoding of the binary content. May be
- * <code>null</code>.
- */
- public TextExtractorJob(final DocumentReader extractor, final InputStream stream, final String type,
- final String encoding)
- {
- this.type = type;
- this.cmd = setter(new Callable()
- {
- public Object call() throws Exception
- {
- Reader r = new StringReader(extractor.getContentAsText(stream, encoding));
- if (r != null)
- {
- if (discarded)
- {
- r.close();
- r = null;
- }
- else if (timedOut)
- {
- // spool a temp file to save memory
- r = getSwappedOutReader(r);
- }
- }
- return r;
- }
- });
- }
-
- /**
- * Returns the reader with the extracted text from the input stream passed
- * to the constructor of this <code>TextExtractorJob</code>. The caller of
- * this method is responsible for closing the returned reader. Returns
- * <code>null</code> if a <code>timeout</code>occurs while waiting for the
- * text extractor to get the reader.
- *
- * @return the Reader with the extracted text. Returns <code>null</code> if
- * a timeout or an exception occured extracting the text.
- */
- public Reader getReader(long timeout)
- {
- Reader reader = null;
- try
- {
- reader = (Reader)timedGet(timeout);
- }
- catch (InterruptedException e)
- {
- // also covers TimeoutException
- // text not extracted within timeout or interrupted
- if (timeout > 0)
- {
- log.debug("Text extraction for {} timed out (>{}ms).", type, new Long(timeout));
- timedOut = true;
- }
- }
- catch (InvocationTargetException e)
- {
- // extraction failed
- log.warn("Exception while indexing binary property: " + e.getCause());
- log.debug("Dump: ", e.getCause());
- }
- return reader;
- }
-
- /**
- * Discards this extractor job. If the reader within this job is ready at
- * the time of this call, it is closed. If the reader is not yet ready this
- * job will be flaged as discarded and any later call to
- * {@link #getReader(long)} will return <code>null</code>. The reader that
- * is about to be constructed by a background thread will be closed
- * automatically as soon as it becomes ready.
- */
- void discard()
- {
- discarded = true;
- Reader r = (Reader)peek();
- if (r != null)
- {
- try
- {
- r.close();
- }
- catch (IOException e)
- {
- log.warn("Exception when trying to discard extractor job: " + e);
- }
- }
- }
-
- /**
- * @return a String description for this job with the mime type.
- */
- @Override
- public String toString()
- {
- return "TextExtractorJob for " + type;
- }
-
- //----------------------------< Runnable >----------------------------------
-
- /**
- * Runs the actual text extraction.
- */
- public void run()
- {
- // forward to command
- cmd.run();
- }
-
- //----------------------------< internal >----------------------------------
-
- /**
- * Returns a <code>Reader</code> for <code>r</code> using a temp file.
- *
- * @param r the reader to swap out into a temp file.
- * @return a reader to the temp file.
- */
- private Reader getSwappedOutReader(Reader r)
- {
- final File temp;
- try
- {
- temp = PrivilegedFileHelper.createTempFile("extractor", null);
- }
- catch (IOException e)
- {
- // unable to create temp file
- // return reader as is
- return r;
- }
- Writer out;
- try
- {
- out = new BufferedWriter(new OutputStreamWriter(PrivilegedFileHelper.fileOutputStream(temp), ENCODING_UTF8));
- }
- catch (IOException e)
- {
- // should never happend actually
- if (!temp.delete())
- {
- PrivilegedFileHelper.deleteOnExit(temp);
- }
- return r;
- }
-
- // spool into temp file
- InputStream in = null;
- try
- {
- try
- {
- //IOUtils.copy(r, out);
- out.close();
- }
- finally
- {
- r.close();
- }
- //in = new LazyFileInputStream(temp);
-
- return new InputStreamReader(in, ENCODING_UTF8)
- {
- @Override
- public void close() throws IOException
- {
- super.close();
- // delete file
- if (!temp.delete())
- {
- PrivilegedFileHelper.deleteOnExit(temp);
- }
- }
- };
- }
- catch (IOException e)
- {
- // do some clean up
- //IOUtils.closeQuietly(out);
- //IOUtils.closeQuietly(in);
- //out.close();
- //in.close();
-
- if (!temp.delete())
- {
- PrivilegedFileHelper.deleteOnExit(temp);
- }
- // use empty string reader as fallback
- return new StringReader("");
- }
- }
-}
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/TextExtractorReader.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/TextExtractorReader.java 2012-01-12 08:07:55 UTC (rev 5443)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/TextExtractorReader.java 2012-01-12 08:38:11 UTC (rev 5444)
@@ -1,149 +0,0 @@
-/*
- * 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.exoplatform.services.jcr.impl.core.query.lucene;
-
-import java.io.IOException;
-import java.io.Reader;
-import java.io.StringReader;
-
-import EDU.oswego.cs.dl.util.concurrent.DirectExecutor;
-import EDU.oswego.cs.dl.util.concurrent.Executor;
-
-/**
- * <code>TextExtractorReader</code> implements a specialized reader that runs
- * the text extractor in a background thread.
- */
-class TextExtractorReader extends Reader {
-
- /**
- * A direct executor in case text extraction is requested for immediate use.
- */
- private static final Executor DIRECT_EXECUTOR = new DirectExecutor();
-
- /**
- * Reference to the extracted text. This reference is initially
- * <code>null</code> and later set to a valid reader when the text extractor
- * finished its work.
- */
- private Reader extractedText;
-
- /**
- * The extractor job.
- */
- private TextExtractorJob job;
-
- /**
- * The pooled executor.
- */
- private final Executor executor;
-
- /**
- * The timeout in milliseconds to wait at most for the text extractor
- * when {@link #isExtractorFinished()} is called.
- */
- private final long timeout;
-
- /**
- * Set to <code>true</code> when the text extractor job has been started
- * and is running.
- */
- private boolean jobStarted = false;
-
- /**
- * Creates a new <code>TextExtractorReader</code> with the given
- * <code>job</code>.
- *
- * @param job the extractor job.
- * @param executor the executor to use when text extraction is requested.
- * @param timeout the timeout to wait at most for the text extractor.
- */
- TextExtractorReader(TextExtractorJob job, Executor executor, long timeout) {
- this.job = job;
- this.executor = executor;
- this.timeout = timeout;
- }
-
- /**
- * Closes this reader and discards the contained {@link TextExtractorJob}.
- *
- * @throws IOException if an error occurs while closing this reader.
- */
- public void close() throws IOException {
- if (extractedText != null) {
- extractedText.close();
- }
- if (jobStarted) {
- job.discard();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public int read(char[] cbuf, int off, int len) throws IOException {
- if (extractedText == null) {
- // no reader present
- // check if job is started already
- if (jobStarted) {
- // wait until available
- extractedText = job.getReader(Long.MAX_VALUE);
- } else {
- // execute with current thread
- try {
- DIRECT_EXECUTOR.execute(job);
- } catch (InterruptedException e) {
- // current thread is in interrupted state
- // -> ignore (job will not return a reader, which is fine)
- }
- extractedText = job.getReader(0);
- }
-
- if (extractedText == null) {
- // exception occurred
- extractedText = new StringReader("");
- }
- }
- return extractedText.read(cbuf, off, len);
- }
-
- /**
- * @return <code>true</code> if the text extractor within this reader has
- * finished its work and this reader will return extracted text.
- */
- public boolean isExtractorFinished() {
- if (!jobStarted) {
- try {
- executor.execute(job);
- jobStarted = true;
- } catch (InterruptedException e) {
- // this thread is in interrupted state
- return false;
- }
- extractedText = job.getReader(timeout);
- } else {
- // job is already running, check for immediate result
- extractedText = job.getReader(0);
- }
-
- if (extractedText == null && job.getException() != null) {
- // exception occurred
- extractedText = new StringReader("");
- }
-
- return extractedText != null;
- }
-}
Added: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/TextFieldExtractor.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/TextFieldExtractor.java (rev 0)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/TextFieldExtractor.java 2012-01-12 08:38:11 UTC (rev 5444)
@@ -0,0 +1,146 @@
+/*
+ * 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.exoplatform.services.jcr.impl.core.query.lucene;
+
+import org.apache.lucene.analysis.TokenStream;
+import org.apache.lucene.document.AbstractField;
+import org.apache.lucene.document.Field;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.io.Reader;
+
+public class TextFieldExtractor extends AbstractField
+{
+
+ /**
+ * The serial version UID.
+ */
+ private static final long serialVersionUID = -2707986404659820071L;
+
+ /**
+ * The logger instance for this class.
+ */
+ private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.TextFieldExtractor");
+
+ /**
+ * The reader from where to read the text extract.
+ */
+ private final Reader reader;
+
+ /**
+ * The extract as obtained lazily from {@link #reader}.
+ */
+ volatile private String extract;
+
+ /**
+ * Creates a new <code>TextFieldExtractor</code> with the given
+ * <code>name</code>.
+ *
+ * @param name the name of the field.
+ * @param reader the reader where to obtain the string from.
+ * @param store when set <code>true</code> the string value is stored in the
+ * index.
+ * @param withOffsets when set <code>true</code> a term vector with offsets
+ * is written into the index.
+ */
+ public TextFieldExtractor(String name, Reader reader, boolean store, boolean withOffsets)
+ {
+ super(name, store ? Field.Store.YES : Field.Store.NO, Field.Index.ANALYZED, withOffsets
+ ? Field.TermVector.WITH_OFFSETS : Field.TermVector.NO);
+ this.reader = reader;
+ }
+
+ /**
+ * @return the string value of this field.
+ */
+ public String stringValue()
+ {
+ if (extract == null)
+ {
+ synchronized (this)
+ {
+ if (extract == null)
+ {
+ StringBuffer textExtract = new StringBuffer();
+ char[] buffer = new char[1024];
+ int len;
+ try
+ {
+ while ((len = reader.read(buffer)) > -1)
+ {
+ textExtract.append(buffer, 0, len);
+ }
+ }
+ catch (IOException e)
+ {
+ log.warn("Exception reading value for field: " + e.getMessage());
+ log.debug("Dump:", e);
+ }
+ finally
+ {
+ try
+ {
+ reader.close();
+ }
+ catch (IOException e)
+ {
+ log.error(e.getLocalizedMessage(), e);
+ }
+ }
+ extract = textExtract.toString();
+ }
+ }
+ }
+ return extract;
+ }
+
+ /**
+ * @return always <code>null</code>.
+ */
+ public Reader readerValue()
+ {
+ return null;
+ }
+
+ /**
+ * @return always <code>null</code>.
+ */
+ public byte[] binaryValue()
+ {
+ return null;
+ }
+
+ /**
+ * @return always <code>null</code>.
+ */
+ public TokenStream tokenStreamValue()
+ {
+ return null;
+ }
+
+ /**
+ * Disposes this field and closes the underlying reader.
+ *
+ * @throws IOException if an error occurs while closing the reader.
+ */
+ public void dispose() throws IOException
+ {
+ reader.close();
+ }
+}
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/Util.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/Util.java 2012-01-12 08:07:55 UTC (rev 5443)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/Util.java 2012-01-12 08:38:11 UTC (rev 5444)
@@ -66,9 +66,9 @@
{
f.readerValue().close();
}
- else if (f instanceof LazyTextExtractorField)
+ else if (f instanceof TextFieldExtractor)
{
- LazyTextExtractorField field = (LazyTextExtractorField)f;
+ TextFieldExtractor field = (TextFieldExtractor)f;
field.dispose();
}
}
@@ -80,31 +80,6 @@
}
/**
- * Returns <code>true</code> if the document is ready to be added to the
- * index. That is all text extractors have finished their work.
- *
- * @param doc the document to check.
- * @return <code>true</code> if the document is ready; <code>false</code>
- * otherwise.
- */
- public static boolean isDocumentReady(Document doc)
- {
- for (Iterator it = doc.getFields().iterator(); it.hasNext();)
- {
- Fieldable f = (Fieldable)it.next();
- if (f instanceof LazyTextExtractorField)
- {
- LazyTextExtractorField field = (LazyTextExtractorField)f;
- if (!field.isExtractorFinished())
- {
- return false;
- }
- }
- }
- return true;
- }
-
- /**
* Depending on the index format this method returns a query that matches
* all nodes that have a property with a given <code>name</code>.
*
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/VolatileIndex.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/VolatileIndex.java 2012-01-12 08:07:55 UTC (rev 5443)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/VolatileIndex.java 2012-01-12 08:38:11 UTC (rev 5444)
@@ -57,12 +57,11 @@
*
* @param analyzer the analyzer to use.
* @param similarity the similarity implementation.
- * @param indexingQueue the indexing queue.
* @throws IOException if an error occurs while opening the index.
*/
- VolatileIndex(Analyzer analyzer, Similarity similarity, IndexingQueue indexingQueue) throws IOException
+ VolatileIndex(Analyzer analyzer, Similarity similarity) throws IOException
{
- super(analyzer, similarity, new RAMDirectory(), null, indexingQueue);
+ super(analyzer, similarity, new RAMDirectory(), null);
}
/**
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/core/query/lucene/IndexingAggregateTest.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/core/query/lucene/IndexingAggregateTest.java 2012-01-12 08:07:55 UTC (rev 5443)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/core/query/lucene/IndexingAggregateTest.java 2012-01-12 08:38:11 UTC (rev 5444)
@@ -17,23 +17,21 @@
package org.exoplatform.services.jcr.api.core.query.lucene;
import org.exoplatform.services.jcr.api.core.query.AbstractIndexingTest;
-import org.exoplatform.services.jcr.impl.core.query.lucene.IndexingQueue;
-import org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex;
-import javax.jcr.RepositoryException;
-import javax.jcr.Node;
-import javax.jcr.query.Query;
-
+import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.Writer;
import java.io.OutputStreamWriter;
-import java.io.ByteArrayInputStream;
-import java.util.Calendar;
-import java.util.List;
+import java.io.Writer;
import java.util.ArrayList;
+import java.util.Calendar;
import java.util.Collections;
import java.util.Iterator;
+import java.util.List;
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.query.Query;
+
/**
* <code>IndexingAggregateTest</code> checks if the nt:file nt:resource
* aggregate defined in workspace indexing-test works properly.
@@ -60,7 +58,6 @@
resource.setProperty("jcr:data", new ByteArrayInputStream(out.toByteArray()));
testRootNode.save();
- waitUntilQueueEmpty();
executeSQLQuery(sqlDog, new Node[]{file});
@@ -70,7 +67,6 @@
writer.flush();
resource.setProperty("jcr:data", new ByteArrayInputStream(out.toByteArray()));
testRootNode.save();
- waitUntilQueueEmpty();
executeSQLQuery(sqlCat, new Node[]{file});
@@ -102,20 +98,6 @@
// executeSQLQuery(sqlCat, new Node[]{file});
}
- protected void waitUntilQueueEmpty() throws Exception
- {
- SearchIndex index = (SearchIndex)getQueryHandler();
- IndexingQueue queue = index.getIndex().getIndexingQueue();
- index.getIndex().flush();
- synchronized (index.getIndex())
- {
- while (queue.getNumPendingDocuments() > 0)
- {
- index.getIndex().wait(50);
- }
- }
- }
-
public void testContentLastModified() throws RepositoryException
{
List expected = new ArrayList();
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/core/query/lucene/IndexingQueueTest.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/core/query/lucene/IndexingQueueTest.java 2012-01-12 08:07:55 UTC (rev 5443)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/core/query/lucene/IndexingQueueTest.java 2012-01-12 08:38:11 UTC (rev 5444)
@@ -1,245 +0,0 @@
-/*
- * 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.exoplatform.services.jcr.api.core.query.lucene;
-
-
-
-import org.exoplatform.services.jcr.api.core.query.AbstractIndexingTest;
-
-import org.exoplatform.services.jcr.impl.core.RepositoryImpl;
-import org.exoplatform.services.jcr.impl.core.query.lucene.IndexingQueue;
-import org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.RepositoryException;
-import javax.jcr.query.Query;
-import java.io.Reader;
-import java.io.InputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FilenameFilter;
-import java.util.Calendar;
-
-/**
- * <code>IndexingQueueTest</code> checks if the indexing queue properly indexes
- * nodes in a background thread when text extraction takes more than 10 ms. See
- * the workspace.xml file for the indexing-test workspace.
- */
-public class IndexingQueueTest extends AbstractIndexingTest {
-
- private static final File TEMP_DIR = new File(System.getProperty("java.io.tmpdir"));
-
- private static final String CONTENT_TYPE = "application/indexing-queue-test";
-
- private static final String ENCODING = "UTF-8";
- public void testname() throws Exception
- {
-
- }
-//
-// public void testQueue() throws Exception {
-// Extractor.sleepTime = 200;
-// SearchIndex index = (SearchIndex) getQueryHandler();
-// IndexingQueue queue = index.getIndex().getIndexingQueue();
-//
-// assertEquals(0, queue.getNumPendingDocuments());
-//
-// String text = "the quick brown fox jumps over the lazy dog.";
-// InputStream in = new ByteArrayInputStream(text.getBytes(ENCODING));
-// Node resource = testRootNode.addNode(nodeName1, "nt:resource");
-// resource.setProperty("jcr:data", in);
-// resource.setProperty("jcr:lastModified", Calendar.getInstance());
-// resource.setProperty("jcr:mimeType", CONTENT_TYPE);
-// resource.setProperty("jcr:encoding", ENCODING);
-// session.save();
-//
-// assertEquals(1, queue.getNumPendingDocuments());
-//
-// Query q = qm.createQuery(testPath + "/*[jcr:contains(., 'fox')]", Query.XPATH);
-// NodeIterator nodes = q.execute().getNodes();
-// assertFalse(nodes.hasNext());
-//
-// synchronized (index.getIndex()) {
-// while (queue.getNumPendingDocuments() > 0) {
-// index.getIndex().wait(50);
-// }
-// }
-//
-// q = qm.createQuery(testPath + "/*[jcr:contains(., 'fox')]", Query.XPATH);
-// nodes = q.execute().getNodes();
-// assertTrue(nodes.hasNext());
-// }
-//
-// public void testInitialIndex() throws Exception {
-// Extractor.sleepTime = 200;
-// SearchIndex index = (SearchIndex) getQueryHandler();
-// File indexDir = new File(index.getPath());
-//
-// // fill workspace
-// Node testFolder = testRootNode.addNode("folder", "nt:folder");
-// String text = "the quick brown fox jumps over the lazy dog.";
-// int num = createFiles(testFolder, text.getBytes(ENCODING), 10, 2, 0);
-// session.save();
-//
-// // shutdown workspace
-// RepositoryImpl repo = (RepositoryImpl) session.getRepository();
-// session.logout();
-// session = null;
-// superuser.logout();
-// superuser = null;
-// TestHelper.shutdownWorkspace(WORKSPACE_NAME, repo);
-//
-// // delete index
-// try {
-// FileUtil.delete(indexDir);
-// } catch (IOException e) {
-// fail("Unable to delete index directory");
-// }
-//
-// int initialNumExtractorFiles = getNumExtractorFiles();
-//
-// Extractor.sleepTime = 20;
-// Thread t = new Thread(new Runnable() {
-// public void run() {
-// try {
-// session = helper.getSuperuserSession(WORKSPACE_NAME);
-// } catch (RepositoryException e) {
-// throw new RuntimeException(e);
-// }
-// }
-// });
-// t.start();
-//
-// while (t.isAlive()) {
-// // there must not be more than 20 extractor files, because:
-// // - initial index creation checks indexing queue every 10 nodes
-// // - there is an aggregate definition on the workspace that causes
-// // 2 extractor jobs per nt:resource
-// // => 2 * 10 = 20
-// int numFiles = getNumExtractorFiles() - initialNumExtractorFiles;
-// assertTrue(numFiles <= 20);
-// Thread.sleep(50);
-// }
-//
-// qm = session.getWorkspace().getQueryManager();
-// index = (SearchIndex) getQueryHandler();
-// IndexingQueue queue = index.getIndex().getIndexingQueue();
-//
-// // flush index to make sure any documents in the buffer are written
-// // to the index. this is to make sure all nodes are pushed either to
-// // the index or to the indexing queue
-// index.getIndex().flush();
-//
-// synchronized (index.getIndex()) {
-// while (queue.getNumPendingDocuments() > 0) {
-// index.getIndex().wait(50);
-// }
-// }
-//
-// String stmt = testPath + "//element(*, nt:resource)[jcr:contains(., 'fox')]";
-// Query q = qm.createQuery(stmt, Query.XPATH);
-// assertEquals(num, q.execute().getNodes().getSize());
-// }
-//
-// /*
-// * Test case for JCR-2082
-// */
-// public void testReaderUpToDate() throws Exception {
-// Extractor.sleepTime = 10;
-// SearchIndex index = (SearchIndex) getQueryHandler();
-// File indexDir = new File(index.getPath());
-//
-// // shutdown workspace
-// RepositoryImpl repo = (RepositoryImpl) session.getRepository();
-// session.logout();
-// session = null;
-// superuser.logout();
-// superuser = null;
-// TestHelper.shutdownWorkspace(WORKSPACE_NAME, repo);
-//
-// // delete index
-// try {
-// FileUtil.delete(indexDir);
-// } catch (IOException e) {
-// fail("Unable to delete index directory");
-// }
-//
-// // start workspace again by getting a session
-// session = helper.getSuperuserSession(WORKSPACE_NAME);
-//
-// qm = session.getWorkspace().getQueryManager();
-//
-// Query q = qm.createQuery(testPath, Query.XPATH);
-// assertEquals(1, getSize(q.execute().getNodes()));
-// }
-//
-// private int createFiles(Node folder, byte[] data,
-// int filesPerLevel, int levels, int count)
-// throws RepositoryException {
-// levels--;
-// for (int i = 0; i < filesPerLevel; i++) {
-// // create files
-// Node file = folder.addNode("file" + i, "nt:file");
-// InputStream in = new ByteArrayInputStream(data);
-// Node resource = file.addNode("jcr:content", "nt:resource");
-// resource.setProperty("jcr:data", in);
-// resource.setProperty("jcr:lastModified", Calendar.getInstance());
-// resource.setProperty("jcr:mimeType", CONTENT_TYPE);
-// resource.setProperty("jcr:encoding", ENCODING);
-// count++;
-// }
-// if (levels > 0) {
-// for (int i = 0; i < filesPerLevel; i++) {
-// // create files
-// Node subFolder = folder.addNode("folder" + i, "nt:folder");
-// count = createFiles(subFolder, data,
-// filesPerLevel, levels, count);
-// }
-// }
-// return count;
-// }
-//
-// private int getNumExtractorFiles() throws IOException {
-// return TEMP_DIR.listFiles(new FilenameFilter() {
-// public boolean accept(File dir, String name) {
-// return name.startsWith("extractor");
-// }
-// }).length;
-// }
-
-// public static final class Extractor implements TextExtractor {
-//
-// protected static volatile int sleepTime = 200;
-//
-// public String[] getContentTypes() {
-// return new String[]{CONTENT_TYPE};
-// }
-//
-// public Reader extractText(InputStream stream, String type, String encoding)
-// throws IOException {
-// try {
-// Thread.sleep(sleepTime);
-// } catch (InterruptedException e) {
-// throw new IOException();
-// }
-// return new InputStreamReader(stream, encoding);
-// }
- // }
-}
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/core/query/lucene/TestAll.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/core/query/lucene/TestAll.java 2012-01-12 08:07:55 UTC (rev 5443)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/core/query/lucene/TestAll.java 2012-01-12 08:38:11 UTC (rev 5444)
@@ -37,7 +37,6 @@
{
TestSuite suite = new TestSuite("Search tests");
- suite.addTestSuite(IndexingQueueTest.class);
suite.addTestSuite(IndexingAggregateTest.class);
return suite;
14 years, 3 months
exo-jcr SVN: r5443 - in jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr: api/writing and 3 other directories.
by do-not-reply@jboss.org
Author: andrew.plotnikov
Date: 2012-01-12 03:07:55 -0500 (Thu, 12 Jan 2012)
New Revision: 5443
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/namespaces/TestNamespaceRegistry.java
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/writing/TestSetProperty.java
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestPermissions.java
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestSessionCleaner.java
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/name/TestJCRPath.java
Log:
EXOJCR-1703: Writed tests to classes JCRName, NamespaceRegistryImpl, PropertyImpl
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/namespaces/TestNamespaceRegistry.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/namespaces/TestNamespaceRegistry.java 2012-01-12 07:12:27 UTC (rev 5442)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/namespaces/TestNamespaceRegistry.java 2012-01-12 08:07:55 UTC (rev 5443)
@@ -23,9 +23,11 @@
import org.exoplatform.services.jcr.JcrAPIBaseTest;
import org.exoplatform.services.jcr.core.WorkspaceContainerFacade;
import org.exoplatform.services.jcr.impl.core.ExtendedNamespaceRegistry;
+import org.exoplatform.services.jcr.impl.core.NamespaceRegistryImpl;
import org.exoplatform.services.jcr.impl.core.NodeImpl;
import org.exoplatform.services.jcr.impl.core.query.RepositoryIndexSearcherHolder;
+import java.util.Arrays;
import java.util.Set;
import javax.jcr.NamespaceException;
@@ -89,6 +91,8 @@
}
assertTrue(prefixes.length >= 7);
+ assertTrue(Arrays.asList(session.getWorkspace().getNamespaceRegistry().getPrefixes()).containsAll(
+ Arrays.asList(namespaceRegistry.getPrefixes())));
}
public void testGetURIs() throws RepositoryException
@@ -359,4 +363,40 @@
fail();
}
}
-}
+
+ public void testIsDefaultPrefix()
+ {
+ assertTrue(((NamespaceRegistryImpl)namespaceRegistry).isDefaultPrefix("nt"));
+ assertFalse(((NamespaceRegistryImpl)namespaceRegistry).isDefaultPrefix("somePrefix"));
+ }
+
+ public void testIsDefaultNamespace() throws NamespaceException, RepositoryException
+ {
+ NamespaceRegistryImpl nameSpace = (NamespaceRegistryImpl)namespaceRegistry;
+ String uri = workspace.getNamespaceRegistry().getURI("nt");
+
+ assertTrue(nameSpace.isDefaultNamespace(uri));
+ assertFalse(nameSpace.isDefaultNamespace(" "));
+ }
+
+ public void testValidateNamespace() throws RepositoryException
+ {
+ try
+ {
+ ((NamespaceRegistryImpl)namespaceRegistry).validateNamespace("some:text", "");
+ fail();
+ }
+ catch (RepositoryException e)
+ {
+ }
+
+ try
+ {
+ ((NamespaceRegistryImpl)namespaceRegistry).validateNamespace("nt", null);
+ fail();
+ }
+ catch (NamespaceException e)
+ {
+ }
+ }
+}
\ No newline at end of file
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/writing/TestSetProperty.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/writing/TestSetProperty.java 2012-01-12 07:12:27 UTC (rev 5442)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/writing/TestSetProperty.java 2012-01-12 08:07:55 UTC (rev 5443)
@@ -41,6 +41,7 @@
import javax.jcr.Session;
import javax.jcr.Value;
import javax.jcr.ValueFormatException;
+import javax.jcr.nodetype.ConstraintViolationException;
import javax.jcr.version.OnParentVersionAction;
/**
@@ -325,6 +326,33 @@
catch (ValueFormatException e)
{
}
+
+ try
+ {
+ node.setProperty("jcr:versionStorage", 20D);
+ fail("exception should have been thrown");
+ }
+ catch (ConstraintViolationException e)
+ {
+ }
+
+ try
+ {
+ node.setProperty("jcr:versionStorage", valueFactory.createValue(20L), PropertyType.LONG);
+ fail("exception should have been thrown");
+ }
+ catch (ConstraintViolationException e)
+ {
+ }
+
+ try
+ {
+ node.setProperty("jcr:versionStorage", "20", PropertyType.LONG);
+ fail("exception should have been thrown");
+ }
+ catch (ConstraintViolationException e)
+ {
+ }
}
public void testSetPathProperty() throws RepositoryException
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestPermissions.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestPermissions.java 2012-01-12 07:12:27 UTC (rev 5442)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestPermissions.java 2012-01-12 08:07:55 UTC (rev 5443)
@@ -862,5 +862,4 @@
assertEquals(marysNode.getACL().getPermissions("mary").size(), 0);
assertEquals(((NodeData)marysNode.getData()).getACL().getOwner(), "admin");
}
-
-}
+}
\ No newline at end of file
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestSessionCleaner.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestSessionCleaner.java 2012-01-12 07:12:27 UTC (rev 5442)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestSessionCleaner.java 2012-01-12 08:07:55 UTC (rev 5443)
@@ -80,6 +80,5 @@
// The weak reference must now be null
assertNull(ref.get());
-
}
}
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/name/TestJCRPath.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/name/TestJCRPath.java 2012-01-12 07:12:27 UTC (rev 5442)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/name/TestJCRPath.java 2012-01-12 08:07:55 UTC (rev 5443)
@@ -26,6 +26,8 @@
import org.exoplatform.services.jcr.impl.core.LocationFactory;
import org.exoplatform.services.jcr.impl.core.NamespaceRegistryImpl;
+import javax.jcr.RepositoryException;
+
/**
* Created by The eXo Platform SAS.
*
@@ -116,10 +118,17 @@
}
- public void testEquals() throws Exception
+ public void testEqualsJCRPath() throws Exception
{
JCRPath path = factory.parseAbsPath("/jcr:node/node1[2]/exo:node2");
assertFalse(path.equals(null));
assertFalse(path.equals(new Object()));
}
+
+ public void testEqualsJCRName() throws RepositoryException
+ {
+ JCRName name = factory.parseAbsPath("/jcr:node/node1[2]/exo:node2").getName();
+ assertFalse(name.equals(null));
+ assertFalse(name.equals(new Object()));
+ }
}
\ No newline at end of file
14 years, 3 months
exo-jcr SVN: r5442 - in jcr/branches/1.15.x/applications/product-patches/as: jboss/bin and 6 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2012-01-12 02:12:27 -0500 (Thu, 12 Jan 2012)
New Revision: 5442
Modified:
jcr/branches/1.15.x/applications/product-patches/as/jboss/bin/run.conf
jcr/branches/1.15.x/applications/product-patches/as/jboss/bin/run.conf.bat
jcr/branches/1.15.x/applications/product-patches/as/jboss/exo-configuration.xml
jcr/branches/1.15.x/applications/product-patches/as/jboss/exo-readme.txt
jcr/branches/1.15.x/applications/product-patches/as/jetty/eXo.bat
jcr/branches/1.15.x/applications/product-patches/as/jetty/eXo.sh
jcr/branches/1.15.x/applications/product-patches/as/jetty/exo-configuration.xml
jcr/branches/1.15.x/applications/product-patches/as/jetty/exo-readme.txt
jcr/branches/1.15.x/applications/product-patches/as/jonas/bin/nt/jonas.bat
jcr/branches/1.15.x/applications/product-patches/as/jonas/bin/unix/jonas
jcr/branches/1.15.x/applications/product-patches/as/jonas/exo-configuration.xml
jcr/branches/1.15.x/applications/product-patches/as/jonas/exo-readme.txt
jcr/branches/1.15.x/applications/product-patches/as/tomcat/bin/eXo.bat
jcr/branches/1.15.x/applications/product-patches/as/tomcat/bin/eXo.sh
jcr/branches/1.15.x/applications/product-patches/as/tomcat/exo-configuration.xml
jcr/branches/1.15.x/applications/product-patches/as/tomcat/exo-readme.txt
Log:
EXOJCR-1706: fix using profiles, the default profile will be jbc
Modified: jcr/branches/1.15.x/applications/product-patches/as/jboss/bin/run.conf
===================================================================
--- jcr/branches/1.15.x/applications/product-patches/as/jboss/bin/run.conf 2012-01-11 11:22:23 UTC (rev 5441)
+++ jcr/branches/1.15.x/applications/product-patches/as/jboss/bin/run.conf 2012-01-12 07:12:27 UTC (rev 5442)
@@ -52,7 +52,11 @@
#JAVA_OPTS="$JAVA_OPTS -Xrunjdwp:transport=dt_shmem,address=jboss,server=y,suspend=n"
# Add the eXo variables
-JAVA_OPTS="$JAVA_OPTS -Dexo.profiles=$1 -Dexo.jcr.parent.dir=../server/default/data"
-if [ "$1" = "ispn" ]; then
- shift
-fi
\ No newline at end of file
+EXO_PROFILES="-Dexo.profiles="
+if [ "$1" = "jbc" ] || [ "$1" = "ispn" ]; then
+ EXO_PROFILES="$EXO_PROFILES,$1"
+ shift 1
+else
+ EXO_PROFILES="$EXO_PROFILES,jbc"
+fi
+JAVA_OPTS="$JAVA_OPTS $EXO_PROFILES -Dexo.jcr.parent.dir=../server/default/data"
Modified: jcr/branches/1.15.x/applications/product-patches/as/jboss/bin/run.conf.bat
===================================================================
--- jcr/branches/1.15.x/applications/product-patches/as/jboss/bin/run.conf.bat 2012-01-11 11:22:23 UTC (rev 5441)
+++ jcr/branches/1.15.x/applications/product-patches/as/jboss/bin/run.conf.bat 2012-01-12 07:12:27 UTC (rev 5442)
@@ -55,8 +55,22 @@
rem set "JAVA_OPTS=%JAVA_OPTS% -Xrunjdwp:transport=dt_shmem,address=jboss,server=y,suspend=n"
rem # Add the eXo variables
-set "JAVA_OPTS=%JAVA_OPTS% -Dexo.profiles=%1 -Dexo.jcr.parent.dir=../server/default/data"
-if ""%1"" == ""ispn"" shift
+set EXO_PROFILES=-Dexo.profiles=
+if ""%1"" == ""jbc"" goto profile
+if ""%1"" == ""ispn"" goto profile
+goto default_profile
+
+:profile
+set EXO_PROFILES=%EXO_PROFILES%,%1
+shift
+goto endif
+
+:default_profile
+set EXO_PROFILES=%EXO_PROFILES%,jbc
+goto endif
+
+:endif
+set "JAVA_OPTS=%JAVA_OPTS% %EXO_PROFILES% -Dexo.jcr.parent.dir=../server/default/data"
:JAVA_OPTS_SET
Modified: jcr/branches/1.15.x/applications/product-patches/as/jboss/exo-configuration.xml
===================================================================
--- jcr/branches/1.15.x/applications/product-patches/as/jboss/exo-configuration.xml 2012-01-11 11:22:23 UTC (rev 5441)
+++ jcr/branches/1.15.x/applications/product-patches/as/jboss/exo-configuration.xml 2012-01-12 07:12:27 UTC (rev 5442)
@@ -55,15 +55,15 @@
<key>org.exoplatform.services.jcr.config.RepositoryServiceConfiguration</key>
<type>org.exoplatform.services.jcr.impl.config.RepositoryServiceConfigurationImpl</type>
<init-params>
- <value-param>
+ <value-param profiles="ispn">
<name>conf-path</name>
<description>JCR configuration file</description>
- <value>jar:/conf/portal/exo-jcr-jbc-config.xml</value>
+ <value>jar:/conf/portal/exo-jcr-ispn-config.xml</value>
</value-param>
- <value-param profiles="ispn">
+ <value-param profiles="jbc">
<name>conf-path</name>
<description>JCR configuration file</description>
- <value>jar:/conf/portal/exo-jcr-ispn-config.xml</value>
+ <value>jar:/conf/portal/exo-jcr-jbc-config.xml</value>
</value-param>
</init-params>
</component>
Modified: jcr/branches/1.15.x/applications/product-patches/as/jboss/exo-readme.txt
===================================================================
--- jcr/branches/1.15.x/applications/product-patches/as/jboss/exo-readme.txt 2012-01-11 11:22:23 UTC (rev 5441)
+++ jcr/branches/1.15.x/applications/product-patches/as/jboss/exo-readme.txt 2012-01-12 07:12:27 UTC (rev 5442)
@@ -4,10 +4,12 @@
In Unix environment
-* "./run.sh" to launch eXo JCR with the configuration for JBoss Cache
+* "./run.sh" to launch eXo JCR with the default configuration
* "./run.sh ispn" to launch eXo JCR with the configuration for Infinispan
+* "./run.sh jbc" to launch eXo JCR with the configuration for JBoss Cache
In Windows environment
-* "run.bat" to launch eXo JCR with the configuration for JBoss Cache
+* "run.bat" to launch eXo JCR with the default configuration
* "run.bat ispn" to launch eXo JCR with the configuration for Infinispan
+* "run.bat jbc" to launch eXo JCR with the configuration for JBoss Cache
Modified: jcr/branches/1.15.x/applications/product-patches/as/jetty/eXo.bat
===================================================================
--- jcr/branches/1.15.x/applications/product-patches/as/jetty/eXo.bat 2012-01-11 11:22:23 UTC (rev 5441)
+++ jcr/branches/1.15.x/applications/product-patches/as/jetty/eXo.bat 2012-01-12 07:12:27 UTC (rev 5442)
@@ -1 +1,17 @@
-java -Djava.security.auth.login.config=jaas.conf -Dexo.profiles=%1 -Djava.net.preferIPv4Stack=true -Dexo.jcr.parent.dir=. -jar start.jar
+set EXO_PROFILES=-Dexo.profiles=
+if ""%1"" == ""jbc"" goto profile
+if ""%1"" == ""ispn"" goto profile
+goto default_profile
+
+:profile
+set EXO_PROFILES=%EXO_PROFILES%,%1
+shift
+goto endif
+
+:default_profile
+set EXO_PROFILES=%EXO_PROFILES%,jbc
+goto endif
+
+:endif
+
+java -Djava.security.auth.login.config=jaas.conf %EXO_PROFILES% -Djava.net.preferIPv4Stack=true -Dexo.jcr.parent.dir=. -jar start.jar
Modified: jcr/branches/1.15.x/applications/product-patches/as/jetty/eXo.sh
===================================================================
--- jcr/branches/1.15.x/applications/product-patches/as/jetty/eXo.sh 2012-01-11 11:22:23 UTC (rev 5441)
+++ jcr/branches/1.15.x/applications/product-patches/as/jetty/eXo.sh 2012-01-12 07:12:27 UTC (rev 5442)
@@ -1 +1,10 @@
-java -Djava.security.auth.login.config=jaas.conf -Dexo.profiles=$1 -Djava.net.preferIPv4Stack=true -Dexo.jcr.parent.dir=. -jar start.jar
+EXO_PROFILES="-Dexo.profiles="
+if [ "$1" = "jbc" ] || [ "$1" = "ispn" ]; then
+ EXO_PROFILES="$EXO_PROFILES,$1"
+ shift 1
+else
+ EXO_PROFILES="$EXO_PROFILES,jbc"
+fi
+EXO_OPTS="-Dexo.product.developing=true $EXO_PROFILES -Djava.net.preferIPv4Stack=true"
+
+java -Djava.security.auth.login.config=jaas.conf $EXO_PROFILES -Djava.net.preferIPv4Stack=true -Dexo.jcr.parent.dir=. -jar start.jar
Modified: jcr/branches/1.15.x/applications/product-patches/as/jetty/exo-configuration.xml
===================================================================
--- jcr/branches/1.15.x/applications/product-patches/as/jetty/exo-configuration.xml 2012-01-11 11:22:23 UTC (rev 5441)
+++ jcr/branches/1.15.x/applications/product-patches/as/jetty/exo-configuration.xml 2012-01-12 07:12:27 UTC (rev 5442)
@@ -55,15 +55,15 @@
<key>org.exoplatform.services.jcr.config.RepositoryServiceConfiguration</key>
<type>org.exoplatform.services.jcr.impl.config.RepositoryServiceConfigurationImpl</type>
<init-params>
- <value-param>
+ <value-param profiles="ispn">
<name>conf-path</name>
<description>JCR configuration file</description>
- <value>jar:/conf/portal/exo-jcr-jbc-config.xml</value>
+ <value>jar:/conf/portal/exo-jcr-ispn-config.xml</value>
</value-param>
- <value-param profiles="ispn">
+ <value-param profiles="jbc">
<name>conf-path</name>
<description>JCR configuration file</description>
- <value>jar:/conf/portal/exo-jcr-ispn-config.xml</value>
+ <value>jar:/conf/portal/exo-jcr-jbc-config.xml</value>
</value-param>
</init-params>
</component>
Modified: jcr/branches/1.15.x/applications/product-patches/as/jetty/exo-readme.txt
===================================================================
--- jcr/branches/1.15.x/applications/product-patches/as/jetty/exo-readme.txt 2012-01-11 11:22:23 UTC (rev 5441)
+++ jcr/branches/1.15.x/applications/product-patches/as/jetty/exo-readme.txt 2012-01-12 07:12:27 UTC (rev 5442)
@@ -1,13 +1,15 @@
Thank you for your interest in eXo JCR
-To launch it, go to the bin directory and execute the following command:
+To launch it, execute the following command:
In Unix environment
-* "./run.sh" to launch eXo JCR with the configuration for JBoss Cache
-* "./run.sh ispn" to launch eXo JCR with the configuration for Infinispan
+* "./eXo.sh" to launch eXo JCR with the default configuration
+* "./eXo.sh ispn" to launch eXo JCR with the configuration for Infinispan
+* "./eXo.sh jbc" to launch eXo JCR with the configuration for JBoss Cache
In Windows environment
-* "run.bat" to launch eXo JCR with the configuration for JBoss Cache
-* "run.bat ispn" to launch eXo JCR with the configuration for Infinispan
+* "eXo.bat" to launch eXo JCR with the default configuration
+* "eXo.bat ispn" to launch eXo JCR with the configuration for Infinispan
+* "eXo.bat jbc" to launch eXo JCR with the configuration for JBoss Cache
Modified: jcr/branches/1.15.x/applications/product-patches/as/jonas/bin/nt/jonas.bat
===================================================================
--- jcr/branches/1.15.x/applications/product-patches/as/jonas/bin/nt/jonas.bat 2012-01-11 11:22:23 UTC (rev 5441)
+++ jcr/branches/1.15.x/applications/product-patches/as/jonas/bin/nt/jonas.bat 2012-01-12 07:12:27 UTC (rev 5442)
@@ -80,9 +80,25 @@
Rem ----------------------- Begin eXo configuration ----------------------------
cd %JONAS_ROOT%/bin
-set JONAS_OPTS=%JONAS_OPTS% -Dorg.exoplatform.services.log.Log=org.apache.commons.logging.impl.SimpleLog -Djava.awt.headless=true -Dexo.profiles=%1 -Djava.net.preferIPv4Stack=true -Dexo.jcr.parent.dir=../..
+
+set EXO_PROFILES=-Dexo.profiles=
+if ""%1"" == ""jbc"" goto profile
+if ""%1"" == ""ispn"" goto profile
+goto default_profile
+
+:profile
+set EXO_PROFILES=%EXO_PROFILES%,%1
+shift
+goto endif
+
+:default_profile
+set EXO_PROFILES=%EXO_PROFILES%,jbc
+goto endif
+
+:endif
+set JONAS_OPTS=%JONAS_OPTS% -Dorg.exoplatform.services.log.Log=org.apache.commons.logging.impl.SimpleLog -Djava.awt.headless=true %EXO_PROFILES% -Djava.net.preferIPv4Stack=true -Dexo.jcr.parent.dir=../..
set JAVA_OPTS=%JAVA_OPTS% -Xmx512M
-if ""%1"" == ""ispn"" shift
+
Rem ------------------------ End eXo configuration -----------------------------
Modified: jcr/branches/1.15.x/applications/product-patches/as/jonas/bin/unix/jonas
===================================================================
--- jcr/branches/1.15.x/applications/product-patches/as/jonas/bin/unix/jonas 2012-01-11 11:22:23 UTC (rev 5441)
+++ jcr/branches/1.15.x/applications/product-patches/as/jonas/bin/unix/jonas 2012-01-12 07:12:27 UTC (rev 5442)
@@ -79,11 +79,18 @@
# ------------------------- Begin eXo configuration ----------------------------
cd $JONAS_ROOT/bin
-JONAS_OPTS="$JONAS_OPTS -Dorg.exoplatform.services.log.Log=org.apache.commons.logging.impl.SimpleLog -Djava.awt.headless=true -Dexo.profiles=$1 -Djava.net.preferIPv4Stack=true -Dexo.jcr.parent.dir=.."
-JAVA_OPTS="$JAVA_OPTS -Xmx512M"
-if [ "$1" = "ispn" ]; then
- shift
-fi
+
+EXO_PROFILES="-Dexo.profiles="
+if [ "$1" = "jbc" ] || [ "$1" = "ispn" ]; then
+ EXO_PROFILES="$EXO_PROFILES,$1"
+ shift
+else
+ EXO_PROFILES="$EXO_PROFILES,jbc"
+fi
+EXO_OPTS="-Dexo.product.developing=true $EXO_PROFILES -Djava.net.preferIPv4Stack=true"
+
+JONAS_OPTS="$JONAS_OPTS -Dorg.exoplatform.services.log.Log=org.apache.commons.logging.impl.SimpleLog -Djava.awt.headless=true $EXO_PROFILES -Djava.net.preferIPv4Stack=true -Dexo.jcr.parent.dir=.."
+
# -------------------------- End eXo configuration -----------------------------
Modified: jcr/branches/1.15.x/applications/product-patches/as/jonas/exo-configuration.xml
===================================================================
--- jcr/branches/1.15.x/applications/product-patches/as/jonas/exo-configuration.xml 2012-01-11 11:22:23 UTC (rev 5441)
+++ jcr/branches/1.15.x/applications/product-patches/as/jonas/exo-configuration.xml 2012-01-12 07:12:27 UTC (rev 5442)
@@ -55,15 +55,15 @@
<key>org.exoplatform.services.jcr.config.RepositoryServiceConfiguration</key>
<type>org.exoplatform.services.jcr.impl.config.RepositoryServiceConfigurationImpl</type>
<init-params>
- <value-param>
+ <value-param profiles="ispn">
<name>conf-path</name>
<description>JCR configuration file</description>
- <value>jar:/conf/portal/exo-jcr-jbc-config.xml</value>
+ <value>jar:/conf/portal/exo-jcr-ispn-config.xml</value>
</value-param>
- <value-param profiles="ispn">
+ <value-param profiles="jbc">
<name>conf-path</name>
<description>JCR configuration file</description>
- <value>jar:/conf/portal/exo-jcr-ispn-config.xml</value>
+ <value>jar:/conf/portal/exo-jcr-jbc-config.xml</value>
</value-param>
</init-params>
</component>
Modified: jcr/branches/1.15.x/applications/product-patches/as/jonas/exo-readme.txt
===================================================================
--- jcr/branches/1.15.x/applications/product-patches/as/jonas/exo-readme.txt 2012-01-11 11:22:23 UTC (rev 5441)
+++ jcr/branches/1.15.x/applications/product-patches/as/jonas/exo-readme.txt 2012-01-12 07:12:27 UTC (rev 5442)
@@ -2,10 +2,12 @@
In Unix environment, go in the directory bin/unix then execute the following command:
-* "./jonas start" to launch eXo JCR with the configuration for JBoss Cache
+* "./jonas start" to launch eXo JCR with the default configuration
* "./jonas ispn start" to launch eXo JCR with the configuration for Infinispan
+* "./jonas jbc start" to launch eXo JCR with the configuration for JBoss Cache
In Windows environment, go in the directory bin\nt then execute the following command:
-* "jonas.bat start" to launch eXo JCR with the configuration for JBoss Cache
+* "jonas.bat start" to launch eXo JCR with the default configuration
* "jonas.bat ispn start" to launch eXo JCR with the configuration for Infinispan
+* "jonas.bat jbc start" to launch eXo JCR with the configuration for JBoss Cache
Modified: jcr/branches/1.15.x/applications/product-patches/as/tomcat/bin/eXo.bat
===================================================================
--- jcr/branches/1.15.x/applications/product-patches/as/tomcat/bin/eXo.bat 2012-01-11 11:22:23 UTC (rev 5441)
+++ jcr/branches/1.15.x/applications/product-patches/as/tomcat/bin/eXo.bat 2012-01-12 07:12:27 UTC (rev 5442)
@@ -8,9 +8,24 @@
rem Sets some variables
set LOG_OPTS="-Dorg.exoplatform.services.log.Log=org.apache.commons.logging.impl.SimpleLog"
set SECURITY_OPTS="-Djava.security.auth.login.config=%TOMCAT_HOME%\conf\jaas.conf"
-set EXO_OPTS=-Dexo.product.developing=true -Dexo.profiles=%1 -Djava.net.preferIPv4Stack=true
+
+set EXO_PROFILES=-Dexo.profiles=
+if ""%1"" == ""jbc"" goto profile
+if ""%1"" == ""ispn"" goto profile
+goto default_profile
+
+:profile
+set EXO_PROFILES=%EXO_PROFILES%,%1
+shift
+goto endif
+
+:default_profile
+set EXO_PROFILES=%EXO_PROFILES%,jbc
+goto endif
+
+:endif
+set EXO_OPTS=-Dexo.product.developing=true %EXO_PROFILES% -Djava.net.preferIPv4Stack=true
set JAVA_OPTS=-Xshare:auto -Xms128m -Xmx512m %LOG_OPTS% %SECURITY_OPTS% %EXO_OPTS%
-if ""%1"" == ""ispn"" shift
rem Launches the server
cd %BIN_DIR%
Modified: jcr/branches/1.15.x/applications/product-patches/as/tomcat/bin/eXo.sh
===================================================================
--- jcr/branches/1.15.x/applications/product-patches/as/tomcat/bin/eXo.sh 2012-01-11 11:22:23 UTC (rev 5441)
+++ jcr/branches/1.15.x/applications/product-patches/as/tomcat/bin/eXo.sh 2012-01-12 07:12:27 UTC (rev 5442)
@@ -5,11 +5,15 @@
PRGDIR=`dirname "$PRG"`
LOG_OPTS="-Dorg.exoplatform.services.log.Log=org.apache.commons.logging.impl.SimpleLog"
SECURITY_OPTS="-Djava.security.auth.login.config=$PRGDIR/../conf/jaas.conf"
-EXO_OPTS="-Dexo.product.developing=true -Dexo.profiles=$1 -Djava.net.preferIPv4Stack=true"
-if [ "$1" = "ispn" ]; then
+EXO_PROFILES="-Dexo.profiles="
+if [ "$1" = "jbc" ] || [ "$1" = "ispn" ]; then
+ EXO_PROFILES="$EXO_PROFILES,$1"
shift
+else
+ EXO_PROFILES="$EXO_PROFILES,jbc"
fi
+EXO_OPTS="-Dexo.product.developing=true $EXO_PROFILES -Djava.net.preferIPv4Stack=true"
-JAVA_OPTS="$JAVA_OPTS $LOG_OPTS $SECURITY_OPTS $EXO_OPTS"
+JAVA_OPTS="$JAVA_OPTS $LOG_OPTS $SECURITY_OPTS $EXO_OPTS $JPDA_OPTS"
export JAVA_OPTS
exec "$PRGDIR"/catalina.sh "$@"
Modified: jcr/branches/1.15.x/applications/product-patches/as/tomcat/exo-configuration.xml
===================================================================
--- jcr/branches/1.15.x/applications/product-patches/as/tomcat/exo-configuration.xml 2012-01-11 11:22:23 UTC (rev 5441)
+++ jcr/branches/1.15.x/applications/product-patches/as/tomcat/exo-configuration.xml 2012-01-12 07:12:27 UTC (rev 5442)
@@ -55,15 +55,15 @@
<key>org.exoplatform.services.jcr.config.RepositoryServiceConfiguration</key>
<type>org.exoplatform.services.jcr.impl.config.RepositoryServiceConfigurationImpl</type>
<init-params>
- <value-param>
+ <value-param profiles="ispn">
<name>conf-path</name>
<description>JCR configuration file</description>
- <value>jar:/conf/portal/exo-jcr-jbc-config.xml</value>
+ <value>jar:/conf/portal/exo-jcr-ispn-config.xml</value>
</value-param>
- <value-param profiles="ispn">
+ <value-param profiles="jbc">
<name>conf-path</name>
<description>JCR configuration file</description>
- <value>jar:/conf/portal/exo-jcr-ispn-config.xml</value>
+ <value>jar:/conf/portal/exo-jcr-jbc-config.xml</value>
</value-param>
</init-params>
</component>
Modified: jcr/branches/1.15.x/applications/product-patches/as/tomcat/exo-readme.txt
===================================================================
--- jcr/branches/1.15.x/applications/product-patches/as/tomcat/exo-readme.txt 2012-01-11 11:22:23 UTC (rev 5441)
+++ jcr/branches/1.15.x/applications/product-patches/as/tomcat/exo-readme.txt 2012-01-12 07:12:27 UTC (rev 5442)
@@ -4,10 +4,12 @@
In Unix environment
-* "./run.sh" to launch eXo JCR with the configuration for JBoss Cache
-* "./run.sh ispn" to launch eXo JCR with the configuration for Infinispan
+* "./eXo.sh run" to launch eXo JCR with the default configuration
+* "./eXo.sh ispn run" to launch eXo JCR with the configuration for Infinispan
+* "./eXo.sh jbc run" to launch eXo JCR with the configuration for JBoss Cache
In Windows environment
-* "run.bat" to launch eXo JCR with the configuration for JBoss Cache
-* "run.bat ispn" to launch eXo JCR with the configuration for Infinispan
+* "eXo.bat run" to launch eXo JCR with the default configuration
+* "eXo.bat ispn run" to launch eXo JCR with the configuration for Infinispan
+* "eXo.bat jbc run" to launch eXo JCR with the configuration for JBoss Cache
14 years, 3 months
exo-jcr SVN: r5441 - in jcr/branches/1.15.x/exo.jcr.component.core/src: test/java/org/exoplatform/services/jcr/api/reading and 2 other directories.
by do-not-reply@jboss.org
Author: andrew.plotnikov
Date: 2012-01-11 06:22:23 -0500 (Wed, 11 Jan 2012)
New Revision: 5441
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/RepositoryImpl.java
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/reading/TestProperty.java
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestInitRepository.java
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestLocationFactory.java
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestSessionDataManager.java
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/name/TestJCRPath.java
Log:
EXOJCR-1703: Writed tests to classes PropertyImpl, SessionDataManager, RepositoryImpl, LocationFactory
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/RepositoryImpl.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/RepositoryImpl.java 2012-01-11 10:44:54 UTC (rev 5440)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/RepositoryImpl.java 2012-01-11 11:22:23 UTC (rev 5441)
@@ -189,10 +189,14 @@
public boolean canRemoveWorkspace(String workspaceName) throws NoSuchWorkspaceException
{
if (repositoryContainer.getWorkspaceEntry(workspaceName) == null)
+ {
throw new NoSuchWorkspaceException("No such workspace " + workspaceName);
+ }
if (workspaceName.equals(config.getSystemWorkspaceName()))
+ {
return false;
+ }
SessionRegistry sessionRegistry =
(SessionRegistry)repositoryContainer.getComponentInstance(SessionRegistry.class);
@@ -287,8 +291,10 @@
final WorkspaceContainer wsContainer = repositoryContainer.getWorkspaceContainer(workspaceName);
if (wsContainer == null)
+ {
throw new RepositoryException("Workspace " + workspaceName
+ " is not configured. Use RepositoryImpl.configWorkspace() method");
+ }
repositoryContainer.getWorkspaceContainer(workspaceName).getWorkspaceInitializer().initWorkspace();
SecurityHelper.doPrivilegedAction(new PrivilegedAction<Void>()
@@ -388,7 +394,9 @@
{
if (getState() == OFFLINE)
+ {
LOG.warn("Repository " + getName() + " is OFFLINE.");
+ }
WorkspaceContainer workspaceContainer = repositoryContainer.getWorkspaceContainer(workspaceName);
if (workspaceContainer == null || !workspaceContainer.getWorkspaceInitializer().isWorkspaceInitialized())
@@ -409,7 +417,9 @@
{
if (getState() == OFFLINE)
+ {
LOG.warn("Repository " + getName() + " is OFFLINE.");
+ }
WorkspaceContainer workspaceContainer = repositoryContainer.getWorkspaceContainer(workspaceName);
if (workspaceContainer == null || !workspaceContainer.getWorkspaceInitializer().isWorkspaceInitialized())
@@ -597,7 +607,9 @@
{
if (getState() == OFFLINE)
+ {
LOG.warn("Repository " + getName() + " is OFFLINE.");
+ }
ConversationState state;
@@ -606,9 +618,13 @@
public ConversationState run() throws Exception
{
if (credentials != null)
+ {
return authenticationPolicy.authenticate(credentials);
+ }
else
+ {
return authenticationPolicy.authenticate();
+ }
}
};
try
@@ -653,12 +669,16 @@
{
workspaceName = config.getDefaultWorkspaceName();
if (workspaceName == null)
+ {
throw new NoSuchWorkspaceException("Both workspace and default-workspace name are null! ");
+ }
}
if (!isWorkspaceInitialized(workspaceName))
+ {
throw new NoSuchWorkspaceException("Workspace '" + workspaceName + "' not found. "
+ "Probably is not initialized. If so either Initialize it manually or turn on the RepositoryInitializer");
+ }
SessionFactory sessionFactory = repositoryContainer.getWorkspaceContainer(workspaceName).getSessionFactory();
return sessionFactory.createSession(state);
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/reading/TestProperty.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/reading/TestProperty.java 2012-01-11 10:44:54 UTC (rev 5440)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/reading/TestProperty.java 2012-01-11 11:22:23 UTC (rev 5441)
@@ -19,6 +19,7 @@
package org.exoplatform.services.jcr.api.reading;
import org.exoplatform.services.jcr.JcrAPIBaseTest;
+import org.exoplatform.services.jcr.impl.core.PropertyImpl;
import org.exoplatform.services.jcr.impl.core.value.BinaryValue;
import java.io.ByteArrayInputStream;
@@ -27,12 +28,17 @@
import java.util.Calendar;
import java.util.GregorianCalendar;
+import javax.jcr.ItemExistsException;
import javax.jcr.Node;
+import javax.jcr.PathNotFoundException;
import javax.jcr.Property;
import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
import javax.jcr.Value;
import javax.jcr.ValueFormatException;
+import javax.jcr.lock.LockException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.version.VersionException;
/**
* Created by The eXo Platform SAS.
@@ -167,6 +173,16 @@
node.setProperty("long", valueFactory.createValue(15l));
assertEquals(15, node.getProperty("long").getLong());
assertEquals(15, node.getProperty("long").getValue().getLong());
+
+ node.setProperty("noLong", "someText");
+ try
+ {
+ node.getProperty("noLong").getLong();
+ fail();
+ }
+ catch (ValueFormatException e)
+ {
+ }
}
public void testGetDouble() throws RepositoryException
@@ -174,6 +190,7 @@
node.setProperty("double", session.getValueFactory().createValue(15));
assertEquals(15, (int)node.getProperty("double").getDouble());
assertEquals(15, (int)node.getProperty("double").getValue().getDouble());
+
try
{
node.getProperty("multi").getDouble();
@@ -183,6 +200,15 @@
{
}
+ node.setProperty("noDouble", "someText");
+ try
+ {
+ node.getProperty("noDouble").getDouble();
+ fail();
+ }
+ catch (ValueFormatException e)
+ {
+ }
}
public void testGetDate() throws RepositoryException
@@ -192,6 +218,16 @@
node.setProperty("date", session.getValueFactory().createValue(calendar));
assertEquals(calendar.getTimeInMillis(), node.getProperty("date").getDate().getTimeInMillis());
assertEquals(calendar.getTimeInMillis(), node.getProperty("date").getValue().getDate().getTimeInMillis());
+
+ node.setProperty("noDate", "someText");
+ try
+ {
+ node.getProperty("noDate").getDate();
+ fail();
+ }
+ catch (ValueFormatException e)
+ {
+ }
}
public void testGetBoolean() throws RepositoryException
@@ -293,8 +329,28 @@
assertEquals(refNode.getPath(), node1.getProperty("reference").getNode().getPath());
refNode.remove();
- node1.remove();
+ node1.setProperty("noNode", "someText");
+ try
+ {
+ node1.getProperty("noNode").getNode();
+ fail();
+ }
+ catch (ValueFormatException e)
+ {
+ }
+ finally
+ {
+ node1.remove();
+ }
}
-}
+ public void testEquals() throws ItemExistsException, PathNotFoundException, VersionException,
+ ConstraintViolationException, LockException, RepositoryException
+ {
+ Node testNode = root.addNode("testNode");
+ PropertyImpl testProperty = (PropertyImpl)testNode.setProperty("testProperty", "someText");
+ assertFalse(testProperty.equals(new Object()));
+
+ }
+}
\ No newline at end of file
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestInitRepository.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestInitRepository.java 2012-01-11 10:44:54 UTC (rev 5440)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestInitRepository.java 2012-01-11 11:22:23 UTC (rev 5441)
@@ -22,12 +22,17 @@
import org.exoplatform.services.jcr.RepositoryService;
import org.exoplatform.services.jcr.access.AccessControlList;
import org.exoplatform.services.jcr.access.SystemIdentity;
+import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
import org.exoplatform.services.jcr.config.WorkspaceEntry;
import org.exoplatform.services.jcr.core.ExtendedNode;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
+import org.exoplatform.services.security.MembershipEntry;
+import java.util.ArrayList;
+
import javax.jcr.NamespaceRegistry;
+import javax.jcr.NoSuchWorkspaceException;
import javax.jcr.Node;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
@@ -86,7 +91,6 @@
public void testInitRegularWorkspace() throws Exception
{
-
RepositoryService service = (RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);
RepositoryImpl defRep = (RepositoryImpl)service.getDefaultRepository();
String sysWs = defRep.getSystemWorkspaceName();
@@ -102,7 +106,9 @@
}
}
if (wsName == null)
+ {
fail("not system workspace not found for test!!");
+ }
// TODO
// defRep.initWorkspace(wsName, "nt:unstructured");
@@ -123,7 +129,6 @@
public void testAutoInitRootPermition()
{
-
WorkspaceEntry wsEntry = (WorkspaceEntry)session.getContainer().getComponentInstanceOfType(WorkspaceEntry.class);
AccessControlList expectedAcl = new AccessControlList();
@@ -142,6 +147,54 @@
{
fail(e.getLocalizedMessage());
}
+ }
+ public void testCanRemoveWorkspaceWhenWorkspaceNotFound() throws RepositoryException,
+ RepositoryConfigurationException
+ {
+ try
+ {
+ repository.canRemoveWorkspace(" ");
+ fail();
+ }
+ catch (NoSuchWorkspaceException e)
+ {
+ }
}
-}
+
+ public void testCreateWorkspaceWhenWorkspaceHaventConfig()
+ {
+ try
+ {
+ repository.createWorkspace("someWorkspace");
+ fail();
+ }
+ catch (RepositoryException e)
+ {
+ }
+ }
+
+ public void testGetSystemSessionWhenWorkspaceNotFound()
+ {
+ try
+ {
+ repository.getSystemSession(" ");
+ fail();
+ }
+ catch (RepositoryException e)
+ {
+ }
+ }
+
+ public void testGetDynamicSessionWhenWorkspaceNotFound()
+ {
+ try
+ {
+ repository.getDynamicSession(" ", new ArrayList<MembershipEntry>());
+ fail();
+ }
+ catch (RepositoryException e)
+ {
+ }
+ }
+}
\ No newline at end of file
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestLocationFactory.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestLocationFactory.java 2012-01-11 10:44:54 UTC (rev 5440)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestLocationFactory.java 2012-01-11 11:22:23 UTC (rev 5441)
@@ -20,6 +20,8 @@
import junit.framework.TestCase;
+import org.exoplatform.services.jcr.datamodel.QPathEntry;
+
import javax.jcr.RepositoryException;
/**
@@ -169,4 +171,42 @@
}
}
-}
+ public void testFormatPathElement() throws RepositoryException
+ {
+ assertEquals("test", factory.formatPathElement(new QPathEntry("", "test", 0)));
+ }
+
+ public void testParsePathEntryWhenParsNameIsNull()
+ {
+ try
+ {
+ factory.parseJCRName(null);
+ fail();
+ }
+ catch (RepositoryException e)
+ {
+ }
+ }
+
+ public void testIsNotLocalName()
+ {
+ try
+ {
+ factory.parseJCRName("");
+ fail();
+ }
+ catch (RepositoryException e)
+ {
+ }
+
+ try
+ {
+ factory.parseJCRName(" ");
+ fail();
+ }
+ catch (RepositoryException e)
+ {
+ }
+ }
+
+}
\ No newline at end of file
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestSessionDataManager.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestSessionDataManager.java 2012-01-11 10:44:54 UTC (rev 5440)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestSessionDataManager.java 2012-01-11 11:22:23 UTC (rev 5441)
@@ -35,8 +35,14 @@
import java.util.ArrayList;
import java.util.List;
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.ItemExistsException;
+import javax.jcr.PathNotFoundException;
import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
+import javax.jcr.lock.LockException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.version.VersionException;
/**
* Created by The eXo Platform SAS.
@@ -378,4 +384,72 @@
assertNotNull(modificationManager.getItemData(QPath.makeChildPath(((NodeImpl)root).getData().getQPath(),
new InternalQName("", "testgetitemNode"))));
}
-}
+
+ public void testIsDeleted() throws ItemExistsException, PathNotFoundException, VersionException,
+ ConstraintViolationException, LockException, RepositoryException
+ {
+ NodeImpl testNode = (NodeImpl)root.addNode("testNode");
+ String identifier = testNode.getIdentifier();
+ QPath itemPath = testNode.getData().getQPath();
+
+ assertFalse(modificationManager.isDeleted(identifier));
+ assertFalse(modificationManager.isDeleted(itemPath));
+
+ testNode.remove();
+ assertTrue(modificationManager.isDeleted(identifier));
+ assertTrue(modificationManager.isDeleted(itemPath));
+ }
+
+ public void testGetACLWhenNodeIsRoot() throws RepositoryException
+ {
+ NodeImpl rootNode = (NodeImpl)root;
+ assertEquals(rootNode.getACL(), modificationManager.getACL(rootNode.getData().getQPath()));
+ }
+
+ public void testUpdateWhenStateIsDeleted() throws ItemExistsException, PathNotFoundException, VersionException,
+ ConstraintViolationException, LockException, RepositoryException
+ {
+ NodeImpl testNode = (NodeImpl)root.addNode("testNode");
+ ItemState state = ItemState.createDeletedState(testNode.getData());
+
+ try
+ {
+ modificationManager.update(state, false);
+ fail();
+ }
+ catch (RepositoryException e)
+ {
+ }
+ }
+
+ public void testUpdateStateWhenStateIsDeleted() throws ItemExistsException, PathNotFoundException, VersionException,
+ ConstraintViolationException, LockException, RepositoryException
+ {
+ NodeImpl testNode = (NodeImpl)root.addNode("testNode");
+ ItemState state = ItemState.createDeletedState(testNode.getData());
+
+ try
+ {
+ modificationManager.updateItemState(state);
+ fail();
+ }
+ catch (RepositoryException e)
+ {
+ }
+ }
+
+ public void testRefreshWhenNodeHasModifiedStatus() throws ItemExistsException, PathNotFoundException,
+ VersionException, ConstraintViolationException, LockException, RepositoryException
+ {
+ NodeImpl testNode = (NodeImpl)root.addNode("testNode");
+
+ try
+ {
+ modificationManager.refresh(testNode.getData());
+ fail();
+ }
+ catch (InvalidItemStateException e)
+ {
+ }
+ }
+}
\ No newline at end of file
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/name/TestJCRPath.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/name/TestJCRPath.java 2012-01-11 10:44:54 UTC (rev 5440)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/name/TestJCRPath.java 2012-01-11 11:22:23 UTC (rev 5441)
@@ -115,4 +115,11 @@
assertEquals("/jcr:node", path.makeAncestorPath(2).getAsString(false));
}
-}
+
+ public void testEquals() throws Exception
+ {
+ JCRPath path = factory.parseAbsPath("/jcr:node/node1[2]/exo:node2");
+ assertFalse(path.equals(null));
+ assertFalse(path.equals(new Object()));
+ }
+}
\ No newline at end of file
14 years, 3 months
exo-jcr SVN: r5440 - kernel/branches/2.4.x/exo.kernel.commons/src/main/java/org/exoplatform/commons/utils.
by do-not-reply@jboss.org
Author: tolusha
Date: 2012-01-11 05:44:54 -0500 (Wed, 11 Jan 2012)
New Revision: 5440
Modified:
kernel/branches/2.4.x/exo.kernel.commons/src/main/java/org/exoplatform/commons/utils/PrivilegedFileHelper.java
Log:
EXOJCR-968: Fix resource loading
Modified: kernel/branches/2.4.x/exo.kernel.commons/src/main/java/org/exoplatform/commons/utils/PrivilegedFileHelper.java
===================================================================
--- kernel/branches/2.4.x/exo.kernel.commons/src/main/java/org/exoplatform/commons/utils/PrivilegedFileHelper.java 2012-01-11 10:10:34 UTC (rev 5439)
+++ kernel/branches/2.4.x/exo.kernel.commons/src/main/java/org/exoplatform/commons/utils/PrivilegedFileHelper.java 2012-01-11 10:44:54 UTC (rev 5440)
@@ -51,7 +51,7 @@
{
public InputStream run()
{
- return PrivilegedFileHelper.class.getClass().getResourceAsStream(resource);
+ return PrivilegedFileHelper.class.getResourceAsStream(resource);
}
};
14 years, 3 months
exo-jcr SVN: r5439 - jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc.
by do-not-reply@jboss.org
Author: tolusha
Date: 2012-01-11 05:10:34 -0500 (Wed, 11 Jan 2012)
New Revision: 5439
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainerChecker.java
Log:
EXOJCR-1697: Improve SQL access, fix query for CheckController
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainerChecker.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainerChecker.java 2012-01-11 10:08:28 UTC (rev 5438)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainerChecker.java 2012-01-11 10:10:34 UTC (rev 5439)
@@ -218,16 +218,16 @@
queries
.add(new InspectionQuery(
jdbcDataContainer.multiDb
- ? "select * from JCR_MITEM I where EXISTS (select count(VERSION) from JCR_MITEM J"
+ ? "select * from JCR_MITEM I where EXISTS (select * from JCR_MITEM J"
+ " WHERE I.PARENT_ID = J.PARENT_ID AND I.NAME = J.NAME and I.I_INDEX = J.I_INDEX and I.I_CLASS = J.I_CLASS"
- + " GROUP BY PARENT_ID, NAME, I_INDEX, I_CLASS HAVING count(VERSION) > 1)"
+ + " and I.VERSION != J.VERSION)"
: "select * from JCR_SITEM I where I.CONTAINER_NAME='" + jdbcDataContainer.containerName + "' and"
- + " EXISTS (select count(VERSION) from JCR_SITEM J WHERE I.CONTAINER_NAME = J.CONTAINER_NAME and"
+ + " EXISTS (select * from JCR_SITEM J WHERE I.CONTAINER_NAME = J.CONTAINER_NAME and"
+ " I.PARENT_ID = J.PARENT_ID AND I.NAME = J.NAME and I.I_INDEX = J.I_INDEX and I.I_CLASS = J.I_CLASS"
- + " GROUP BY CONTAINER_NAME, PARENT_ID, NAME, I_INDEX, I_CLASS HAVING count(VERSION) > 1)", new String[]{
- DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME, DBConstants.COLUMN_VERSION,
- DBConstants.COLUMN_CLASS, DBConstants.COLUMN_INDEX}, "Several versions of same item.",
- InspectionStatus.ERR));
+ + " and I.VERSION != J.VERSION)",
+ new String[]{DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME,
+ DBConstants.COLUMN_VERSION, DBConstants.COLUMN_CLASS, DBConstants.COLUMN_INDEX},
+ "Several versions of same item.", InspectionStatus.ERR));
// using existing DataSource to get a JDBC Connection.
Connection jdbcConn = jdbcDataContainer.getConnectionFactory().getJdbcConnection();
14 years, 3 months
exo-jcr SVN: r5438 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc.
by do-not-reply@jboss.org
Author: tolusha
Date: 2012-01-11 05:08:28 -0500 (Wed, 11 Jan 2012)
New Revision: 5438
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainerChecker.java
Log:
EXOJCR-1697: Improve SQL access, fix query for CheckController
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainerChecker.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainerChecker.java 2012-01-11 09:17:07 UTC (rev 5437)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainerChecker.java 2012-01-11 10:08:28 UTC (rev 5438)
@@ -218,13 +218,13 @@
queries
.add(new InspectionQuery(
jdbcDataContainer.multiDb
- ? "select * from JCR_MITEM I where EXISTS (select count(VERSION) from JCR_MITEM J"
+ ? "select * from JCR_MITEM I where EXISTS (select * from JCR_MITEM J"
+ " WHERE I.PARENT_ID = J.PARENT_ID AND I.NAME = J.NAME and I.I_INDEX = J.I_INDEX and I.I_CLASS = J.I_CLASS"
- + " GROUP BY PARENT_ID, NAME, I_INDEX, I_CLASS HAVING count(VERSION) > 1)"
+ + " and I.VERSION != J.VERSION)"
: "select * from JCR_SITEM I where I.CONTAINER_NAME='" + jdbcDataContainer.containerName + "' and"
- + " EXISTS (select count(VERSION) from JCR_SITEM J WHERE I.CONTAINER_NAME = J.CONTAINER_NAME and"
+ + " EXISTS (select * from JCR_SITEM J WHERE I.CONTAINER_NAME = J.CONTAINER_NAME and"
+ " I.PARENT_ID = J.PARENT_ID AND I.NAME = J.NAME and I.I_INDEX = J.I_INDEX and I.I_CLASS = J.I_CLASS"
- + " GROUP BY CONTAINER_NAME, PARENT_ID, NAME, I_INDEX, I_CLASS HAVING count(VERSION) > 1)",
+ + " and I.VERSION != J.VERSION)",
new String[]{
DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME, DBConstants.COLUMN_VERSION,
DBConstants.COLUMN_CLASS, DBConstants.COLUMN_INDEX}, "Several versions of same item.",
14 years, 3 months