Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.5.0 deg into 5.0.0 #2

Open
wants to merge 18 commits into
base: modeshape-5.0.0-deg
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions boms/modeshape-bom-embedded/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.modeshape.bom</groupId>
<artifactId>modeshape-bom-embedded</artifactId>
<version>4.5-SNAPSHOT</version>
<version>4.5.0.1-deg-SNAPSHOT</version>

<name>ModeShape BOM for embedded usage</name>

Expand Down Expand Up @@ -84,8 +84,8 @@
<!-- ***************** -->
<!-- Repository Deployment URLs -->
<!-- ***************** -->
<jboss.releases.repo.url>https://repository.jboss.org/nexus/service/local/staging/deploy/maven2/</jboss.releases.repo.url>
<jboss.snapshots.repo.url>https://repository.jboss.org/nexus/content/repositories/snapshots/</jboss.snapshots.repo.url>
<jboss.releases.repo.url>http://nexus.data-experts.de:8081/nexus/content/repositories/portal/</jboss.releases.repo.url>
<jboss.snapshots.repo.url>http://nexus.data-experts.de:8081/nexus/content/repositories/portal-snapshot/</jboss.snapshots.repo.url>
</properties>

<!--
Expand Down
6 changes: 3 additions & 3 deletions boms/modeshape-bom-jbossas/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.modeshape.bom</groupId>
<artifactId>modeshape-bom-jbossas</artifactId>
<version>4.5-SNAPSHOT</version>
<version>4.5.0.1-deg-SNAPSHOT</version>

<name>ModeShape BOM for use within a JBoss App Server</name>

Expand Down Expand Up @@ -52,8 +52,8 @@
<!-- ***************** -->
<!-- Repository Deployment URLs -->
<!-- ***************** -->
<jboss.releases.repo.url>https://repository.jboss.org/nexus/service/local/staging/deploy/maven2/</jboss.releases.repo.url>
<jboss.snapshots.repo.url>https://repository.jboss.org/nexus/content/repositories/snapshots/</jboss.snapshots.repo.url>
<jboss.releases.repo.url>http://nexus.data-experts.de:8081/nexus/content/repositories/portal/</jboss.releases.repo.url>
<jboss.snapshots.repo.url>http://nexus.data-experts.de:8081/nexus/content/repositories/portal-snapshot/</jboss.snapshots.repo.url>

<jcr.version>2.0</jcr.version>
<version.org.wildfly>9.0.0.Final</version.org.wildfly>
Expand Down
6 changes: 3 additions & 3 deletions boms/modeshape-bom-remote-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.modeshape.bom</groupId>
<artifactId>modeshape-bom-remote-client</artifactId>
<version>4.5-SNAPSHOT</version>
<version>4.5.0.1-deg-SNAPSHOT</version>

<name>ModeShape BOM for remote REST and JDBC clients</name>

Expand Down Expand Up @@ -52,8 +52,8 @@
<!-- ***************** -->
<!-- Repository Deployment URLs -->
<!-- ***************** -->
<jboss.releases.repo.url>https://repository.jboss.org/nexus/service/local/staging/deploy/maven2/</jboss.releases.repo.url>
<jboss.snapshots.repo.url>https://repository.jboss.org/nexus/content/repositories/snapshots/</jboss.snapshots.repo.url>
<jboss.releases.repo.url>http://nexus.data-experts.de:8081/nexus/content/repositories/portal/</jboss.releases.repo.url>
<jboss.snapshots.repo.url>http://nexus.data-experts.de:8081/nexus/content/repositories/portal-snapshot/</jboss.snapshots.repo.url>
<jcr.version>2.0</jcr.version>
</properties>

Expand Down
2 changes: 1 addition & 1 deletion checkstyle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.modeshape</groupId>
<artifactId>modeshape-checkstyle</artifactId>
<version>4.5-SNAPSHOT</version>
<version>4.5.0.1-deg-SNAPSHOT</version>
<name>ModeShape Checkstyle Rules</name>
<description>Contains the definitions for the ModeShape commons code style and conventions</description>

Expand Down
2 changes: 1 addition & 1 deletion connectors/modeshape-connector-cmis/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.modeshape</groupId>
<artifactId>modeshape-connectors</artifactId>
<version>4.5-SNAPSHOT</version>
<version>4.5.0.1-deg-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<!-- The groupId and version values are inherited from parent -->
Expand Down
2 changes: 1 addition & 1 deletion connectors/modeshape-connector-git/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.modeshape</groupId>
<artifactId>modeshape-connectors</artifactId>
<version>4.5-SNAPSHOT</version>
<version>4.5.0.1-deg-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<!-- The groupId and version values are inherited from parent -->
Expand Down
2 changes: 1 addition & 1 deletion connectors/modeshape-connector-jdbc-metadata/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.modeshape</groupId>
<artifactId>modeshape-connectors</artifactId>
<version>4.5-SNAPSHOT</version>
<version>4.5.0.1-deg-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<!-- The groupId and version values are inherited from parent -->
Expand Down
2 changes: 1 addition & 1 deletion connectors/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.modeshape</groupId>
<artifactId>modeshape-parent</artifactId>
<version>4.5-SNAPSHOT</version>
<version>4.5.0.1-deg-SNAPSHOT</version>
<relativePath>../modeshape-parent/pom.xml</relativePath>
</parent>
<!-- The groupId and version values are inherited from parent -->
Expand Down
2 changes: 1 addition & 1 deletion demos/embedded-repo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.modeshape</groupId>
<artifactId>modeshape-parent</artifactId>
<version>4.5-SNAPSHOT</version>
<version>4.5.0.1-deg-SNAPSHOT</version>
<relativePath>../../modeshape-parent</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion demos/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.modeshape</groupId>
<artifactId>modeshape-parent</artifactId>
<version>4.5-SNAPSHOT</version>
<version>4.5.0.1-deg-SNAPSHOT</version>
<relativePath>../modeshape-parent</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion demos/sequencers/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.modeshape</groupId>
<artifactId>modeshape-parent</artifactId>
<version>4.5-SNAPSHOT</version>
<version>4.5.0.1-deg-SNAPSHOT</version>
<relativePath>../../modeshape-parent/pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion deploy/jbossas/modeshape-jbossas-cmis-war/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.modeshape</groupId>
<artifactId>modeshape-parent</artifactId>
<version>4.5-SNAPSHOT</version>
<version>4.5.0.1-deg-SNAPSHOT</version>
<relativePath>../../../modeshape-parent/pom.xml</relativePath>
</parent>
<artifactId>modeshape-jbossas-cmis-war</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion deploy/jbossas/modeshape-jbossas-explorer-war/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.modeshape</groupId>
<artifactId>modeshape-parent</artifactId>
<version>4.5-SNAPSHOT</version>
<version>4.5.0.1-deg-SNAPSHOT</version>
<relativePath>../../../modeshape-parent/pom.xml</relativePath>
</parent>
<artifactId>modeshape-jbossas-explorer-war</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion deploy/jbossas/modeshape-jbossas-subsystem/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.modeshape</groupId>
<artifactId>modeshape-parent</artifactId>
<version>4.5-SNAPSHOT</version>
<version>4.5.0.1-deg-SNAPSHOT</version>
<relativePath>../../../modeshape-parent/pom.xml</relativePath>
</parent>
<!-- The groupId and version values are inherited from parent -->
Expand Down
2 changes: 1 addition & 1 deletion deploy/jbossas/modeshape-jbossas-web-rest-war/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.modeshape</groupId>
<artifactId>modeshape-parent</artifactId>
<version>4.5-SNAPSHOT</version>
<version>4.5.0.1-deg-SNAPSHOT</version>
<relativePath>../../../modeshape-parent/pom.xml</relativePath>
</parent>
<artifactId>modeshape-jbossas-web-rest-war</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion deploy/jbossas/modeshape-jbossas-web-webdav-war/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.modeshape</groupId>
<artifactId>modeshape-parent</artifactId>
<version>4.5-SNAPSHOT</version>
<version>4.5.0.1-deg-SNAPSHOT</version>
<relativePath>../../../modeshape-parent/pom.xml</relativePath>
</parent>
<artifactId>modeshape-jbossas-web-webdav-war</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion deploy/jbossas/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.modeshape</groupId>
<artifactId>modeshape-parent</artifactId>
<version>4.5-SNAPSHOT</version>
<version>4.5.0.1-deg-SNAPSHOT</version>
<relativePath>../../modeshape-parent/pom.xml</relativePath>
</parent>
<packaging>pom</packaging>
Expand Down
2 changes: 1 addition & 1 deletion deploy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.modeshape</groupId>
<artifactId>modeshape-parent</artifactId>
<version>4.5-SNAPSHOT</version>
<version>4.5.0.1-deg-SNAPSHOT</version>
<relativePath>../modeshape-parent</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion extractors/modeshape-extractor-tika/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.modeshape</groupId>
<artifactId>modeshape-extractors</artifactId>
<version>4.5-SNAPSHOT</version>
<version>4.5.0.1-deg-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<!-- The groupId and version values are inherited from parent -->
Expand Down
2 changes: 1 addition & 1 deletion extractors/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.modeshape</groupId>
<artifactId>modeshape-parent</artifactId>
<version>4.5-SNAPSHOT</version>
<version>4.5.0.1-deg-SNAPSHOT</version>
<relativePath>../modeshape-parent/pom.xml</relativePath>
</parent>
<!-- The groupId and version values are inherited from parent -->
Expand Down
2 changes: 1 addition & 1 deletion index-providers/modeshape-lucene-index-provider/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.modeshape</groupId>
<artifactId>modeshape-index-providers</artifactId>
<version>4.5-SNAPSHOT</version>
<version>4.5.0.1-deg-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<!-- The groupId and version values are inherited from parent -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,20 @@
package org.modeshape.jcr.index.lucene;

import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.DoubleField;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.IntField;
import org.apache.lucene.document.LongField;
import org.apache.lucene.document.StringField;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.Term;
import org.apache.lucene.util.BytesRef;
import org.modeshape.common.annotation.Immutable;
import org.modeshape.common.annotation.ThreadSafe;
import org.modeshape.common.util.CheckArg;
Expand Down Expand Up @@ -69,13 +77,18 @@ public void add( final String nodeKey, final String propertyName, final Object[]
// we're updating an existing document
logger.debug("Updating the property '{0}' of document '{1}' in the Lucene index '{2}' with the values '{3}'", values,
propertyName, nodeKey, name, values);

Document document = searcher.loadDocumentById(nodeKey);
// remove the old values for the property from the document
removeProperty(propertyName, document);
// add the new values
addProperty(nodeKey, document, propertyName, values);
writer.updateDocument(FieldUtil.idTerm(nodeKey), document);
// load the existing document
Document oldDocument = searcher.loadDocumentById(nodeKey);

//clone the old document without the property we're updating...
Document newDocument = clone(oldDocument, propertyName);

//add the fields for the new property
List<Field> fields = valuesToFields(propertyName, values);
for (Field field : fields) {
newDocument.add(field);
}
writer.updateDocument(FieldUtil.idTerm(nodeKey), newDocument);
} else {
// we're creating the document for the first time...
logger.debug("Adding the document '{0}' in the Lucene Index '{1}' with the property '{2}' and values '{3}",
Expand All @@ -90,6 +103,49 @@ public void add( final String nodeKey, final String propertyName, final Object[]
throw new LuceneIndexException(e);
}
}

private Document clone(Document oldDocument, String... excludeProps) {
List<String> excluded = Arrays.asList(excludeProps);

Document newDocument = new Document();
for (IndexableField indexableField : oldDocument) {
Field oldField = (Field) indexableField;
String name = oldField.name();
if (excluded.contains(name)) {
continue;
}
Field newField = clone(oldField);
newDocument.add(newField);
}
return newDocument;
}

private Field clone(Field existing) {
String name = existing.name();

if (name.startsWith(FieldUtil.LENGTH_PREFIX)) {
// these are always stored as longs
return new LongField(name, Long.valueOf(existing.stringValue()), Field.Store.YES);
}
Number numberValue = existing.numericValue();
if (numberValue instanceof Integer) {
return new IntField(name, numberValue.intValue(), Field.Store.YES);
} else if (numberValue instanceof Long) {
return new LongField(name, numberValue.longValue(), Field.Store.YES);
} else if (numberValue instanceof Double) {
return new DoubleField(name, numberValue.doubleValue(), Field.Store.YES);
}
String stringValue = existing.stringValue();
if (stringValue != null) {
return new StringField(name, stringValue, Field.Store.YES);
}
BytesRef bytesRef = existing.binaryValue();
if (bytesRef != null) {
// we don't really store any binary fields
return new StringField(name, bytesRef, Field.Store.YES);
}
throw new LuceneIndexException("Cannot clone existing field: " + existing);
}

@Override
protected void preCommit( Map<String, String> commitData ) {
Expand All @@ -108,16 +164,20 @@ protected void remove(final String nodeKey, final String propertyName) {
}
try {
Document document = searcher.loadDocumentById(nodeKey);
removeProperty(propertyName, document);
if (document.getFields().isEmpty()) {
boolean hasProperty = document.getField(propertyName) != null;
if (!hasProperty) {
return;
}
Term idTerm = FieldUtil.idTerm(nodeKey);
if (document.getFields().size() == 1) {
// there are no more fields, so remove the entire document....
writer.deleteDocuments(FieldUtil.idTerm(nodeKey));
writer.deleteDocuments(idTerm);
// mark the node key as removed
cache.remove(nodeKey);
} else {
// update the document after adding back the ID (which was removed during removeProperty)
document.add(FieldUtil.idField(nodeKey));
writer.updateDocument(FieldUtil.idTerm(nodeKey), document);
// create a clone without the property
Document newDocument = clone(document, propertyName);
writer.updateDocument(idTerm, newDocument);
}
} catch (IOException e) {
throw new LuceneIndexException(e);
Expand All @@ -141,21 +201,6 @@ private boolean documentExists( String nodeKey ) {
return cache.hasNode(nodeKey) || writer.getCommitData().containsKey(nodeKey);
}

private void removeProperty( String propertyName, Document document ) {
Iterator<IndexableField> fieldIterator = document.iterator();
while (fieldIterator.hasNext()) {
IndexableField field = fieldIterator.next();
String name = field.name();
if (name.equals(propertyName)) {
// there can be multiple properties with the same name (multivalued) so we need to call remove for each one
fieldIterator.remove();
} else if (FieldUtil.ID.equals(name)) {
// for some inexplicable reason (Lucene bug ??) this has to be removed and readded with each update
fieldIterator.remove();
}
}
}

/**
* A simple holder which tracks for each index writer session the document keys which exist in the index
* and then writes this information in the commit data. This avoids the document searching required when updating the column
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import javax.jcr.Node;
import javax.jcr.PropertyType;
import org.junit.Test;
import org.modeshape.common.FixFor;
import org.modeshape.jcr.LocalIndexProviderTest;
import org.modeshape.jcr.api.JcrTools;
import org.modeshape.jcr.api.index.IndexDefinition;
Expand Down Expand Up @@ -52,6 +53,7 @@ protected String providerName() {
}

@Test
@FixFor( "MODE-2520" )
public void shouldUseMultiColumnIndex() throws Exception {
registerNodeType("nt:testType");
Map<String, Integer> properties = new HashMap<>();
Expand Down
2 changes: 1 addition & 1 deletion index-providers/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.modeshape</groupId>
<artifactId>modeshape-parent</artifactId>
<version>4.5-SNAPSHOT</version>
<version>4.5.0.1-deg-SNAPSHOT</version>
<relativePath>../modeshape-parent/pom.xml</relativePath>
</parent>
<!-- The groupId and version values are inherited from parent -->
Expand Down
Loading