deleted filestorage.ui bundle, and added filestorage UI in c.s.s.gwt.ui

This commit is contained in:
Fredrik Teschke
2015-01-23 19:33:39 +01:00
parent d7920ef0df
commit 7134f051a9
48 changed files with 497 additions and 461 deletions
+8 -7
View File
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<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.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="resources"/>
<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>
@@ -1,7 +1,12 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
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.8
org.eclipse.jdt.core.compiler.source=1.7
@@ -4,8 +4,9 @@ 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.dto,
com.sap.sse.filestorage.impl,
com.sap.sse.filestorage.testsupport
Import-Package: com.sap.sse.osgi,
@@ -1,4 +1,5 @@
source.. = src/
source.. = src/,\
resources/
output.. = bin/
bin.includes = META-INF/,\
.
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.4.0//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.4.0/distro-source/core/src/gwt-module.dtd">
<module>
<source path='dto'/>
</module>
@@ -10,22 +10,26 @@ import com.sap.sse.common.NoCorrespondingServiceRegisteredException;
*/
public interface FileStorageManagementService {
FileStorageService[] getAvailableFileStorageServices();
FileStorageService getFileStorageService(String name);
/**
* Sets the property of the service, and also stores the property value so that it can be restored
* after a server restart.
* @throws NoCorrespondingServiceRegisteredException service may have disappeared from registry in the meantime
* @throws IllegalArgumentException if the property with name {@code propertyName} doesn't exist for the service
* Sets the property of the service, and also stores the property value so that it can be restored after a server
* restart.
*
* @throws NoCorrespondingServiceRegisteredException
* service may have disappeared from registry in the meantime
* @throws IllegalArgumentException
* if the property with name {@code propertyName} doesn't exist for the service
*/
void setFileStorageServiceProperty(String serviceName, String propertyName, String propertyValue)
throws NoCorrespondingServiceRegisteredException, IllegalArgumentException;
/**
* @return may be {@code null} if no service has been selected so far.
* @throws NoCorrespondingServiceRegisteredException
* if no service has been selected so far.
*/
FileStorageService getActiveFileStorageService();
FileStorageService getActiveFileStorageService() throws NoCorrespondingServiceRegisteredException;
/**
* @throws InvalidPropertiesException
@@ -0,0 +1,33 @@
package com.sap.sse.filestorage.dto;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import com.sap.sse.filestorage.FileStorageService;
import com.sap.sse.filestorage.Property;
public class FileStorageServiceDTO implements Serializable {
private static final long serialVersionUID = 6101940297792100418L;
public String name;
public String description;
public PropertyDTO[] properties;
// for GWT
FileStorageServiceDTO() {
}
public FileStorageServiceDTO(String name, String description, PropertyDTO... properties) {
this.name = name;
this.description = description;
this.properties = properties;
}
public static FileStorageServiceDTO convert(FileStorageService s) {
List<PropertyDTO> pDtos = new ArrayList<>();
for (Property p : s.getProperties()) {
pDtos.add(PropertyDTO.convert(p));
}
return new FileStorageServiceDTO(s.getName(), s.getDescription(), pDtos.toArray(new PropertyDTO[0]));
}
}
@@ -0,0 +1,28 @@
package com.sap.sse.filestorage.dto;
import java.io.Serializable;
import com.sap.sse.filestorage.Property;
public class PropertyDTO implements Serializable {
private static final long serialVersionUID = -2721807793068803143L;
public boolean isRequired;
public String name;
public String value;
public String description;
// for GWT
PropertyDTO() {
}
public PropertyDTO(boolean isRequired, String name, String value, String description) {
this.isRequired = isRequired;
this.name = name;
this.value = value;
this.description = description;
}
public static PropertyDTO convert(Property p) {
return new PropertyDTO(p.isRequired(), p.getName(), p.getValue(), p.getDescription());
}
}
@@ -0,0 +1,26 @@
package com.sap.sse.filestorage.dto;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import com.sap.sse.filestorage.InvalidPropertiesException;
import com.sap.sse.filestorage.Property;
public class PropertyErrors implements Serializable {
private static final long serialVersionUID = -7328897153875728802L;
public Map<PropertyDTO, String> perPropertyMessages = new HashMap<>();
public String message;
// for GWT
PropertyErrors() {
}
public PropertyErrors(InvalidPropertiesException e) {
message = e.getMessage();
for (Entry<Property, String> entry : e.getPerPropertyMessage().entrySet()) {
this.perPropertyMessages.put(PropertyDTO.convert(entry.getKey()), entry.getValue());
}
}
}
@@ -92,7 +92,8 @@ public class AmazonS3FileStorageServiceImpl implements FileStorageService {
private URI getUri(String key) {
try {
// FIXME: region is missing s3-... see: http://stackoverflow.com/questions/10975475/amazon-s3-upload-file-and-get-url
// FIXME: region is missing s3-... see:
// http://stackoverflow.com/questions/10975475/amazon-s3-upload-file-and-get-url
return new URI(retrievalProtocol, baseUrl, "/" + bucketName.getValue() + "/" + key, null);
} catch (URISyntaxException e) {
logger.log(Level.WARNING, "Could not create URI for uploaded file with key " + key, e);
@@ -130,6 +131,7 @@ public class AmazonS3FileStorageServiceImpl implements FileStorageService {
}
logger.info("Removed file " + uri);
}
@Override
public Property[] getProperties() {
return new Property[] { accessId, accessKey, bucketName };
@@ -163,12 +165,13 @@ 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,
throw new InvalidPropertiesException("invalid bucket", new Pair<Property, String>(bucketName,
"bucket does not exist"));
}
}
@@ -21,6 +21,9 @@ public class TransientFileStorageManagementServiceImpl implements FileStorageMan
@Override
public FileStorageService getActiveFileStorageService() {
if (active == null) {
throw new NoCorrespondingServiceRegisteredException();
}
return active;
}