mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-25 06:58:39 +00:00
Revert "introduce new filestorage.common bundle, so that filestorage bundle can be upgraded to java 1.8"
This reverts commit 02972d1bea.
Conflicts:
java/com.sap.sse.filestorage/src/com/sap/sse/filestorage/impl/ReplicableFileStorageManagementService.java
This commit is contained in:
@@ -2,6 +2,6 @@
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
||||
Regular → Executable
+12
-12
@@ -1,12 +1,12 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
||||
|
||||
@@ -4,7 +4,7 @@ Bundle-Name: Sse File storage
|
||||
Bundle-SymbolicName: com.sap.sse.filestorage
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-Vendor: SAP
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||
Export-Package: com.sap.sse.filestorage,
|
||||
com.sap.sse.filestorage.impl,
|
||||
com.sap.sse.filestorage.testsupport
|
||||
@@ -19,6 +19,4 @@ Require-Bundle: org.apache.servicemix.bundles.aws-java-sdk;bundle-version="1.9.8
|
||||
org.apache.commons.logging;bundle-version="1.1.3",
|
||||
com.sap.sse.common,
|
||||
com.sap.sse.mongodb;bundle-version="1.0.0",
|
||||
com.mongodb.driver;bundle-version="2.6.2",
|
||||
com.sap.sse.replication;bundle-version="1.0.0",
|
||||
com.sap.sse.filestorage.common;bundle-version="1.0.0"
|
||||
com.mongodb.driver;bundle-version="2.6.2"
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.sap.sse.filestorage.common;
|
||||
package com.sap.sse.filestorage;
|
||||
|
||||
import com.sap.sse.common.NoCorrespondingServiceRegisteredException;
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.sap.sse.filestorage;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
|
||||
import com.sap.sse.common.TypeBasedServiceFinder;
|
||||
|
||||
/**
|
||||
* Service for storing files. The interface is intentionally agnostic of the underlying implementation, which may be
|
||||
* provided e.g. by using Amazon's S3 or simply saving the files to a statically reachable directory on one of our
|
||||
* servers. Implementations of this service are announced via the OSGi service registry. They should provide their name
|
||||
* as the OSGi property {@link TypeBasedServiceFinder#TYPE type};
|
||||
*
|
||||
* TODO The storage service to use should be configured via the AdminConsole. Upon auto-discovering the available
|
||||
* services, the AdminConsole should allow to edit properties for each service (e.g. access credentials for AWS S3). We
|
||||
* probably need a generic property discovery mechanism (key-value based?), and to survive server restarts these
|
||||
* properties should be saved to the MongoDB.
|
||||
*
|
||||
* @author Fredrik Teschke
|
||||
*
|
||||
*/
|
||||
public interface FileStorageService {
|
||||
/**
|
||||
* @param originalFileExtension
|
||||
* may be {@code null}
|
||||
*/
|
||||
URI storeFile(InputStream is, String fileExtension, long lengthInBytes) throws IOException,
|
||||
OperationFailedException, InvalidPropertiesException;
|
||||
|
||||
/**
|
||||
* From the given {@code uri} it should be possible to determine the file to remove.
|
||||
*/
|
||||
void removeFile(URI uri) throws OperationFailedException, InvalidPropertiesException;
|
||||
|
||||
Property[] getProperties();
|
||||
|
||||
/**
|
||||
* Should not be called directly, but through {@link FileStorageManagementService#setFileStorageServiceProperty}
|
||||
* as this deals with storing the new values.
|
||||
* @throws IllegalArgumentException
|
||||
* if {@code name} is not a valid property name
|
||||
*/
|
||||
void internalSetProperty(String name, String value) throws IllegalArgumentException;
|
||||
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Description text that explains the storage service.
|
||||
*/
|
||||
String getDescription();
|
||||
|
||||
/**
|
||||
* Test whether properties are valid, e.g. by trying to log in using access credentials provided as properties.
|
||||
*/
|
||||
void testProperties() throws InvalidPropertiesException;
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package com.sap.sse.filestorage;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.sap.sse.common.Util.Pair;
|
||||
|
||||
public class InvalidPropertiesException extends Exception {
|
||||
private static final long serialVersionUID = -7328897153875728802L;
|
||||
private final Map<Property, String> perPropertyMessages = new HashMap<>();
|
||||
|
||||
public InvalidPropertiesException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public InvalidPropertiesException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
public InvalidPropertiesException(String message,
|
||||
Pair<Property, String>... perPropertyMessages) {
|
||||
this(message, null, perPropertyMessages);
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
public InvalidPropertiesException(String message, Throwable cause,
|
||||
Pair<Property, String>... perPropertyMessages) {
|
||||
super(message, cause);
|
||||
for (Pair<Property, String> pair : perPropertyMessages) {
|
||||
this.perPropertyMessages.put(pair.getA(), pair.getB());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Returns the overall error message (always exists).
|
||||
*/
|
||||
public String getMessage() {
|
||||
return super.getMessage();
|
||||
}
|
||||
|
||||
public Map<Property, String> getPerPropertyMessage() {
|
||||
return perPropertyMessages;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.sap.sse.filestorage;
|
||||
|
||||
public class OperationFailedException extends Exception {
|
||||
private static final long serialVersionUID = 3361800673687196602L;
|
||||
|
||||
public OperationFailedException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.sap.sse.filestorage;
|
||||
|
||||
/**
|
||||
* Property of a file storage service.
|
||||
* @author Fredrik Teschke
|
||||
*
|
||||
*/
|
||||
public interface Property {
|
||||
boolean isRequired();
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* @return {@code null} if not yet initialized
|
||||
*/
|
||||
String getValue();
|
||||
String getDescription();
|
||||
}
|
||||
@@ -8,9 +8,9 @@ import org.osgi.framework.BundleContext;
|
||||
import org.osgi.util.tracker.ServiceTracker;
|
||||
|
||||
import com.sap.sse.common.TypeBasedServiceFinder;
|
||||
import com.sap.sse.filestorage.FileStorageManagementService;
|
||||
import com.sap.sse.filestorage.FileStorageService;
|
||||
import com.sap.sse.filestorage.FileStorageServicePropertyStore;
|
||||
import com.sap.sse.filestorage.common.FileStorageManagementService;
|
||||
import com.sap.sse.filestorage.common.FileStorageService;
|
||||
import com.sap.sse.mongodb.MongoDBConfiguration;
|
||||
|
||||
public class Activator implements BundleActivator {
|
||||
|
||||
+25
-23
@@ -19,10 +19,10 @@ import com.amazonaws.services.s3.model.DeleteObjectRequest;
|
||||
import com.amazonaws.services.s3.model.ObjectMetadata;
|
||||
import com.amazonaws.services.s3.model.PutObjectRequest;
|
||||
import com.sap.sse.common.Util.Pair;
|
||||
import com.sap.sse.filestorage.common.FileStorageService;
|
||||
import com.sap.sse.filestorage.common.FileStorageServiceProperty;
|
||||
import com.sap.sse.filestorage.common.InvalidPropertiesException;
|
||||
import com.sap.sse.filestorage.common.OperationFailedException;
|
||||
import com.sap.sse.filestorage.FileStorageService;
|
||||
import com.sap.sse.filestorage.InvalidPropertiesException;
|
||||
import com.sap.sse.filestorage.OperationFailedException;
|
||||
import com.sap.sse.filestorage.Property;
|
||||
|
||||
/**
|
||||
* For testing purposes configure the access credentials as follows: To link this service to an AWS account, create the
|
||||
@@ -42,20 +42,20 @@ public class AmazonS3FileStorageServiceImpl implements FileStorageService {
|
||||
private static final String retrievalProtocol = "http";
|
||||
// private static final String bucketName = "ftes-sap-sailing";
|
||||
|
||||
private final FileStorageServicePropertyImpl accessId = new FileStorageServicePropertyImpl("accessId", false,
|
||||
private final PropertyImpl accessId = new PropertyImpl("accessId", false,
|
||||
"Access ID (leave blank to use ~/.aws/credentials instead)");
|
||||
private final FileStorageServicePropertyImpl accessKey = new FileStorageServicePropertyImpl("accessKey", false,
|
||||
private final PropertyImpl accessKey = new PropertyImpl("accessKey", false,
|
||||
"Secret Access Key (leave blank to use ~/.aws/credentials instead)");
|
||||
private final FileStorageServicePropertyImpl bucketName = new FileStorageServicePropertyImpl("bucketName", true,
|
||||
private final PropertyImpl bucketName = new PropertyImpl("bucketName", true,
|
||||
"Name of Bucket to use (has to already exist, and user needs sufficient permissions)");
|
||||
private final Map<String, FileStorageServicePropertyImpl> properties = new HashMap<>();
|
||||
private final Map<String, PropertyImpl> properties = new HashMap<>();
|
||||
|
||||
public AmazonS3FileStorageServiceImpl() {
|
||||
addProperties(accessId, accessKey, bucketName);
|
||||
}
|
||||
|
||||
private void addProperties(FileStorageServicePropertyImpl... properties) {
|
||||
for (FileStorageServicePropertyImpl p : properties) {
|
||||
private void addProperties(PropertyImpl... properties) {
|
||||
for (PropertyImpl p : properties) {
|
||||
this.properties.put(p.getName(), p);
|
||||
}
|
||||
}
|
||||
@@ -107,15 +107,15 @@ public class AmazonS3FileStorageServiceImpl implements FileStorageService {
|
||||
.withCannedAcl(CannedAccessControlList.PublicRead);
|
||||
final AmazonS3Client s3Client = createS3Client();
|
||||
|
||||
new Thread() {
|
||||
public void run() {
|
||||
try {
|
||||
s3Client.putObject(request);
|
||||
} catch (AmazonClientException e) {
|
||||
logger.log(Level.WARNING, "Could not store file", e);
|
||||
}
|
||||
};
|
||||
}.run();
|
||||
new Thread() {
|
||||
public void run() {
|
||||
try {
|
||||
s3Client.putObject(request);
|
||||
} catch (AmazonClientException e) {
|
||||
logger.log(Level.WARNING, "Could not store file", e);
|
||||
}
|
||||
};
|
||||
}.run();
|
||||
URI uri = getUri(key);
|
||||
logger.info("Stored file " + uri);
|
||||
return uri;
|
||||
@@ -134,8 +134,8 @@ public class AmazonS3FileStorageServiceImpl implements FileStorageService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileStorageServiceProperty[] getProperties() {
|
||||
return new FileStorageServiceProperty[] { accessId, accessKey, bucketName };
|
||||
public Property[] getProperties() {
|
||||
return new Property[] { accessId, accessKey, bucketName };
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -166,12 +166,14 @@ public class AmazonS3FileStorageServiceImpl implements FileStorageService {
|
||||
s3.doesBucketExist(bucketName.getValue());
|
||||
} catch (Exception e) {
|
||||
throw new InvalidPropertiesException("invalid credentials or not enough access rights for the bucket", e,
|
||||
new Pair<>(accessId, "seems to be invalid"), new Pair<>(accessKey, "seems to be invalid"));
|
||||
new Pair<Property, String>(accessId, "seems to be invalid"), new Pair<Property, String>(accessKey,
|
||||
"seems to be invalid"));
|
||||
}
|
||||
|
||||
// test if bucket exists
|
||||
if (!s3.doesBucketExist(bucketName.getValue())) {
|
||||
throw new InvalidPropertiesException("invalid bucket", new Pair<>(bucketName, "bucket does not exist"));
|
||||
throw new InvalidPropertiesException("invalid bucket", new Pair<Property, String>(bucketName,
|
||||
"bucket does not exist"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -11,9 +11,9 @@ import org.osgi.util.tracker.ServiceTrackerCustomizer;
|
||||
|
||||
import com.sap.sse.common.NoCorrespondingServiceRegisteredException;
|
||||
import com.sap.sse.common.TypeBasedServiceFinder;
|
||||
import com.sap.sse.filestorage.FileStorageManagementService;
|
||||
import com.sap.sse.filestorage.FileStorageService;
|
||||
import com.sap.sse.filestorage.FileStorageServicePropertyStore;
|
||||
import com.sap.sse.filestorage.common.FileStorageManagementService;
|
||||
import com.sap.sse.filestorage.common.FileStorageService;
|
||||
import com.sap.sse.osgi.CachedOsgiTypeBasedServiceFinderFactory;
|
||||
|
||||
/**
|
||||
|
||||
+4
-4
@@ -11,9 +11,9 @@ import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.sap.sse.filestorage.common.FileStorageService;
|
||||
import com.sap.sse.filestorage.common.FileStorageServiceProperty;
|
||||
import com.sap.sse.filestorage.common.InvalidPropertiesException;
|
||||
import com.sap.sse.filestorage.FileStorageService;
|
||||
import com.sap.sse.filestorage.InvalidPropertiesException;
|
||||
import com.sap.sse.filestorage.Property;
|
||||
|
||||
public class LocalFileStorageServiceImpl implements FileStorageService {
|
||||
private static final Logger logger = Logger.getLogger(LocalFileStorageServiceImpl.class.getName());
|
||||
@@ -76,7 +76,7 @@ public class LocalFileStorageServiceImpl implements FileStorageService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileStorageServiceProperty[] getProperties() {
|
||||
public Property[] getProperties() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
+4
-5
@@ -1,19 +1,18 @@
|
||||
package com.sap.sse.filestorage.impl;
|
||||
|
||||
import com.sap.sse.filestorage.common.FileStorageServiceProperty;
|
||||
import com.sap.sse.filestorage.Property;
|
||||
|
||||
|
||||
public class FileStorageServicePropertyImpl implements FileStorageServiceProperty {
|
||||
public class PropertyImpl implements Property {
|
||||
private final boolean isRequired;
|
||||
private final String name;
|
||||
private final String description;
|
||||
private String value;
|
||||
|
||||
public FileStorageServicePropertyImpl(String name, boolean isRequired, String description) {
|
||||
public PropertyImpl(String name, boolean isRequired, String description) {
|
||||
this(name, isRequired, description, null);
|
||||
}
|
||||
|
||||
public FileStorageServicePropertyImpl(String name, boolean isRequired, String description, String value) {
|
||||
public PropertyImpl(String name, boolean isRequired, String description, String value) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.value = value;
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package com.sap.sse.filestorage.testsupport;
|
||||
|
||||
import com.sap.sse.filestorage.common.InvalidPropertiesException;
|
||||
import com.sap.sse.filestorage.InvalidPropertiesException;
|
||||
import com.sap.sse.filestorage.impl.AmazonS3FileStorageServiceImpl;
|
||||
|
||||
public class AmazonS3TestSupport {
|
||||
|
||||
Reference in New Issue
Block a user