better matching of MS Office mime types (in showing file icons and indexing)
[pithos] / src / gr / ebs / gss / server / ejb / ExternalAPIBean.java
index 6d9caef..b6b90b8 100644 (file)
@@ -264,7 +264,7 @@ public class ExternalAPIBean implements ExternalAPI, ExternalAPIRemote {
        }
 
        @Override
        }
 
        @Override
-       public void createFolder(Long userId, Long parentId, String name)
+       public FolderDTO createFolder(Long userId, Long parentId, String name)
                        throws DuplicateNameException, ObjectNotFoundException, InsufficientPermissionsException {
                // Validate.
                if (userId == null)
                        throws DuplicateNameException, ObjectNotFoundException, InsufficientPermissionsException {
                // Validate.
                if (userId == null)
@@ -291,7 +291,7 @@ public class ExternalAPIBean implements ExternalAPI, ExternalAPIRemote {
                                        " to write to this folder");
 
                // Do the actual work.
                                        " to write to this folder");
 
                // Do the actual work.
-               createFolder(name, parent, creator);
+               return createFolder(name, parent, creator);
        }
 
        /**
        }
 
        /**
@@ -300,8 +300,9 @@ public class ExternalAPIBean implements ExternalAPI, ExternalAPIRemote {
         * @param name
         * @param parent
         * @param creator
         * @param name
         * @param parent
         * @param creator
+        * @return the new folder
         */
         */
-       private void createFolder(String name, Folder parent, User creator) {
+       private FolderDTO createFolder(String name, Folder parent, User creator) {
                Folder folder = new Folder();
                folder.setName(name);
                if (parent != null) {
                Folder folder = new Folder();
                folder.setName(name);
                if (parent != null) {
@@ -337,6 +338,7 @@ public class ExternalAPIBean implements ExternalAPI, ExternalAPIRemote {
                        folder.addPermission(permission);
                }
                dao.create(folder);
                        folder.addPermission(permission);
                }
                dao.create(folder);
+               return folder.getDTO();
        }
 
        /*
        }
 
        /*
@@ -406,7 +408,7 @@ public class ExternalAPIBean implements ExternalAPI, ExternalAPIRemote {
        }
 
        @Override
        }
 
        @Override
-       public void modifyFolder(Long userId, Long folderId, String folderName)
+       public FolderDTO modifyFolder(Long userId, Long folderId, String folderName)
                        throws InsufficientPermissionsException, ObjectNotFoundException, DuplicateNameException {
 
                // Validate.
                        throws InsufficientPermissionsException, ObjectNotFoundException, DuplicateNameException {
 
                // Validate.
@@ -430,6 +432,7 @@ public class ExternalAPIBean implements ExternalAPI, ExternalAPIRemote {
                // Do the actual modification.
                folder.setName(folderName);
                dao.update(folder);
                // Do the actual modification.
                folder.setName(folderName);
                dao.update(folder);
+               return folder.getDTO();
        }
 
        /*
        }
 
        /*
@@ -1081,7 +1084,7 @@ public class ExternalAPIBean implements ExternalAPI, ExternalAPIRemote {
        }
 
        @Override
        }
 
        @Override
-       public void moveFileToPath(Long userId, Long ownerId, Long fileId, String dest) throws ObjectNotFoundException, InsufficientPermissionsException, DuplicateNameException, GSSIOException, QuotaExceededException {
+       public void moveFileToPath(Long userId, Long ownerId, Long fileId, String dest) throws ObjectNotFoundException, InsufficientPermissionsException, QuotaExceededException {
                if (userId == null)
                        throw new ObjectNotFoundException("No user specified");
                if (ownerId == null)
                if (userId == null)
                        throw new ObjectNotFoundException("No user specified");
                if (ownerId == null)
@@ -1798,7 +1801,7 @@ public class ExternalAPIBean implements ExternalAPI, ExternalAPIRemote {
         * @see gr.ebs.gss.server.ejb.ExternalAPI#moveFiles(java.lang.Long, java.util.List, java.lang.Long)
         */
        @Override
         * @see gr.ebs.gss.server.ejb.ExternalAPI#moveFiles(java.lang.Long, java.util.List, java.lang.Long)
         */
        @Override
-       public void moveFiles(Long userId, List<Long> fileIds, Long destId) throws InsufficientPermissionsException, ObjectNotFoundException, DuplicateNameException, GSSIOException, QuotaExceededException {
+       public void moveFiles(Long userId, List<Long> fileIds, Long destId) throws InsufficientPermissionsException, ObjectNotFoundException, QuotaExceededException {
                for(Long l : fileIds){
                        FileHeader file = dao.getEntityById(FileHeader.class, l);
                        moveFile(userId, l, destId, file.getName());
                for(Long l : fileIds){
                        FileHeader file = dao.getEntityById(FileHeader.class, l);
                        moveFile(userId, l, destId, file.getName());
@@ -2298,6 +2301,16 @@ public class ExternalAPIBean implements ExternalAPI, ExternalAPIRemote {
                                return "application/vnd.ms-powerpoint";
                        else if (".pdf".equals(extension))
                                return "application/pdf";
                                return "application/vnd.ms-powerpoint";
                        else if (".pdf".equals(extension))
                                return "application/pdf";
+                       else if (".gif".equals(extension))
+                               return "image/gif";
+                       else if (".jpg".equals(extension) || ".jpeg".equals(extension) || ".jpe".equals(extension))
+                               return "image/jpeg";
+                       else if (".tiff".equals(extension) || ".tif".equals(extension))
+                               return "image/tiff";
+                       else if (".png".equals(extension))
+                               return "image/png";
+                       else if (".bmp".equals(extension))
+                               return "image/bmp";
                }
                // when all else fails assign the default mime type
                return DEFAULT_MIME_TYPE;
                }
                // when all else fails assign the default mime type
                return DEFAULT_MIME_TYPE;