dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #40529
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20568: Undo wrongful commit
------------------------------------------------------------
revno: 20568
committer: Halvdan Hoem Grelland <halvdanhg@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-10-07 15:46:41 +0200
message:
Undo wrongful commit
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/fileresource/FileResourceContentStore.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/fileresource/DefaultFileResourceService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/fileresource/JCloudsFileResourceContentStore.java
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/SpringScheduler.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/FileResourceController.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/fileresource/FileResourceContentStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/fileresource/FileResourceContentStore.java 2015-10-07 13:43:35 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/fileresource/FileResourceContentStore.java 2015-10-07 13:46:41 +0000
@@ -30,7 +30,6 @@
import com.google.common.io.ByteSource;
-import java.io.IOException;
import java.net.URI;
/**
@@ -55,8 +54,6 @@
*/
String saveFileResourceContent( String key, ByteSource content, long size, String contentMd5 );
- String saveFileResourceContent2( String key, ByteSource content, long size, String contentMd5 ) throws IOException;
-
/**
* Delete the content bytes of a file resource.
* @param key the key.
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/fileresource/DefaultFileResourceService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/fileresource/DefaultFileResourceService.java 2015-10-07 13:43:35 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/fileresource/DefaultFileResourceService.java 2015-10-07 13:46:41 +0000
@@ -36,7 +36,6 @@
import com.google.common.io.ByteSource;
-import java.io.IOException;
import java.net.URI;
import java.util.List;
@@ -88,22 +87,8 @@
{
String storageKey = getRelativeStorageKey( fileResource );
-// String key = fileResourceContentStore.saveFileResourceContent(
-// storageKey, content, fileResource.getContentLength(), fileResource.getContentMd5() );
-
- //
- String key = null;
-
- try
- {
- key = fileResourceContentStore.saveFileResourceContent2(
- storageKey, content, fileResource.getContentLength(), fileResource.getContentMd5() );
- }
- catch ( IOException e )
- {
- e.printStackTrace();
- }
- //
+ String key = fileResourceContentStore.saveFileResourceContent(
+ storageKey, content, fileResource.getContentLength(), fileResource.getContentMd5() );
if ( key == null )
{
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/fileresource/JCloudsFileResourceContentStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/fileresource/JCloudsFileResourceContentStore.java 2015-10-07 13:43:35 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/fileresource/JCloudsFileResourceContentStore.java 2015-10-07 13:46:41 +0000
@@ -29,17 +29,13 @@
*/
import com.google.common.hash.HashCode;
-import com.google.common.io.ByteSink;
import com.google.common.io.ByteSource;
-import com.google.common.io.FileWriteMode;
-import org.apache.commons.io.IOUtils;
import org.apache.commons.io.input.NullInputStream;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.external.location.LocationManager;
import org.hisp.dhis.hibernate.HibernateConfigurationProvider;
-import org.hisp.dhis.system.scheduling.Scheduler;
import org.jclouds.ContextBuilder;
import org.jclouds.blobstore.BlobRequestSigner;
import org.jclouds.blobstore.BlobStore;
@@ -52,22 +48,16 @@
import org.jclouds.filesystem.reference.FilesystemConstants;
import org.jclouds.http.HttpRequest;
import org.joda.time.Minutes;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.util.concurrent.ListenableFuture;
-import org.springframework.util.concurrent.ListenableFutureCallback;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
-import java.nio.file.Files;
-import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Properties;
-import java.util.concurrent.Callable;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@@ -138,9 +128,6 @@
this.configurationProvider = configurationProvider;
}
- @Autowired
- private Scheduler scheduler;
-
// -------------------------------------------------------------------------
// Life cycle management
// -------------------------------------------------------------------------
@@ -279,49 +266,6 @@
}
@Override
- public String saveFileResourceContent2( String key, ByteSource content, long size, String contentMd5 ) throws IOException
- {
- Path tempDir = Files.createTempDirectory( null );
- Path tmpFile = Files.createTempFile( tempDir, null, null );
-
- ByteSink byteSink = com.google.common.io.Files.asByteSink( tmpFile.toFile(), FileWriteMode.APPEND );
- IOUtils.copy( content.openStream(), byteSink.openStream() );
-
- ListenableFuture<String> uploadResult = scheduler.executeTask( () -> {
- Blob blob = blobStore.blobBuilder( key )
- .payload( tmpFile.toFile() )
- .contentLength( size )
- .build();
-
- return putBlob( blob );
- } );
-
- uploadResult.addCallback( new ListenableFutureCallback<String>()
- {
- @Override
- public void onFailure( Throwable ex )
- {
- log.error( ex );
- }
-
- @Override
- public void onSuccess( String result )
- {
- if ( result != null )
- {
- log.info( "File uploaded: " + result );
- }
- else
- {
- log.info( "Upload failed" );
- }
- }
- } );
-
- return key;
- }
-
- @Override
public void deleteFileResourceContent( String key )
{
deleteBlob( key );
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/SpringScheduler.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/SpringScheduler.java 2015-10-07 13:43:35 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/SpringScheduler.java 2015-10-07 13:46:41 +0000
@@ -109,8 +109,8 @@
if ( key != null )
{
ScheduledFuture<?> future = futures.get( key );
-
- boolean result = future != null && future.cancel( true );
+
+ boolean result = future != null ? future.cancel( true ) : false;
futures.remove( key );
@@ -133,7 +133,7 @@
ScheduledFuture<?> future = futures.get( key );
- boolean result = future != null && future.cancel( true );
+ boolean result = future != null ? future.cancel( true ) : false;
keys.remove();
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/FileResourceController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/FileResourceController.java 2015-10-07 13:43:35 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/FileResourceController.java 2015-10-07 13:46:41 +0000
@@ -31,7 +31,6 @@
import com.google.common.hash.Hashing;
import com.google.common.io.ByteSource;
import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.io.IOUtils;
import org.apache.commons.io.input.NullInputStream;
import org.apache.commons.lang3.StringUtils;
import org.hisp.dhis.dxf2.webmessage.WebMessage;