Преглед изворни кода

实现jasperserver axis资源列表list、get接口;
put接口雏形;

sunyj пре 8 година
родитељ
комит
414a63c480

+ 6 - 1
pom.xml

@@ -28,6 +28,7 @@
 		<barcode4j.version>2.1</barcode4j.version>
 		<batik.bridge.version>1.8</batik.bridge.version>
 		<xmlgraphics.version>2.1</xmlgraphics.version>
+		<mail.version>1.4.7</mail.version>
 	</properties>
 
 	<dependencies>
@@ -193,7 +194,11 @@
 			<artifactId>xmlgraphics-commons</artifactId>
 			<version>${xmlgraphics.version}</version>
 		</dependency>
-
+		<dependency>
+			<groupId>javax.mail</groupId>
+			<artifactId>mail</artifactId>
+			<version>${mail.version}</version>
+		</dependency>
 	</dependencies>
 
 	<build>

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

@@ -0,0 +1,249 @@
+package com.uas.report.axis;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.springframework.util.CollectionUtils;
+import org.springframework.util.StringUtils;
+
+import com.uas.report.SpecialProperties;
+import com.uas.report.util.ContextUtils;
+import com.uas.report.util.FileUtils;
+
+public class BasicResourceHandler implements ResourceHandler {
+
+	private SpecialProperties specialProperties = ContextUtils.getBean(SpecialProperties.class);
+
+	private FileFilter filter = new FileFilter() {
+		@Override
+		public boolean accept(File file) {
+			if (file == null || !file.exists()) {
+				return false;
+			}
+			// 不支持查看、压缩:jasper文件、tmp路径
+			String filePath = file.getPath();
+			if (filePath.endsWith(".jasper") || filePath.endsWith("tmp") || filePath.contains("\\tmp\\")
+					|| filePath.contains("/tmp/")) {
+				return false;
+			}
+			return true;
+		}
+	};
+
+	public List<Resource> listResource(String resourceURI) throws FileNotFoundException, IOException {
+		File dir = new File(specialProperties.getLocalBaseDir() + Folder.SEPARATOR + resourceURI);
+		if (!dir.exists() || !dir.isDirectory() || !filter.accept(dir)) {
+			return null;
+		}
+		List<Resource> resources = new ArrayList<>();
+		File[] files = dir.listFiles(filter);
+		for (File file : files) {
+			resources.add(locateResource(file));
+		}
+		return resources;
+	}
+
+	public Resource locateResource(String resourceURI) throws FileNotFoundException, IOException {
+		return locateResource(getFile(resourceURI));
+	}
+
+	private Resource locateResource(File file) throws FileNotFoundException, IOException {
+		if (file == null || !file.exists() || !filter.accept(file)) {
+			return null;
+		}
+		Resource resource = null;
+		if (file.isDirectory()) {
+			resource = new Folder();
+		} else {
+			resource = locateFileResource(file);
+		}
+		resource.setCreationDate(new Date(file.lastModified()));
+		resource.setUpdateDate(new Date(file.lastModified()));
+		resource.setVersion(Resource.DEFAULT_VERSION);
+		resource.setName(file.getName());
+		resource.setLabel(file.getName());
+		resource.setDescription(file.getName());
+		resource.setUri(getResourceURI(file));
+		return resource;
+	}
+
+	private FileResource locateFileResource(File file) throws FileNotFoundException, IOException {
+		FileResource fileResource = new FileResource();
+		String fileType = getFileType(file.getName());
+		if (StringUtils.isEmpty(fileType)) {
+			fileResource.setFileType(ResourceDescriptor.TYPE_UNKNOW);
+		} else {
+			if (fileType.equalsIgnoreCase(ResourceDescriptor.TYPE_JRXML)) {
+				fileResource.setFileType(ResourceDescriptor.TYPE_JRXML);
+			} else if (isImage(fileType)) {
+				fileResource.setFileType(ResourceDescriptor.TYPE_IMAGE);
+			} else {
+				fileResource.setFileType(ResourceDescriptor.TYPE_UNKNOW);
+			}
+		}
+		fileResource.readData(new FileInputStream(file));
+		return fileResource;
+	}
+
+	private boolean isImage(String fileType) {
+		return fileType.toLowerCase()
+				.matches("^(gif|jpg|jpeg|png|bmp|tiff|pcx|tga|exif|fpx|svg|psd|cdr|pcd|dxf|ufo|eps|ai|raw)$");
+	}
+
+	private File getFile(String resourceURI) {
+		return new File(specialProperties.getLocalBaseDir() + "/" + resourceURI);
+	}
+
+	private String getResourceURI(File file) {
+		String resourceURI = file.getPath();
+		resourceURI = resourceURI.replace(new File(specialProperties.getLocalBaseDir()).getPath(), "");
+		resourceURI = resourceURI.replace("\\", Folder.SEPARATOR);
+		if (!resourceURI.startsWith(Folder.SEPARATOR)) {
+			resourceURI = Folder.SEPARATOR + resourceURI;
+		}
+		return resourceURI;
+	}
+
+	private String getFileType(String fileName) {
+		int index = fileName.lastIndexOf(".");
+		if (index < 0) {
+			return null;
+		}
+		return fileName.substring(index + 1);
+	}
+
+	public ResourceDescriptor toResourceDescriptor(Resource resource) {
+		ResourceDescriptor resourceDescriptor = new ResourceDescriptor();
+		if (resource instanceof Folder) {
+			resourceDescriptor.setWsType(ResourceDescriptor.TYPE_FOLDER);
+			resourceDescriptor.setHasData(false);
+		} else if (resource instanceof FileResource) {
+			FileResource fileResource = (FileResource) resource;
+			resourceDescriptor.setWsType(fileResource.getFileType());
+			resourceDescriptor.setHasData(fileResource.hasData());
+		}
+		resourceDescriptor.setUriString(resource.getURIString());
+		resourceDescriptor.setName(resource.getName());
+		resourceDescriptor.setLabel(resource.getLabel());
+		resourceDescriptor.setDescription(resource.getDescription());
+		resourceDescriptor.setResourceType(resource.getResourceType());
+		resourceDescriptor.setParentFolder(resource.getParentUri());
+		resourceDescriptor.setVersion(resource.getVersion());
+		resourceDescriptor.setCreationDate(resource.getCreationDate());
+		return resourceDescriptor;
+	}
+
+	public Resource toResource(ResourceDescriptor resourceDescriptor) {
+		Resource resource = null;
+		String wsType = resourceDescriptor.getWsType();
+		if (wsType.equals(ResourceDescriptor.TYPE_FOLDER)) {
+			resource = new Folder();
+		} else {
+			resource = toFileResource(resourceDescriptor);
+		}
+		resource.setUri(resourceDescriptor.getUriString());
+		resource.setName(resourceDescriptor.getName());
+		resource.setLabel(resourceDescriptor.getLabel());
+		resource.setDescription(resourceDescriptor.getDescription());
+		resource.setParentUri(resourceDescriptor.getParentFolder());
+		resource.setVersion(resourceDescriptor.getVersion());
+		return resource;
+	}
+
+	private FileResource toFileResource(ResourceDescriptor resourceDescriptor) {
+		FileResource fileResource = new FileResource();
+		fileResource.setFileType(resourceDescriptor.getWsType());
+		if (resourceDescriptor.hasData()) {
+			fileResource.setData(resourceDescriptor.getData());
+		}
+		return fileResource;
+	}
+
+	/**
+	 * Return a list of ResourceDescriptor(s)
+	 * 
+	 * @throws IOException
+	 * @throws FileNotFoundException
+	 * 
+	 * @throws WSException
+	 */
+	public List<ResourceDescriptor> listResourceDescriptors(String uri) throws FileNotFoundException, IOException {
+		List<ResourceDescriptor> returnedMaps = new ArrayList<>();
+
+		List<Resource> resources = listResource(uri);
+		if (CollectionUtils.isEmpty(resources)) {
+			return returnedMaps;
+		}
+		for (Resource resource : resources) {
+			returnedMaps.add(toResourceDescriptor(resource));
+		}
+
+		/*
+		 * // This filters with object level security. // Will only get folders
+		 * the user has access to
+		 * 
+		 * List<Resource> folders = getRepository().getSubFolders(null, uri);
+		 * filterFolderList(folders);
+		 * 
+		 * if (folders == null) return returnedMaps;
+		 * 
+		 * for (int i = 0; i < folders.size(); ++i) { Resource folderRes =
+		 * folders.get(i);
+		 * returnedMaps.add(createResourceDescriptor(folderRes)); }
+		 * 
+		 * // create a criteria for finding things with a common parent folder.
+		 * FilterCriteria filterCriteria = new FilterCriteria();
+		 * filterCriteria.addFilterElement(FilterCriteria.
+		 * createParentFolderFilter(uri));
+		 * 
+		 * // This filters with object level security // Will only get resources
+		 * the user has access to
+		 * 
+		 * List units = getRepository().loadClientResources(filterCriteria);
+		 * 
+		 * if (units == null) return returnedMaps;
+		 * 
+		 * for (Iterator it = units.iterator(); units != null && it.hasNext();)
+		 * { Resource fileRes = (Resource) it.next(); try {
+		 * returnedMaps.add(createResourceDescriptor(fileRes)); } catch
+		 * (Exception ex) { logger.error(ex); } }
+		 */
+
+		return returnedMaps;
+	}
+
+	public Class<?> getResourceType() {
+		return null;
+	}
+
+	public ResourceDescriptor put(Request request) throws FileNotFoundException, IOException {
+		ResourceDescriptor resourceDescriptor = request.getResourceDescriptor();
+		Resource resource = toResource(resourceDescriptor);
+		String resourceURI = resource.getURIString();
+		File file = getFile(resourceURI);
+		if (resourceDescriptor.isNew()) {
+			if (resource instanceof Folder) {
+				file.mkdirs();
+			} else {
+				FileResource fileResource = (FileResource) resource;
+				FileUtils.write(file.getPath(), fileResource.getData());
+			}
+		} else {
+			if (resource instanceof Folder) {
+				// TODO
+			} else {
+				FileResource fileResource = (FileResource) resource;
+				FileUtils.write(file.getPath(), fileResource.getData());
+			}
+		}
+		resource = locateResource(file);
+		resourceDescriptor = toResourceDescriptor(resource);
+		return resourceDescriptor;
+	};
+}

+ 0 - 119
src/main/java/com/uas/report/axis/FileHelper.java

@@ -1,119 +0,0 @@
-package com.uas.report.axis;
-
-import java.io.File;
-import java.io.FileFilter;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import org.springframework.util.StringUtils;
-
-import com.uas.report.SpecialProperties;
-import com.uas.report.util.ContextUtils;
-
-public class FileHelper {
-
-	private static SpecialProperties specialProperties = ContextUtils.getBean(SpecialProperties.class);
-
-	private static FileFilter filter = new FileFilter() {
-		@Override
-		public boolean accept(File file) {
-			if (file == null || !file.exists()) {
-				return false;
-			}
-			// 不支持查看、压缩:jasper文件、tmp路径
-			String filePath = file.getPath();
-			if (filePath.endsWith(".jasper") || filePath.endsWith("tmp") || filePath.contains("\\tmp\\")
-					|| filePath.contains("/tmp/")) {
-				return false;
-			}
-			return true;
-		}
-	};
-
-	public static List<Resource> listResource(String resourceURI) throws FileNotFoundException, IOException {
-		File dir = new File(specialProperties.getLocalBaseDir() + Folder.SEPARATOR + resourceURI);
-		if (!dir.exists() || !dir.isDirectory() || !filter.accept(dir)) {
-			return null;
-		}
-		List<Resource> resources = new ArrayList<>();
-		File[] files = dir.listFiles(filter);
-		for (File file : files) {
-			resources.add(locateResource(file));
-		}
-		return resources;
-	}
-
-	public static Resource locateResource(String resourceURI) throws FileNotFoundException, IOException {
-		return locateResource(getFile(resourceURI));
-	}
-
-	private static Resource locateResource(File file) throws FileNotFoundException, IOException {
-		if (file == null || !file.exists() || !filter.accept(file)) {
-			return null;
-		}
-		Resource resource = null;
-		if (file.isDirectory()) {
-			resource = new Folder();
-		} else {
-			resource = locateFileResource(file);
-		}
-		resource.setCreationDate(new Date(file.lastModified()));
-		resource.setUpdateDate(new Date(file.lastModified()));
-		resource.setVersion(1);
-		resource.setName(file.getName());
-		resource.setLabel(file.getName());
-		resource.setDescription(file.getName());
-		resource.setUri(getResourceURI(file));
-		return resource;
-	}
-
-	private static FileResource locateFileResource(File file) throws FileNotFoundException, IOException {
-		FileResource fileResource = new FileResource();
-		String fileType = getFileType(file.getName());
-		if (StringUtils.isEmpty(fileType)) {
-			fileResource.setFileType(FileResource.TYPE_UNKNOW);
-		} else {
-			if (fileType.equalsIgnoreCase(FileResource.TYPE_JRXML)) {
-				fileResource.setFileType(FileResource.TYPE_JRXML);
-			} else if (isImage(fileType)) {
-				fileResource.setFileType(FileResource.TYPE_IMAGE);
-			} else {
-				fileResource.setFileType(FileResource.TYPE_UNKNOW);
-			}
-		}
-		fileResource.readData(new FileInputStream(file));
-		return fileResource;
-	}
-
-	private static boolean isImage(String fileType) {
-		return fileType.toLowerCase()
-				.matches("^(gif|jpg|jpeg|png|bmp|tiff|pcx|tga|exif|fpx|svg|psd|cdr|pcd|dxf|ufo|eps|ai|raw)$");
-	}
-
-	private static File getFile(String resourceURI) {
-		return new File(specialProperties.getLocalBaseDir() + "/" + resourceURI);
-	}
-
-	private static String getResourceURI(File file) {
-		String resourceURI = file.getPath();
-		resourceURI = resourceURI.replace(new File(specialProperties.getLocalBaseDir()).getPath(), "");
-		resourceURI = resourceURI.replace("\\", Folder.SEPARATOR);
-		if (!resourceURI.startsWith(Folder.SEPARATOR)) {
-			resourceURI = Folder.SEPARATOR + resourceURI;
-		}
-		return resourceURI;
-	}
-
-	private static String getFileType(String fileName) {
-		int index = fileName.lastIndexOf(".");
-		if (index < 0) {
-			return null;
-		}
-		return fileName.substring(index + 1);
-	}
-
-}

+ 0 - 16
src/main/java/com/uas/report/axis/FileResource.java

@@ -9,22 +9,6 @@ import com.uas.report.axis.util.StreamUtil;
 
 public class FileResource extends Resource {
 
-	public static final String TYPE_IMAGE = "img";
-	public static final String TYPE_FONT = "font";
-	public static final String TYPE_JRXML = "jrxml";
-	public static final String TYPE_JAR = "jar";
-	public static final String TYPE_RESOURCE_BUNDLE = "prop";
-	public static final String TYPE_STYLE_TEMPLATE = "jrtx";
-	public static final String TYPE_XML = "xml";
-	public static final String TYPE_JSON = "json";
-	public static final String TYPE_CSS = "css";
-	public static final String TYPE_ACCESS_GRANT_SCHEMA = "accessGrantSchema";
-	public static final String TYPE_MONGODB_JDBC_CONFIG = "config";
-	public static final String TYPE_AZURE_CERTIFICATE = "cer";
-	public static final String TYPE_SECURE_FILE = "secureFile";
-	public static final String TYPE_DASHBOARD_COMPONENTS_SCHEMA = "dashboardComponent";
-	public static final String TYPE_UNKNOW = "unknow";
-
 	private String fileType;
 	private byte[] data;
 	private String referenceURI;

+ 10 - 0
src/main/java/com/uas/report/axis/FileResourceHandler.java

@@ -0,0 +1,10 @@
+package com.uas.report.axis;
+
+public class FileResourceHandler extends BasicResourceHandler {
+
+	@Override
+	public Class<?> getResourceType() {
+		return FileResource.class;
+	}
+
+}

+ 10 - 0
src/main/java/com/uas/report/axis/FolderHandler.java

@@ -0,0 +1,10 @@
+package com.uas.report.axis;
+
+public class FolderHandler extends BasicResourceHandler {
+
+	@Override
+	public Class<?> getResourceType() {
+		return Folder.class;
+	}
+
+}

+ 31 - 0
src/main/java/com/uas/report/axis/InputControlQueryDataRow.java

@@ -0,0 +1,31 @@
+package com.uas.report.axis;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class InputControlQueryDataRow {
+
+	private Object value = null;
+	private List<Object> columnValues = null;
+
+	/** Creates a new instance of InputControlQueryDataRow */
+	public InputControlQueryDataRow() {
+		columnValues = new ArrayList<>();
+	}
+
+	public List<Object> getColumnValues() {
+		return columnValues;
+	}
+
+	public void setColumnValues(List<Object> columnValues) {
+		this.columnValues = columnValues;
+	}
+
+	public Object getValue() {
+		return value;
+	}
+
+	public void setValue(Object value) {
+		this.value = value;
+	}
+}

+ 18 - 17
src/main/java/com/uas/report/axis/Resource.java

@@ -5,14 +5,19 @@ import java.util.List;
 
 public abstract class Resource {
 
-	private int version;
+	/**
+	 * 更新一次,版本号加1
+	 */
+	public static final int DEFAULT_VERSION = 1;
+
+	private int version = DEFAULT_VERSION;
 	private Date creationDate;
 	private Date updateDate;
 	private String name;
 	private String label;
 	private String description;
 	private List<Attribute> attributes;
-	private String folderUri;
+	private String parentUri;
 	private String uri;
 
 	public int getVersion() {
@@ -71,14 +76,6 @@ public abstract class Resource {
 		this.attributes = attributes;
 	}
 
-	public String getFolderUri() {
-		return folderUri;
-	}
-
-	public void setFolderUri(String folderUri) {
-		this.folderUri = folderUri;
-	}
-
 	public String getUri() {
 		return uri;
 	}
@@ -87,11 +84,19 @@ public abstract class Resource {
 		this.uri = uri;
 	}
 
+	public String getParentUri() {
+		return parentUri;
+	}
+
+	public void setParentUri(String parentUri) {
+		this.parentUri = parentUri;
+	}
+
 	public String getURIString() {
 		if (uri == null) {
 			StringBuffer sb = new StringBuffer();
-			if (getParentFolder() != null && !getParentFolder().equals(Folder.SEPARATOR))
-				sb.append(getParentFolder());
+			if (getParentUri() != null && !getParentUri().equals(Folder.SEPARATOR))
+				sb.append(getParentUri());
 			sb.append(Folder.SEPARATOR);
 			if (getName() != null && !getName().equals(Folder.SEPARATOR))
 				sb.append(getName());
@@ -100,10 +105,6 @@ public abstract class Resource {
 		return uri;
 	}
 
-	public String getParentFolder() {
-		return folderUri;
-	}
-
 	public String getResourceType() {
 		return getImplementingItf().getName();
 	}
@@ -114,7 +115,7 @@ public abstract class Resource {
 	public String toString() {
 		return "Resource [version=" + version + ", creationDate=" + creationDate + ", updateDate=" + updateDate
 				+ ", name=" + name + ", label=" + label + ", description=" + description + ", attributes=" + attributes
-				+ ", folderUri=" + folderUri + ", uri=" + uri + "]";
+				+ ", folderUri=" + parentUri + ", uri=" + uri + "]";
 	}
 
 }

+ 151 - 7
src/main/java/com/uas/report/axis/ResourceDescriptor.java

@@ -1,10 +1,13 @@
 package com.uas.report.axis;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 
+import org.springframework.util.StringUtils;
+
 public class ResourceDescriptor {
 
 	public static final String TYPE_FOLDER = "folder";
@@ -20,21 +23,47 @@ public class ResourceDescriptor {
 	// File resource properties
 	public static final String PROP_FILERESOURCE_HAS_DATA = "PROP_HAS_DATA";
 
+	public static final String TYPE_IMAGE = "img";
+	public static final String TYPE_FONT = "font";
+	public static final String TYPE_JRXML = "jrxml";
+	public static final String TYPE_JAR = "jar";
+	public static final String TYPE_RESOURCE_BUNDLE = "prop";
+	public static final String TYPE_STYLE_TEMPLATE = "jrtx";
+	public static final String TYPE_XML = "xml";
+	public static final String TYPE_JSON = "json";
+	public static final String TYPE_CSS = "css";
+	public static final String TYPE_ACCESS_GRANT_SCHEMA = "accessGrantSchema";
+	public static final String TYPE_MONGODB_JDBC_CONFIG = "config";
+	public static final String TYPE_AZURE_CERTIFICATE = "cer";
+	public static final String TYPE_SECURE_FILE = "secureFile";
+	public static final String TYPE_DASHBOARD_COMPONENTS_SCHEMA = "dashboardComponent";
+	public static final String TYPE_UNKNOW = "unknow";
+
+	// SQL resource properties
+	public static final String PROP_QUERY_DATA = "PROP_QUERY_DATA";
+	public static final String PROP_QUERY_DATA_ROW = "PROP_QUERY_DATA_ROW";
+	public static final String PROP_QUERY_DATA_ROW_COLUMN = "PROP_QUERY_DATA_ROW_COLUMN";
+
 	private List<ResourceProperty> properties = new ArrayList<>();
 	private HashMap<String, ResourceProperty> hm = new HashMap<>();
 
 	private String name;
 	private String label;
+	private String description;
+	private boolean isNew = false;
 	private String wsType;
 	private String uriString;
-	private boolean isNew = false;
-	private String description;
 
 	private Date creationDate;
 
 	private List<ResourceDescriptor> children = new ArrayList<>();
 	private List<ListItem> parameters = new ArrayList<>();
 
+	// This data is used to store the data for sunsequent calls to
+	// getQueryData....
+	private List<InputControlQueryDataRow> queryDataCache = null;
+	private byte[] data;
+	private String fileType;
 	private String referenceType;
 
 	public List<ResourceProperty> getProperties() {
@@ -125,6 +154,14 @@ public class ResourceDescriptor {
 		this.parameters = parameters;
 	}
 
+	public byte[] getData() {
+		return data;
+	}
+
+	public void setData(byte[] data) {
+		this.data = data;
+	}
+
 	public String getReferenceType() {
 		return referenceType;
 	}
@@ -133,10 +170,41 @@ public class ResourceDescriptor {
 		this.referenceType = referenceType;
 	}
 
+	public List<InputControlQueryDataRow> getQueryDataCache() {
+		return queryDataCache;
+	}
+
+	public void setQueryDataCache(List<InputControlQueryDataRow> queryDataCache) {
+		this.queryDataCache = queryDataCache;
+	}
+
+	public String getFileType() {
+		return fileType;
+	}
+
+	public void setFileType(String fileType) {
+		this.fileType = fileType;
+	}
+
 	public void setVersion(int version) {
 		setResourceProperty(PROP_VERSION, "" + version);
 	}
 
+	public int getVersion() {
+		String version = getResourcePropertyValue(PROP_VERSION);
+		if (StringUtils.isEmpty(version)) {
+			return Resource.DEFAULT_VERSION;
+		}
+		return Integer.parseInt(version);
+	}
+
+	public boolean hasData() {
+		String s = getResourcePropertyValue(PROP_FILERESOURCE_HAS_DATA);
+		if (s != null)
+			return s.equals("true");
+		return false;
+	}
+
 	public void setHasData(boolean hasData) {
 		setResourceProperty(PROP_FILERESOURCE_HAS_DATA, "" + hasData);
 	}
@@ -146,11 +214,86 @@ public class ResourceDescriptor {
 	}
 
 	public void setResourceType(String resourceType) {
-		setResourceProperty(PROP_RESOURCE_TYPE, "" + resourceType);
+		setResourceProperty(PROP_RESOURCE_TYPE, resourceType);
 	}
 
 	public void setParentFolder(String parentFolder) {
-		setResourceProperty(PROP_PARENT_FOLDER, "" + parentFolder);
+		setResourceProperty(PROP_PARENT_FOLDER, parentFolder);
+	}
+
+	public String getParentFolder() {
+		return getResourcePropertyValue(PROP_PARENT_FOLDER);
+	}
+
+	/**
+	 * Return the property PROP_QUERY_DATA as set of InputControlQueryDataRow
+	 * the structure is as follow: PROP_QUERY_DATA { PROP_QUERY_DATA_ROW {
+	 * PROP_QUERY_DATA_COLUMN_VALUE } } } This method is performed only once,
+	 * and the result is cached in queryDataCache. Subsequent calls to this
+	 * method will return always queryDataCache.
+	 * 
+	 */
+	public List<InputControlQueryDataRow> getQueryData() {
+
+		if (queryDataCache != null)
+			return queryDataCache;
+
+		queryDataCache = new ArrayList<>();
+
+		ResourceProperty rp = getResourceProperty(PROP_QUERY_DATA);
+		if (rp != null) {
+			// Look for rows....
+			for (int i = 0; i < rp.getProperties().size(); ++i) {
+				ResourceProperty rpRow = (ResourceProperty) rp.getProperties().get(i);
+				if (rpRow.getName().equals(PROP_QUERY_DATA_ROW)) {
+					InputControlQueryDataRow icqdr = new InputControlQueryDataRow();
+					icqdr.setValue(rpRow.getValue());
+
+					// Look for row details...
+					for (int k = 0; k < rpRow.getProperties().size(); ++k) {
+						ResourceProperty rpRowChild = (ResourceProperty) rpRow.getProperties().get(k);
+						if (rpRowChild.getName().equals(PROP_QUERY_DATA_ROW_COLUMN)) {
+							icqdr.getColumnValues().add(rpRowChild.getValue());
+						}
+					}
+
+					queryDataCache.add(icqdr);
+				}
+			}
+
+		}
+		return queryDataCache;
+	}
+
+	/**
+	 * Convenient way to create the PROP_QUERY_DATA properties from a set of
+	 * InputControlQueryDataRow the structure will be create as follow:
+	 * PROP_QUERY_DATA { PROP_QUERY_DATA_ROW { PROP_QUERY_DATA_COLUMN_VALUE } }
+	 * } A call to this method will set to null the queryDataCache
+	 * 
+	 */
+	public void setQueryData(List<InputControlQueryDataRow> queryData) {
+
+		queryDataCache = null;
+
+		ResourceProperty rp = new ResourceProperty(PROP_QUERY_DATA);
+
+		for (int i = 0; i < queryData.size(); ++i) {
+			InputControlQueryDataRow icqdr = queryData.get(i);
+
+			ResourceProperty rpRow = new ResourceProperty(PROP_QUERY_DATA_ROW, "" + icqdr.getValue());
+
+			for (int k = 0; k < icqdr.getColumnValues().size(); ++k) {
+				Object columnValue = icqdr.getColumnValues().get(k);
+				rpRow.getProperties().add(new ResourceProperty(PROP_QUERY_DATA_ROW_COLUMN,
+						(columnValue == null) ? "" : "" + columnValue));
+			}
+
+			rp.getProperties().add(rpRow);
+		}
+
+		setResourceProperty(rp);
+
 	}
 
 	public ResourceProperty getResourceProperty(String resourcePropertyName) {
@@ -217,9 +360,10 @@ public class ResourceDescriptor {
 	@Override
 	public String toString() {
 		return "ResourceDescriptor [properties=" + properties + ", hm=" + hm + ", name=" + name + ", label=" + label
-				+ ", wsType=" + wsType + ", uriString=" + uriString + ", isNew=" + isNew + ", description="
-				+ description + ", creationDate=" + creationDate + ", children=" + children + ", parameters="
-				+ parameters + ", referenceType=" + referenceType + "]";
+				+ ", description=" + description + ", isNew=" + isNew + ", wsType=" + wsType + ", uriString="
+				+ uriString + ", creationDate=" + creationDate + ", children=" + children + ", parameters=" + parameters
+				+ ", queryDataCache=" + queryDataCache + ", data=" + Arrays.toString(data) + ", fileType=" + fileType
+				+ ", referenceType=" + referenceType + "]";
 	}
 
 }

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

@@ -0,0 +1,11 @@
+package com.uas.report.axis;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+public interface ResourceHandler {
+
+	public Class<?> getResourceType();
+
+	public ResourceDescriptor put(Request request) throws FileNotFoundException, IOException;
+}

+ 113 - 0
src/main/java/com/uas/report/axis/ResourceHandlerRegistry.java

@@ -0,0 +1,113 @@
+package com.uas.report.axis;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Map.Entry;
+
+public class ResourceHandlerRegistry {
+
+	private Map<String, Class<? extends BasicResourceHandler>> typeHandlers;
+	private Map<String, BasicResourceHandler> handlers;
+	private Map<String, String> resourceTypes;
+
+	public ResourceHandlerRegistry() throws ClassNotFoundException, InstantiationException, IllegalAccessException {
+		init();
+	}
+
+	private void initTypeHandlers() {
+		typeHandlers = new HashMap<>();
+		typeHandlers.put(ResourceDescriptor.TYPE_FOLDER, FolderHandler.class);
+		typeHandlers.put(ResourceDescriptor.TYPE_IMAGE, FileResourceHandler.class);
+		typeHandlers.put(ResourceDescriptor.TYPE_JRXML, FileResourceHandler.class);
+		typeHandlers.put(ResourceDescriptor.TYPE_FONT, FileResourceHandler.class);
+		typeHandlers.put(ResourceDescriptor.TYPE_JRXML, FileResourceHandler.class);
+		typeHandlers.put(ResourceDescriptor.TYPE_XML, FileResourceHandler.class);
+		typeHandlers.put(ResourceDescriptor.TYPE_JAR, FileResourceHandler.class);
+		typeHandlers.put(ResourceDescriptor.TYPE_REFERENCE, FileResourceHandler.class);
+	}
+
+	public void init() throws ClassNotFoundException, InstantiationException, IllegalAccessException {
+		initTypeHandlers();
+		handlers = new HashMap<>();
+		resourceTypes = new HashMap<>();
+
+		for (Iterator<Entry<String, Class<? extends BasicResourceHandler>>> it = typeHandlers.entrySet().iterator(); it
+				.hasNext();) {
+			Entry<String, Class<? extends BasicResourceHandler>> entry = it.next();
+			String wsType = entry.getKey();
+			BasicResourceHandler handler = null;
+
+			Class<?> handlerClass = entry.getValue();
+
+			handler = (BasicResourceHandler) handlerClass.newInstance();
+
+			handlers.put(wsType, handler);
+
+			Class<?> resourceType = handler.getResourceType();
+			resourceTypes.put(resourceType.getName(), wsType);
+
+		}
+	}
+
+	public BasicResourceHandler getHandler(String wsType) {
+		BasicResourceHandler handler = handlers.get(wsType);
+		return handler;
+	}
+
+	public BasicResourceHandler getHandler(Resource resource) {
+		String resourceType = resource.getResourceType();
+		String wsType = resourceTypes.get(resourceType);
+		if (wsType == null) {
+			synchronized (resourceTypes) {
+				// determine a (more generic) type for the resource
+				wsType = determineWSType(resource);
+				// cache the type
+				resourceTypes.put(resourceType, wsType);
+			}
+		}
+		return getHandler(wsType);
+	}
+
+	protected String determineWSType(Resource resource) {
+		String wsType = null;
+
+		LinkedList<Class<?>> itfQueue = new LinkedList<>();
+		Class<?>[] itfs = resource.getClass().getInterfaces();
+		for (int i = 0; i < itfs.length; i++) {
+			itfQueue.add(itfs[i]);
+		}
+
+		while (!itfQueue.isEmpty()) {
+			Class<?> itf = itfQueue.removeFirst();
+			wsType = resourceTypes.get(itf.getName());
+			if (wsType != null) {
+				break;
+			}
+
+			Class<?>[] interfaces = itf.getInterfaces();
+			for (int i = 0; i < interfaces.length; i++) {
+				itfQueue.add(interfaces[i]);
+			}
+		}
+
+		return wsType;
+	}
+
+	public boolean typeExtends(String type, String parentType) {
+		BasicResourceHandler handler = handlers.get(type);
+		Class<?> resourceType = handler.getResourceType();
+		BasicResourceHandler parentHandler = handlers.get(parentType);
+		Class<?> parentResourceType = parentHandler.getResourceType();
+		return parentResourceType.isAssignableFrom(resourceType);
+	}
+
+	public Map<String, Class<? extends BasicResourceHandler>> getTypeHandlers() {
+		return typeHandlers;
+	}
+
+	public void setTypeHandlers(Map<String, Class<? extends BasicResourceHandler>> typeHandlers) {
+		this.typeHandlers = typeHandlers;
+	}
+}

+ 80 - 0
src/main/java/com/uas/report/axis/ValidationError.java

@@ -0,0 +1,80 @@
+package com.uas.report.axis;
+
+import java.io.Serializable;
+import java.text.MessageFormat;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "error")
+public class ValidationError implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	private String errorCode;
+	private Object[] arguments;
+	private String defaultMessage;
+	private String field;
+
+	public ValidationError() {
+	}
+
+	public ValidationError(String errorCode, Object[] arguments, String defaultMessage, String field) {
+		this.errorCode = errorCode;
+		this.arguments = arguments;
+		this.defaultMessage = defaultMessage;
+		this.field = field;
+	}
+
+	public ValidationError(String errorCode, Object[] arguments, String defaultMessage) {
+		this(errorCode, arguments, defaultMessage, null);
+	}
+
+	public String getErrorCode() {
+		return errorCode;
+	}
+
+	public Object[] getErrorArguments() {
+		return arguments;
+	}
+
+	public String getDefaultMessage() {
+		return defaultMessage;
+	}
+
+	public String getField() {
+		return field;
+	}
+
+	public void setErrorCode(String errorCode) {
+		this.errorCode = errorCode;
+	}
+
+	public void setArguments(Object[] arguments) {
+		this.arguments = arguments;
+	}
+
+	public void setErrorArguments(Object... arguments) {
+		this.setArguments(arguments);
+	}
+
+	public void setDefaultMessage(String defaultMessage) {
+		this.defaultMessage = defaultMessage;
+	}
+
+	public void setField(String field) {
+		this.field = field;
+	}
+
+	public String toString() {
+		if (getDefaultMessage() != null) {
+			return MessageFormat.format(getDefaultMessage(), getErrorArguments());
+		}
+
+		if (getField() == null) {
+			return getErrorCode();
+		}
+
+		return getErrorCode() + "." + getField();
+	}
+
+}

+ 68 - 0
src/main/java/com/uas/report/axis/ValidationErrors.java

@@ -0,0 +1,68 @@
+package com.uas.report.axis;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "errors")
+public class ValidationErrors implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	private final List<ValidationError> errors;
+
+	public ValidationErrors() {
+		errors = new ArrayList<>();
+	}
+
+	public ValidationErrors(List<ValidationError> errors) {
+		this.errors = errors;
+	}
+
+	public boolean isError() {
+		return !errors.isEmpty();
+	}
+
+	@XmlElement(name = "error", type = ValidationError.class)
+	public List<ValidationError> getErrors() {
+		return errors;
+	}
+
+	public void add(ValidationError error) {
+		errors.add(error);
+	}
+
+	public String toString() {
+		if (!isError()) {
+			return "No errors";
+		}
+
+		StringBuffer sb = new StringBuffer();
+		sb.append(errors.size());
+		sb.append(" error(s)\n");
+		for (Iterator<ValidationError> it = errors.iterator(); it.hasNext();) {
+			ValidationError error = it.next();
+			sb.append(error.toString());
+			sb.append('\n');
+		}
+		return sb.toString();
+	}
+
+	public void removeError(String code, String field) {
+		for (Iterator<ValidationError> it = errors.iterator(); it.hasNext();) {
+			ValidationError error = it.next();
+			if (matches(error, code, field)) {
+				it.remove();
+			}
+		}
+	}
+
+	protected boolean matches(ValidationError error, String code, String field) {
+		return code.equals(error.getErrorCode()) && field.equals(error.getField());
+	}
+
+}

+ 34 - 0
src/main/java/com/uas/report/axis/WSException.java

@@ -0,0 +1,34 @@
+package com.uas.report.axis;
+
+public class WSException extends Exception {
+
+	private static final long serialVersionUID = 1L;
+
+	public static final int NO_ERROR = 0;
+	public static final int GENERAL_ERROR = 1;
+	public static final int GENERAL_ERROR2 = 2;
+	public static final int REFERENCED_RESOURCE_NOT_FOUND = 3;
+	public static final int EXPORT_ERROR = 4;
+	public static final int FILL_ERROR = 5;
+	public static final int GENERAL_REQUEST_ERROR = 6;
+
+	private int errorCode = 0;
+
+	/** Creates a new instance of WSException */
+	public WSException(int code, String message) {
+		super(message);
+		this.errorCode = code;
+	}
+
+	public WSException(Exception e) {
+		this(GENERAL_ERROR, e.getMessage());
+	}
+
+	public int getErrorCode() {
+		return errorCode;
+	}
+
+	public void setErrorCode(int errorCode) {
+		this.errorCode = errorCode;
+	}
+}

+ 24 - 0
src/main/java/com/uas/report/axis/WSValidationException.java

@@ -0,0 +1,24 @@
+package com.uas.report.axis;
+
+public class WSValidationException extends WSException {
+
+	private static final long serialVersionUID = 1L;
+
+	private final String objectName;
+	private final ValidationErrors errors;
+
+	public WSValidationException(String objectName, ValidationErrors errors) {
+		super(GENERAL_ERROR2, errors.toString());
+
+		this.objectName = objectName;
+		this.errors = errors;
+	}
+
+	public ValidationErrors getErrors() {
+		return errors;
+	}
+
+	public String getObjectName() {
+		return objectName;
+	}
+}

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

@@ -1,5 +1,6 @@
 package com.uas.report.axis.repository;
 
+import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.StringReader;
@@ -16,36 +17,69 @@ import java.util.Map.Entry;
 import javax.activation.DataHandler;
 import javax.activation.DataSource;
 
+import org.apache.axis.AxisFault;
 import org.apache.axis.Message;
 import org.apache.axis.MessageContext;
+import org.apache.axis.attachments.AttachmentPart;
 import org.apache.axis.attachments.Attachments;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.MessageSourceResolvable;
+import org.springframework.context.NoSuchMessageException;
+import org.springframework.context.support.DefaultMessageSourceResolvable;
+import org.springframework.context.support.ReloadableResourceBundleMessageSource;
 import org.springframework.stereotype.Service;
-import org.springframework.util.CollectionUtils;
+import org.springframework.validation.DefaultMessageCodesResolver;
+import org.springframework.validation.MessageCodesResolver;
 
+import com.uas.report.SpecialProperties;
 import com.uas.report.axis.Argument;
-import com.uas.report.axis.FileHelper;
-import com.uas.report.axis.FileResource;
-import com.uas.report.axis.Folder;
 import com.uas.report.axis.ListItem;
 import com.uas.report.axis.OperationResult;
 import com.uas.report.axis.Request;
 import com.uas.report.axis.Resource;
 import com.uas.report.axis.ResourceDescriptor;
+import com.uas.report.axis.BasicResourceHandler;
+import com.uas.report.axis.ResourceHandlerRegistry;
 import com.uas.report.axis.ResultAttachments;
+import com.uas.report.axis.ValidationError;
+import com.uas.report.axis.ValidationErrors;
+import com.uas.report.axis.WSException;
+import com.uas.report.axis.WSValidationException;
 import com.uas.report.axis.util.Marshaller;
 import com.uas.report.axis.util.Unmarshaller;
 
 @Service
-public class RepositoryManagementServiceImpl implements RepositoryManagementService {
+public class RepositoryManagementServiceImpl implements RepositoryManagementService, InitializingBean {
 
 	private static final String VERSION = "2.0.1";
 
+	@Autowired
+	private SpecialProperties specialProperties;
+
 	private Locale locale = null; // Default locale....
 
+	private ResourceHandlerRegistry resourceHandlerRegistry;
+
+	private BasicResourceHandler basicResourceHandler = new BasicResourceHandler();
+
+	private ReloadableResourceBundleMessageSource messageSource;
+
+	private String attachmentsPath = specialProperties.getLocalBaseDir() + "/tmp/jasperserver/axis_attachments";
+
 	private Logger logger = LoggerFactory.getLogger(getClass());
 
+	@Override
+	public void afterPropertiesSet() throws Exception {
+		resourceHandlerRegistry = new ResourceHandlerRegistry();
+		messageSource = new ReloadableResourceBundleMessageSource();
+		messageSource.setUseCodeAsDefaultMessage(true);
+		messageSource.setFallbackToSystemLocale(false);
+		messageSource.setBasenames("bundlePathsListCe");
+	}
+
 	@Override
 	public String list(String requestXmlString) {
 		OperationResult operationResult = new OperationResult();
@@ -137,7 +171,7 @@ public class RepositoryManagementServiceImpl implements RepositoryManagementServ
 				}
 			} else if (request.getResourceDescriptor().getWsType().equals(ResourceDescriptor.TYPE_FOLDER)) {
 				logger.debug("List folders");
-				list = listResources(request.getResourceDescriptor().getUriString());
+				list = basicResourceHandler.listResourceDescriptors(request.getResourceDescriptor().getUriString());
 			} else if (request.getResourceDescriptor().getWsType().equals(ResourceDescriptor.TYPE_REPORTUNIT)) {
 				/*
 				 * logger.debug("List report units"); list =
@@ -199,22 +233,26 @@ public class RepositoryManagementServiceImpl implements RepositoryManagementServ
 					}
 				}
 			}
-//			if (params.size() > 0 && specialOptions.containsKey(Argument.RU_REF_URI)) {
-//				ResourceDescriptor reportDescriptior = createResourceDescriptor(
-//						(String) specialOptions.get(Argument.RU_REF_URI));
-//				specialOptions.put(Argument.PARAMS_ARG, buildParameterMap(params, reportDescriptior));
-//			}
+			// if (params.size() > 0 &&
+			// specialOptions.containsKey(Argument.RU_REF_URI)) {
+			// ResourceDescriptor reportDescriptior = createResourceDescriptor(
+			// (String) specialOptions.get(Argument.RU_REF_URI));
+			// specialOptions.put(Argument.PARAMS_ARG, buildParameterMap(params,
+			// reportDescriptior));
+			// }
 
 			String resourceURI = request.getResourceDescriptor().getUriString();
-			Resource resource = FileHelper.locateResource(resourceURI);
+			Resource resource = basicResourceHandler.locateResource(resourceURI);
 			if (resource == null) {
 				logger.warn("Get: null resourceDescriptor for " + resourceURI);
 				operationResult.setReturnCode(2);
-//				operationResult
-//						.setMessage(messageSource.getMessage("webservices.error.resourceNotFound", null, getLocale()));
+				// operationResult
+				// .setMessage(messageSource.getMessage("webservices.error.resourceNotFound",
+				// null, getLocale()));
 			} else {
-//				ResourceDescriptor rd = createResourceDescriptor(resource, processDescriptorOptions(specialOptions));
-				ResourceDescriptor rd = createResourceDescriptor(resource);
+				// ResourceDescriptor rd = createResourceDescriptor(resource,
+				// processDescriptorOptions(specialOptions));
+				ResourceDescriptor rd = basicResourceHandler.toResourceDescriptor(resource);
 
 				logger.debug("Get: " + resourceURI + ", wsType: " + rd.getWsType() + ", resourceType: "
 						+ rd.getResourceType());
@@ -223,13 +261,16 @@ public class RepositoryManagementServiceImpl implements RepositoryManagementServ
 				ResultAttachments attachments = new ResultAttachments();
 				attachments
 						.setEncapsulationDime(getArgumentValue("USE_DIME_ATTACHMENTS", request.getArguments()) != null);
-//				ResourceHandler handler = getHandlerRegistry().getHandler(rd.getWsType());
-//				handler.getAttachments(resource, specialOptions, rd, attachments, this);
-//				if (operationResult.getReturnCode() != 0) {
-//					addExceptionToAllAuditEvents(new Exception(operationResult.getMessage()));
-//				}
-//
-//				return marshalResponse(operationResult, attachments);
+				// ResourceHandler handler =
+				// getHandlerRegistry().getHandler(rd.getWsType());
+				// handler.getAttachments(resource, specialOptions, rd,
+				// attachments, this);
+				// if (operationResult.getReturnCode() != 0) {
+				// addExceptionToAllAuditEvents(new
+				// Exception(operationResult.getMessage()));
+				// }
+				//
+				// return marshalResponse(operationResult, attachments);
 				return marshalResponse(operationResult);
 			}
 		} catch (Exception e) {
@@ -246,8 +287,53 @@ public class RepositoryManagementServiceImpl implements RepositoryManagementServ
 
 	@Override
 	public String put(String requestXmlString) {
-		// TODO Auto-generated method stub
-		return null;
+		OperationResult operationResult = new OperationResult();
+		operationResult.setVersion(VERSION);
+		try {
+			StringReader xmlStringReader = new StringReader(requestXmlString);
+			Request request = (Request) Unmarshaller.unmarshal(xmlStringReader);
+			// createAuditEvent(request.getOperationName(),
+			// request.getResourceDescriptor().getWsType(),
+			// request.getResourceDescriptor().isNew());
+			setLocale(request.getLocale());
+
+			ResourceDescriptor newDescriptor = request.getResourceDescriptor();
+
+			logger.debug("Put: for " + newDescriptor.getUriString());
+
+			if (newDescriptor.getUriString() == null || newDescriptor.getUriString().length() == 0) {
+				throw new WSException(WSException.GENERAL_REQUEST_ERROR,
+						messageSource.getMessage("webservices.error.noUriGiven", null, getLocale()));
+			}
+
+			if (newDescriptor.getWsType() == null || newDescriptor.getWsType().length() == 0) {
+				throw new WSException(WSException.GENERAL_REQUEST_ERROR,
+						messageSource.getMessage("webservices.error.noTypeGiven", null, getLocale()));
+			}
+
+			String wsType = newDescriptor.getWsType();
+			BasicResourceHandler handler = resourceHandlerRegistry.getHandler(wsType);
+			operationResult.getResourceDescriptors().add(handler.put(request));
+
+		} catch (WSValidationException e) {
+			logger.error("caught validation exception: " + e.getMessage(), e);
+
+			operationResult.setReturnCode(e.getErrorCode());
+			operationResult.setMessage(getValidationErrorMessage(e.getObjectName(), e.getErrors()));
+		} catch (WSException e) {
+			operationResult.setReturnCode(e.getErrorCode());
+			operationResult.setMessage(e.getMessage());
+		} catch (Exception e) {
+
+			// e.printStackTrace();
+			logger.error("caught exception: " + e.getMessage(), e);
+
+			operationResult.setReturnCode(1);
+			operationResult.setMessage(e.getMessage());
+		}
+		logger.debug("Marshalling response");
+
+		return marshalResponse(operationResult);
 	}
 
 	@Override
@@ -274,6 +360,49 @@ public class RepositoryManagementServiceImpl implements RepositoryManagementServ
 		return null;
 	}
 
+	/**
+	 * Function to get attachments from an Axis message
+	 * @throws WSException 
+	 * @throws NoSuchMessageException 
+	 * @throws AxisFault 
+	 *
+	 */
+	public AttachmentPart[] getMessageAttachments() throws NoSuchMessageException, WSException, AxisFault {
+		try {
+			MessageContext msgContext = MessageContext.getCurrentContext();
+			File file = new File(attachmentsPath);
+			if (!file.exists()) {
+				file.mkdirs();
+			}
+			msgContext.setProperty(MessageContext.ATTACHMENTS_DIR, attachmentsPath);
+			Message reqMsg = msgContext.getRequestMessage();
+			Attachments messageAttachments = reqMsg.getAttachmentsImpl();
+			if (null == messageAttachments) {
+				logger.error("no attachment support");
+				return new AttachmentPart[0];
+			}
+			int attachmentCount = messageAttachments.getAttachmentCount();
+			AttachmentPart attachments[] = new AttachmentPart[attachmentCount];
+
+			Iterator<?> it = messageAttachments.getAttachments().iterator();
+			int count = 0;
+			while (it.hasNext()) {
+				AttachmentPart part = (AttachmentPart) it.next();
+				attachments[count++] = part;
+			}
+			return attachments;
+		} catch (AxisFault e) {
+			if (e.getFaultString().startsWith("java.io.IOException")) {
+//				throw new JSExceptionWrapper(new WSException(WSException.GENERAL_ERROR,
+//						messageSource.getMessage("webservices.error.attachments.folder", null, getLocale())));
+				throw new WSException(WSException.GENERAL_ERROR,
+						messageSource.getMessage("webservices.error.attachments.folder", null, getLocale()));
+			}
+//			throw new JSExceptionWrapper(e);
+			throw e;
+		}
+	}
+
 	public Locale getLocale() {
 		return locale;
 	}
@@ -394,82 +523,35 @@ public class RepositoryManagementServiceImpl implements RepositoryManagementServ
 		return null;
 	}
 
-	/**
-	 * Return a list of ResourceDescriptor(s)
-	 * @throws IOException 
-	 * @throws FileNotFoundException 
-	 * 
-	 * @throws WSException
-	 */
-	public List<ResourceDescriptor> listResources(String uri) throws FileNotFoundException, IOException {
-		logger.debug("list for uri: " + uri);
-
-		List<ResourceDescriptor> returnedMaps = new ArrayList<>();
-
-		List<Resource> resources = FileHelper.listResource(uri);
-		if(CollectionUtils.isEmpty(resources)){
-			return returnedMaps;
-		}
-		for(Resource resource :resources){
-			returnedMaps.add(createResourceDescriptor(resource));
+	protected String getValidationErrorMessage(String objectName, ValidationErrors errors) {
+		StringBuffer message = new StringBuffer();
+		List<ValidationError> errorList = errors.getErrors();
+		message.append(getMessage("webservices.error.validation.errors.prefix",
+				new Object[] { new Integer(errorList.size()) }));
+		message.append("\n");
+		for (Iterator<ValidationError> it = errorList.iterator(); it.hasNext();) {
+			ValidationError error = (ValidationError) it.next();
+			message.append(getValidationErrorMessage(objectName, error));
+			message.append("\n");
 		}
-		
-		/*
-		 * // This filters with object level security. // Will only get folders
-		 * the user has access to
-		 * 
-		 * List<Resource> folders = getRepository().getSubFolders(null, uri);
-		 * filterFolderList(folders);
-		 * 
-		 * if (folders == null) return returnedMaps;
-		 * 
-		 * for (int i = 0; i < folders.size(); ++i) { Resource folderRes =
-		 * folders.get(i);
-		 * returnedMaps.add(createResourceDescriptor(folderRes)); }
-		 * 
-		 * // create a criteria for finding things with a common parent folder.
-		 * FilterCriteria filterCriteria = new FilterCriteria();
-		 * filterCriteria.addFilterElement(FilterCriteria.
-		 * createParentFolderFilter(uri));
-		 * 
-		 * // This filters with object level security // Will only get resources
-		 * the user has access to
-		 * 
-		 * List units = getRepository().loadClientResources(filterCriteria);
-		 * 
-		 * if (units == null) return returnedMaps;
-		 * 
-		 * for (Iterator it = units.iterator(); units != null && it.hasNext();)
-		 * { Resource fileRes = (Resource) it.next(); try {
-		 * returnedMaps.add(createResourceDescriptor(fileRes)); } catch
-		 * (Exception ex) { logger.error(ex); } }
-		 */
-
-		return returnedMaps;
+		return message.toString();
 	}
 
-	/**
-	 * the same as createResourceDescriptor( resource, false)
-	 */
-	public ResourceDescriptor createResourceDescriptor(Resource resource) {
-		ResourceDescriptor descriptor = new ResourceDescriptor();
-		if(resource instanceof Folder){
-			descriptor.setWsType(ResourceDescriptor.TYPE_FOLDER);
-			descriptor.setHasData(false);
-		}else if(resource instanceof FileResource){
-			FileResource fileResource=(FileResource)resource;
-			descriptor.setWsType(fileResource.getFileType());
-			descriptor.setHasData(fileResource.hasData());
+	protected Object getValidationErrorMessage(String objectName, ValidationError error) {
+		MessageCodesResolver codesResolver = new DefaultMessageCodesResolver();
+		String[] codes;
+		if (error.getField() == null) {
+			codes = codesResolver.resolveMessageCodes(error.getErrorCode(), objectName);
+		} else {
+			codes = codesResolver.resolveMessageCodes(error.getErrorCode(), objectName, error.getField(), null);
 		}
-		descriptor.setUriString(resource.getURIString());
-		descriptor.setDescription(resource.getDescription());
-		descriptor.setLabel(resource.getLabel());
-		descriptor.setName(resource.getName());
-		descriptor.setResourceType(resource.getResourceType());
-		descriptor.setParentFolder(resource.getParentFolder());
-		descriptor.setVersion(resource.getVersion());
-		descriptor.setCreationDate(resource.getCreationDate());
-		return descriptor;
+		MessageSourceResolvable messageResolvable = new DefaultMessageSourceResolvable(codes, error.getErrorArguments(),
+				error.getDefaultMessage());
+		String message = messageSource.getMessage(messageResolvable, getLocale());
+		return message;
 	}
 
+	public String getMessage(String messageCode, Object[] args) {
+		return messageSource.getMessage(messageCode, args, getLocale());
+	}
 }

+ 1 - 1
src/main/java/com/uas/report/controller/PrintController.java

@@ -159,7 +159,7 @@ public class PrintController {
 			if (ArrayUtils.isEmpty(data)) {
 				throw new ReportException("报表导出失败:" + userName + "/" + reportName + "\n");
 			}
-			FileUtils.create(file.getPath(), data);
+			FileUtils.write(file.getPath(), data);
 		} else {
 			FileInputStream fileInputStream = null;
 			try {

+ 2 - 2
src/main/java/com/uas/report/service/impl/FileServiceImpl.java

@@ -165,7 +165,7 @@ public class FileServiceImpl implements FileService {
 			targetFile.getParentFile().mkdirs();
 		}
 		try {
-			FileUtils.create(targetFile.getAbsolutePath(), file.getBytes());
+			FileUtils.write(targetFile.getAbsolutePath(), file.getBytes());
 			return "成功上传文件至:" + targetFile.getPath();
 		} catch (IllegalStateException | IOException | ReportException e) {
 			logger.error("", e);
@@ -194,7 +194,7 @@ public class FileServiceImpl implements FileService {
 				// 导致最终文件路径不正确,如果手动设置临时路径为根路径,
 				// 又会因为权限问题导致文件写入失败,
 				// 所以自己在指定路径创建文件,而不使用transferTo方法
-				FileUtils.create(targetFile.getAbsolutePath(), file.getBytes());
+				FileUtils.write(targetFile.getAbsolutePath(), file.getBytes());
 				stringBuilder.append("成功上传文件至:");
 			} catch (IllegalStateException | IOException | ReportException e) {
 				logger.error("", e);

+ 1 - 1
src/main/java/com/uas/report/service/impl/PrintServiceImpl.java

@@ -602,7 +602,7 @@ public class PrintServiceImpl implements PrintService {
 		if (ArrayUtils.isEmpty(data) || pageSize == null) {
 			throw new ReportException("获取预览数据失败");
 		}
-		FileUtils.create(file.getPath(), data);
+		FileUtils.write(file.getPath(), data);
 		return pageSize;
 	}
 

+ 3 - 3
src/main/java/com/uas/report/util/FileUtils.java

@@ -23,14 +23,14 @@ public class FileUtils {
 	private static final Logger logger = LoggerFactory.getLogger(FileUtils.class);
 
 	/**
-	 * 创建文件
+	 * 写入文件
 	 * 
 	 * @param filePath
 	 *            文件路径
 	 * @param data
 	 *            数据
 	 */
-	public static void create(String filePath, byte[] data) {
+	public static void write(String filePath, byte[] data) {
 		if (StringUtils.isEmpty(filePath) || ArrayUtils.isEmpty(data)) {
 			throw new ReportException("参数不能为空:filePath,data");
 		}
@@ -42,7 +42,7 @@ public class FileUtils {
 			FileOutputStream fos = new FileOutputStream(file);
 			fos.write(data);
 			fos.flush();
-			logger.info("Created... " + file.getPath());
+			logger.info("Writed... " + file.getPath());
 			fos.close();
 		} catch (IOException e) {
 			throw new ReportException(e).setDetailedMessage(e);