Browse Source

[jasperserver axis] 简化移动接口

sunyj 8 years ago
parent
commit
60925db0d4

+ 2 - 2
src/main/java/com/uas/report/axis/BasicResourceHandler.java

@@ -281,7 +281,7 @@ public class BasicResourceHandler implements ResourceHandler {
 	}
 
 	@Override
-	public void move(Request request) throws IOException, WSException {
+	public void move(ResourceDescriptor descriptor, String destinationURI) throws IOException {
 		// default implementation does nothing
 	}
 
@@ -298,7 +298,7 @@ public class BasicResourceHandler implements ResourceHandler {
 		return null;
 	}
 
-	protected String getDestinationURI(Request request) throws WSException {
+	public String getDestinationURI(Request request) throws WSException {
 		String destinationURI = request.getArgumentValue(Argument.DESTINATION_URI);
 		if (destinationURI == null) {
 			throw new WSException(WSException.GENERAL_REQUEST_ERROR, "未传递参数DESTINATION_URI");

+ 2 - 9
src/main/java/com/uas/report/axis/FileResourceHandler.java

@@ -39,9 +39,6 @@ public class FileResourceHandler extends BasicResourceHandler {
 
 	@Override
 	public void delete(ResourceDescriptor descriptor) throws IOException {
-		if (descriptor == null) {
-			return;
-		}
 		File file = getFile(descriptor.getUriString());
 		if (file.isDirectory()) {
 			throw new IOException("资源为文件夹!");
@@ -50,15 +47,11 @@ public class FileResourceHandler extends BasicResourceHandler {
 	}
 
 	@Override
-	public void move(Request request) throws IOException, WSException {
-		if (request == null) {
-			return;
-		}
-		File file = getFile(request.getResourceDescriptor().getUriString());
+	public void move(ResourceDescriptor descriptor, String destinationURI) throws IOException {
+		File file = getFile(descriptor.getUriString());
 		if (file.isDirectory()) {
 			throw new IOException("资源为文件夹!");
 		}
-		String destinationURI = getDestinationURI(request);
 		FileUtils.move(file, new File(getFile(destinationURI), file.getName()));
 	}
 }

+ 2 - 9
src/main/java/com/uas/report/axis/FolderHandler.java

@@ -14,9 +14,6 @@ public class FolderHandler extends BasicResourceHandler {
 
 	@Override
 	public void delete(ResourceDescriptor descriptor) throws IOException {
-		if (descriptor == null) {
-			return;
-		}
 		File file = getFile(descriptor.getUriString());
 		if (!file.isDirectory()) {
 			throw new IOException("资源并非文件夹!");
@@ -25,15 +22,11 @@ public class FolderHandler extends BasicResourceHandler {
 	}
 
 	@Override
-	public void move(Request request) throws IOException, WSException {
-		if (request == null) {
-			return;
-		}
-		File file = getFile(request.getResourceDescriptor().getUriString());
+	public void move(ResourceDescriptor descriptor, String destinationURI) throws IOException {
+		File file = getFile(descriptor.getUriString());
 		if (!file.isDirectory()) {
 			throw new IOException("资源并非文件夹!");
 		}
-		String destinationURI = getDestinationURI(request);
 		FileUtils.move(file, new File(getFile(destinationURI), file.getName()));
 	}
 }

+ 1 - 1
src/main/java/com/uas/report/axis/ResourceHandler.java

@@ -14,7 +14,7 @@ public interface ResourceHandler {
 
 	public void delete(ResourceDescriptor descriptor) throws IOException;
 
-	public void move(Request request) throws IOException, WSException;
+	public void move(ResourceDescriptor descriptor, String destinationURI) throws IOException;
 
 	public ResourceDescriptor copy(Request request);
 

+ 1 - 1
src/main/java/com/uas/report/axis/repository/RepositoryManagementServiceImpl.java

@@ -459,7 +459,7 @@ public class RepositoryManagementServiceImpl implements RepositoryManagementServ
 			// getHandlerRegistry().getHandler(wsType);
 			// handler.move(request, this);
 			BasicResourceHandler handler = resourceHandlerRegistry.getHandler(wsType);
-			handler.move(request);
+			handler.move(resourceDescriptor, basicResourceHandler.getDestinationURI(request));
 			// if (or.getReturnCode() != 0) {
 			// addExceptionToAllAuditEvents(new Exception(or.getMessage()));
 			// }