Skip to content

[bugfix] make exist-db 5.3 compatible #196

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

Open
wants to merge 3 commits into
base: develop
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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<project.build.source>1.8</project.build.source>
<project.build.target>1.8</project.build.target>

<exist.version>5.3.0</exist.version> <!-- minimum version is 5.1.0 -->
<exist.version>5.3.0</exist.version> <!-- minimum version is 5.3.0 -->
<activemq.version>5.16.3</activemq.version>
<commonspool2.version>2.11.1</commonspool2.version>
<hawtbuf.version>1.11</hawtbuf.version>
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/exist/jms/messaging/MessagingJmsListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -279,22 +279,22 @@ private MapType getMessageProperties(final Message msg, final XQueryContext xque
addStringKV(map, key, value);

} else if (obj instanceof Integer) {
final Integer localValue = msg.getIntProperty(key);
final int localValue = msg.getIntProperty(key);
final ValueSequence vs = new ValueSequence(new IntegerValue(localValue));
addKV(map, key, vs);

} else if (obj instanceof Double) {
final Double localValue = msg.getDoubleProperty(key);
final double localValue = msg.getDoubleProperty(key);
final ValueSequence vs = new ValueSequence(new DoubleValue(localValue));
addKV(map, key, vs);

} else if (obj instanceof Boolean) {
final Boolean localValue = msg.getBooleanProperty(key);
final boolean localValue = msg.getBooleanProperty(key);
final ValueSequence vs = new ValueSequence(new BooleanValue(localValue));
addKV(map, key, vs);

} else if (obj instanceof Float) {
final Float localValue = msg.getFloatProperty(key);
final float localValue = msg.getFloatProperty(key);
final ValueSequence vs = new ValueSequence(new FloatValue(localValue));
addKV(map, key, vs);

Expand Down Expand Up @@ -432,7 +432,7 @@ private Sequence processXML(final byte[] data, final boolean isGzipped) throws X
if (validationReport.isValid()) {
content = adapter.getDocument();
} else {
final String txt = String.format("Received document is not valid: %s", validationReport.toString());
final String txt = String.format("Received document is not valid: %s", validationReport);
LOG.debug(txt);
throw new XPathException(JMS023, txt);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@
import org.exist.dom.persistent.DocumentImpl;
import org.exist.jms.replication.shared.MessageHelper;
import org.exist.jms.replication.shared.ReplicationTxnManager;
import org.exist.jms.shared.*;
import org.exist.jms.shared.Constants;
import org.exist.jms.shared.Identity;
import org.exist.jms.shared.Report;
import org.exist.jms.shared.eXistMessage;
import org.exist.jms.shared.eXistMessagingListener;
import org.exist.security.Account;
import org.exist.security.Group;
import org.exist.security.Permission;
Expand Down Expand Up @@ -641,7 +645,9 @@ private void createCollection(final eXistMessage em) {
createOrCheckCollection(sourcePath);

// Update meta data
updateCollectionMetadata(sourcePath, userName, groupName, mode, createTime);
try (final Collection collection = updateCollectionMetadata(sourcePath, userName, groupName, mode, createTime)) {
LOG.info("Updated meta data for {}", collection.getURI().toString());
}
}

/**
Expand Down Expand Up @@ -714,7 +720,7 @@ private Collection updateCollectionMetadata(final XmldbURI sourcePath, final Opt
permission.setMode(mode.get());
}
// Set Create time only
createTime.ifPresent(collection::setCreationTime);
createTime.ifPresent(collection::setCreated);

broker.saveCollection(txn, collection);

Expand Down Expand Up @@ -897,7 +903,7 @@ private void updateMetadataCollection(final eXistMessage em) {
permission.setMode(mode.get());
}

created.ifPresent(collection::setCreationTime);
created.ifPresent(collection::setCreated);

// Make persistent
broker.saveCollection(txn, collection);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/exist/jms/shared/JmsConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public void validate() throws XPathException {
public boolean isDurable() {
final String durable = getProperty(Constants.DURABLE);

return durable == null ? false : BooleanUtils.toBoolean(durable);
return durable != null && BooleanUtils.toBoolean(durable);

}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/exist/jms/shared/ReportItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
public class ReportItem {

private final Date timestamp;
private Throwable throwable = new Throwable("EMPTY");
private CONTEXT context = CONTEXT.NOTDEFINED;
private Throwable throwable;
private CONTEXT context;

public ReportItem(final Throwable throwable, final CONTEXT context) {
this.timestamp = new Date();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,31 +49,31 @@ public class ManageReceivers extends BasicFunction {
new QName(START, JmsModule.NAMESPACE_URI, JmsModule.PREFIX), "Start receiver",
new SequenceType[]{
new FunctionParameterSequenceType(ID, Type.INTEGER, Cardinality.EXACTLY_ONE, RECEIVER_ID),},
new SequenceType(Type.ITEM, Cardinality.EMPTY)
new SequenceType(Type.ITEM, Cardinality.EMPTY_SEQUENCE)
),
new FunctionSignature(
new QName(STOP, JmsModule.NAMESPACE_URI, JmsModule.PREFIX), "Stop receiver",
new SequenceType[]{
new FunctionParameterSequenceType(ID, Type.INTEGER, Cardinality.EXACTLY_ONE, RECEIVER_ID),},
new SequenceType(Type.ITEM, Cardinality.EMPTY)
new SequenceType(Type.ITEM, Cardinality.EMPTY_SEQUENCE)
),
new FunctionSignature(
new QName(CLOSE, JmsModule.NAMESPACE_URI, JmsModule.PREFIX), "Close receiver",
new SequenceType[]{
new FunctionParameterSequenceType(ID, Type.INTEGER, Cardinality.EXACTLY_ONE, RECEIVER_ID),},
new SequenceType(Type.ITEM, Cardinality.EMPTY)
new SequenceType(Type.ITEM, Cardinality.EMPTY_SEQUENCE)
),
new FunctionSignature(
new QName(REPORT, JmsModule.NAMESPACE_URI, JmsModule.PREFIX), "Get details of receiver",
new SequenceType[]{
new FunctionParameterSequenceType(ID, Type.INTEGER, Cardinality.EXACTLY_ONE, RECEIVER_ID),},
new FunctionReturnSequenceType(Type.NODE, Cardinality.ONE, "XML fragment with receiver information")
new FunctionReturnSequenceType(Type.NODE, Cardinality.EXACTLY_ONE, "XML fragment with receiver information")
),
new FunctionSignature(
new QName(CLEARREPORT, JmsModule.NAMESPACE_URI, JmsModule.PREFIX), "Clear report",
new SequenceType[]{
new FunctionParameterSequenceType(ID, Type.INTEGER, Cardinality.EXACTLY_ONE, RECEIVER_ID),},
new FunctionReturnSequenceType(Type.NODE, Cardinality.ONE, "Clear report of receiver")
new FunctionReturnSequenceType(Type.NODE, Cardinality.EXACTLY_ONE, "Clear report of receiver")
),};

public ManageReceivers(final XQueryContext context, final FunctionSignature signature) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.exist.jms.xquery.MessagingModule;
import org.exist.xquery.*;
import org.exist.xquery.functions.map.AbstractMapType;
import org.exist.xquery.functions.request.RequestModule;
import org.exist.xquery.value.*;

import static org.exist.jms.shared.ErrorCodes.JMS010;
Expand Down Expand Up @@ -87,9 +86,10 @@ public Sequence eval(final Sequence[] args, final Sequence contextSequence) thro
final JmsConfiguration config = new JmsConfiguration();
config.loadConfiguration(configMap);

// Remove Request module from expression and xquery context
this.getContext().setModule(RequestModule.NAMESPACE_URI, null);
context.setModule(RequestModule.NAMESPACE_URI, null);
// TODO why was this needed and why did we want to remove it.
// // Remove Request module from expression and xquery context
// this.getContext().setModule(RequestModule.NAMESPACE_URI, null);
// context.setModule(RequestModule.NAMESPACE_URI, null);

// Setup listener, pass correct User object
// get user via Broker for compatibility < existdb 2.2
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/exist/jms/xquery/messaging/SendMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ public class SendMessage extends BasicFunction {
new QName("send", MessagingModule.NAMESPACE_URI, MessagingModule.PREFIX),
"Send JMS message",
new SequenceType[]{
new FunctionParameterSequenceType("content", Type.ITEM, Cardinality.ONE, "Send message to remote server"),
new FunctionParameterSequenceType("content", Type.ITEM, Cardinality.EXACTLY_ONE, "Send message to remote server"),
new FunctionParameterSequenceType("jmsMessageProperties", Type.MAP, Cardinality.ZERO_OR_ONE, "Application-defined property values"),
new FunctionParameterSequenceType("jmsConfiguration", Type.MAP, Cardinality.ONE, "JMS configuration settings")
new FunctionParameterSequenceType("jmsConfiguration", Type.MAP, Cardinality.EXACTLY_ONE, "JMS configuration settings")
},
new FunctionReturnSequenceType(Type.NODE, Cardinality.ONE, "Confirmation message")
new FunctionReturnSequenceType(Type.NODE, Cardinality.EXACTLY_ONE, "Confirmation message")
),

};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class ReplicationSwitch extends BasicFunction {
new QName("enable-trigger", ReplicationModule.NAMESPACE_URI, ReplicationModule.PREFIX),
"Globally switch on/off the replication trigger", new SequenceType[]{
new FunctionParameterSequenceType("newStatus", Type.BOOLEAN, Cardinality.EXACTLY_ONE, "Value true() enables replication."),},
new FunctionReturnSequenceType(Type.EMPTY, Cardinality.ZERO, "")
new FunctionReturnSequenceType(Type.EMPTY, Cardinality.EMPTY_SEQUENCE, "")
),};

public ReplicationSwitch(final XQueryContext context, final FunctionSignature signature) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ public class SyncResource extends BasicFunction {
new QName("sync", ReplicationModule.NAMESPACE_URI, ReplicationModule.PREFIX),
"Synchronize resource", new SequenceType[]{
new FunctionParameterSequenceType("path", Type.STRING, Cardinality.EXACTLY_ONE, "Path to resource"),},
new FunctionReturnSequenceType(Type.EMPTY, Cardinality.EMPTY, "No return value")
new FunctionReturnSequenceType(Type.EMPTY, Cardinality.EMPTY_SEQUENCE, "No return value")
),
new FunctionSignature(
new QName("sync-metadata", ReplicationModule.NAMESPACE_URI, ReplicationModule.PREFIX),
"Synchronize meta data of resource", new SequenceType[]{
new FunctionParameterSequenceType("path", Type.STRING, Cardinality.EXACTLY_ONE, "Path to resource"),},
new FunctionReturnSequenceType(Type.EMPTY, Cardinality.EMPTY, "No return value")
new FunctionReturnSequenceType(Type.EMPTY, Cardinality.EMPTY_SEQUENCE, "No return value")
),};

public SyncResource(final XQueryContext context, final FunctionSignature signature) {
Expand Down
3 changes: 2 additions & 1 deletion src/test/resources/activemq.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">

<broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="ActiveMQData" useShutdownHook="false">
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost"
useJmx="false" persistent="false" dataDirectory="ActiveMQData" useShutdownHook="false">
<persistenceAdapter>
<kahaDB directory="ActiveMQData/kahadb"/>
</persistenceAdapter>
Expand Down