Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*/
package org.bitrepository.alarm;

import jakarta.jms.JMSException;
import org.bitrepository.alarm.handling.AlarmHandler;
import org.bitrepository.alarm.handling.AlarmMediator;
import org.bitrepository.alarm.store.AlarmStore;
Expand All @@ -35,7 +36,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.jms.JMSException;
import java.time.Instant;
import java.util.Collection;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*/
package org.bitrepository.audittrails;

import jakarta.jms.JMSException;
import org.bitrepository.audittrails.collector.AuditTrailCollector;
import org.bitrepository.audittrails.preserver.AuditTrailPreserver;
import org.bitrepository.audittrails.store.AuditEventIterator;
Expand All @@ -40,11 +41,10 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.jms.JMSException;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.time.Instant;

/**
* Class to expose the functionality of the AuditTrailService.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.Duration;
import java.io.FileInputStream;
import java.net.URI;
import java.net.URL;
import java.time.Instant;

Expand Down Expand Up @@ -74,7 +75,7 @@ void setup() throws Exception {
settings.getRepositorySettings().getCollections().getCollection().add(c);

collectionID = c.getID();
testUploadUrl = new URL("http://TestURL.com");
testUploadUrl = new URI("http://TestURL.com").toURL();
threadFactory = new DefaultThreadFactory(this.getClass().getSimpleName(), Thread.NORM_PRIORITY, false);

}
Expand Down Expand Up @@ -121,8 +122,8 @@ public AuditEventIterator answer(InvocationOnMock invocation) {
}
}).when(store).getAuditTrailsByIterator(ArgumentMatchers.any(), ArgumentMatchers.anyString(),
ArgumentMatchers.anyString(), ArgumentMatchers.any(Long.class), ArgumentMatchers.any(),
ArgumentMatchers.any(), ArgumentMatchers.any(), ArgumentMatchers.any(Instant.class),
ArgumentMatchers.any(Instant.class),
ArgumentMatchers.any(), ArgumentMatchers.any(), ArgumentMatchers.isNull(Instant.class),
ArgumentMatchers.isNull(Instant.class),
ArgumentMatchers.any(), ArgumentMatchers.any());

preserver.start();
Expand Down
2 changes: 1 addition & 1 deletion bitrepository-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ The below code is a full example of the various parts above. The code will compi
import java.net.MalformedURLException;
import java.net.URL;

import javax.jms.JMSException;
import jakarta.jms.JMSException;

import org.bitrepository.bitrepositoryelements.ChecksumDataForFileTYPE;
import org.bitrepository.bitrepositoryelements.ChecksumSpecTYPE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

package org.bitrepository.commandline;

import jakarta.jms.JMSException;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.ParseException;
import org.apache.commons.codec.DecoderException;
Expand All @@ -45,9 +46,9 @@
import org.bitrepository.protocol.security.SecurityManager;
import org.bitrepository.settings.referencesettings.ProtocolType;

import javax.jms.JMSException;
import java.io.File;
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URL;
import java.security.NoSuchAlgorithmException;
import java.time.Duration;
Expand Down Expand Up @@ -325,8 +326,7 @@ protected void deleteFileAfterwards(URL url) {
fileexchange.deleteFile(url);
} catch (Exception e) {
output.error("Issue regarding removing file from server: " + e.getMessage());
}
}
} }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, lines inadvertently joined.


/**
* Retrieves the URL for the PutFile operation.
Expand All @@ -344,12 +344,10 @@ protected URL getURLOrUploadFile() {
String urlArg = cmdHandler.getOptionValue(Constants.URL_ARG);

try {
final URL url = new URL(urlArg);
final URL url = new URI(urlArg).toURL();

ProtocolType protocolType = ProtocolType.fromValue(url.getProtocol().toUpperCase(Locale.ROOT));
if (protocolType != ProtocolType.FILE) {
// Test if URL can actually be opened to exit early
// - otherwise checksum pillars will still receive and store checksum.
Comment on lines -351 to -352
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn’t the comment fine and helpful?

HttpURLConnection connection = (HttpURLConnection) url.openConnection();
int responseCode = connection.getResponseCode();

Expand Down
6 changes: 3 additions & 3 deletions bitrepository-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk18on</artifactId>
<version>1.83</version>
<version>1.84</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcmail-jdk18on</artifactId>
<version>1.83</version>
<version>1.84</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
Expand All @@ -74,7 +74,7 @@
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>11.0.24</version>
<version>12.1.8</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;

Expand Down Expand Up @@ -84,8 +85,8 @@ public void getFile(OutputStream out, URL url) throws IOException {
public void getFile(File outputFile, String fileAddress) {
URL url;
try {
url = new URL(fileAddress);
} catch (MalformedURLException e) {
url = new URI(fileAddress).toURL();
} catch (MalformedURLException | URISyntaxException e) {
throw new IllegalStateException("Cannot create the URL.", e);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@
*/
package org.bitrepository.protocol.activemq;

import jakarta.jms.Connection;
import jakarta.jms.DeliveryMode;
import jakarta.jms.Destination;
import jakarta.jms.ExceptionListener;
import jakarta.jms.JMSException;
import jakarta.jms.MessageConsumer;
import jakarta.jms.MessageProducer;
import jakarta.jms.Session;
import jakarta.jms.TextMessage;
import jakarta.jms.Topic;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.util.ByteArrayInputStream;
import org.bitrepository.bitrepositorymessages.Message;
Expand Down Expand Up @@ -56,16 +66,6 @@
import org.slf4j.LoggerFactory;
import org.xml.sax.SAXException;

import javax.jms.Connection;
import javax.jms.DeliveryMode;
import javax.jms.Destination;
import javax.jms.ExceptionListener;
import javax.jms.JMSException;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.jms.Topic;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.HashMap;
Expand Down Expand Up @@ -416,7 +416,7 @@ public void onException(JMSException arg0) {
* <p>
* This adapts from general Active MQ messages to the types.
*/
private class ActiveMQMessageListener implements javax.jms.MessageListener {
private class ActiveMQMessageListener implements jakarta.jms.MessageListener {
/**
* The Log.
*/
Expand Down Expand Up @@ -445,7 +445,7 @@ public ActiveMQMessageListener(MessageListener listener) {
* @param jmsMessage The message received.
*/
@Override
public void onMessage(final javax.jms.Message jmsMessage) {
public void onMessage(final jakarta.jms.Message jmsMessage) {
String type = null;
String text = null;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,9 @@
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;

public class HttpFileExchange implements FileExchange {
private final Logger log = LoggerFactory.getLogger(getClass());
Expand Down Expand Up @@ -99,7 +98,7 @@ public URL putFile(File dataFile) {
throw new CoordinationLayerException("Could not upload the file '" + dataFile.getAbsolutePath() +
"' to the server.", e);
}
}
}

@Override
public void getFile(OutputStream out, URL url) throws IOException {
Expand All @@ -110,12 +109,12 @@ public void getFile(OutputStream out, URL url) throws IOException {
public void getFile(File outputFile, String fileAddress) {
try {
// retrieve the url and the output-stream for the file.
URL url = new URL(fileAddress);
URL url = new URI(fileAddress).toURL();
try (OutputStream out = new BufferedOutputStream(new FileOutputStream(outputFile))) {
// download the file.
performDownload(out, url);
}
} catch (IOException e) {
} catch (IOException | URISyntaxException e) {
throw new CoordinationLayerException("Could not download data from '" + fileAddress + "' to the file '" +
outputFile.getAbsolutePath() + "'.", e);
}
Expand Down Expand Up @@ -190,11 +189,25 @@ public URL getURL(String filename) throws MalformedURLException {
ArgumentValidator.checkNotNullOrEmpty(filename, "String fileName");
ArgumentValidator.checkNotNull(settings,
"The ReferenceSettings are missing the settings for the file exchange.");
String urlEncodedFilename = URLEncoder.encode(filename, StandardCharsets.UTF_8);
log.debug("URL for file '{}' encoded to '{}'", filename, urlEncodedFilename);

return new URL(settings.getProtocolType().value(), settings.getServerName(), settings.getPort().intValue(),
settings.getPath() + "/" + urlEncodedFilename);
String path = settings.getPath() == null ? "" : settings.getPath();
if (!path.startsWith("/")) {
path = "/" + path;
}
if (!path.endsWith("/")) {
path += "/";
}

try {
URI baseURI = new URI(settings.getProtocolType().value(), null, settings.getServerName(),
settings.getPort().intValue(), path, null, null);
String encodedFilename = new URI(null, null, null, -1, "/" + filename, null, null)
.getRawPath().substring(1).replace("+", "%2B");

return new URI(baseURI.toASCIIString() + encodedFilename).toURL();
} catch (URISyntaxException e) {
throw new MalformedURLException(e.getMessage());
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
package org.bitrepository.protocol.messagebus;

import javax.jms.JMSException;
import jakarta.jms.JMSException;
import java.util.List;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
*/
package org.bitrepository.protocol.messagebus;

import jakarta.jms.JMSException;
import org.bitrepository.common.settings.Settings;
import org.bitrepository.protocol.activemq.ActiveMQMessageBus;
import org.bitrepository.protocol.security.SecurityManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.jms.JMSException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
*/
package org.bitrepository.protocol.messagebus;

import jakarta.jms.JMSException;
import org.bitrepository.bitrepositorymessages.Message;
import org.bitrepository.protocol.MessageContext;

import javax.jms.JMSException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.core.util.StatusPrinter;
import jakarta.jms.JMSException;
import org.bitrepository.SuiteInfo;
import org.bitrepository.SuiteInfoParameterResolver;
import org.bitrepository.common.settings.Settings;
Expand All @@ -42,12 +43,16 @@
import org.bitrepository.protocol.security.DummySecurityManager;
import org.bitrepository.protocol.security.SecurityManager;
import org.bitrepository.protocol.utils.TestWatcherExtension;
import org.junit.jupiter.api.*;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.slf4j.LoggerFactory;

import javax.jms.JMSException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
Expand Down Expand Up @@ -94,7 +99,7 @@ public void initializeSuite(SuiteInfo testInfo) {
defaultDownloadFileAddress = defaultFileUrl.toExternalForm();
defaultUploadFileAddress = defaultFileUrl.toExternalForm() + "-" + defaultFileId;
} catch (MalformedURLException e) {
throw new RuntimeException("Never happens");
throw new RuntimeException("Failed to construct default file URLs for test setup", e);
}
initMessagebus();
}
Expand Down
Loading