do not lock resource if entity object does not exist
[pithos] / src / gr / ebs / gss / server / ejb / ExternalAPI.java
index 2634c21..454b359 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2007, 2008, 2009 Electronic Business Systems Ltd.
+ * Copyright 2007, 2008, 2009, 2010 Electronic Business Systems Ltd.
  *
  * This file is part of GSS.
  *
@@ -21,11 +21,18 @@ package gr.ebs.gss.server.ejb;
 import gr.ebs.gss.client.exceptions.DuplicateNameException;
 import gr.ebs.gss.client.exceptions.GSSIOException;
 import gr.ebs.gss.client.exceptions.InsufficientPermissionsException;
+import gr.ebs.gss.client.exceptions.InvitationUsedException;
 import gr.ebs.gss.client.exceptions.ObjectNotFoundException;
 import gr.ebs.gss.client.exceptions.QuotaExceededException;
+import gr.ebs.gss.server.domain.FileHeader;
 import gr.ebs.gss.server.domain.FileUploadStatus;
+import gr.ebs.gss.server.domain.FileLock;
+import gr.ebs.gss.server.domain.Invitation;
 import gr.ebs.gss.server.domain.Nonce;
 import gr.ebs.gss.server.domain.User;
+import gr.ebs.gss.server.domain.UserClass;
+import gr.ebs.gss.server.domain.UserLogin;
+import gr.ebs.gss.server.domain.WebDavNonce;
 import gr.ebs.gss.server.domain.dto.FileBodyDTO;
 import gr.ebs.gss.server.domain.dto.FileHeaderDTO;
 import gr.ebs.gss.server.domain.dto.FolderDTO;
@@ -45,6 +52,8 @@ import javax.ejb.Local;
 import javax.ejb.TransactionAttribute;
 import javax.ejb.TransactionAttributeType;
 
+import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
+
 /**
  * The External API for GSS clients.
  *
@@ -249,6 +258,7 @@ public interface ExternalAPI {
         * @param userId the ID of the current user
         * @param folderId the ID of the folder to retrieve
         * @param folderName
+        * @param readForAll
         * @param permissions
         * @return the updated folder
         * @throws InsufficientPermissionsException if the user does not have the
@@ -258,7 +268,9 @@ public interface ExternalAPI {
         * @throws DuplicateNameException if the specified name already exists in
         *             the parent folder, as either a folder or file
         */
-       public FolderDTO updateFolder(Long userId, Long folderId, String folderName, Set<PermissionDTO> permissions)
+       public FolderDTO updateFolder(Long userId, Long folderId, String folderName,
+                               Boolean readForAll,
+                               Set<PermissionDTO> permissions)
                        throws InsufficientPermissionsException, ObjectNotFoundException, DuplicateNameException;
 
        /**
@@ -335,19 +347,6 @@ public interface ExternalAPI {
        public void deleteFile(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
 
        /**
-        * Deletes the specified file in the specified user's namespace.
-        *
-        * @param userId the ID of the current user
-        * @param fileIds the IDs of the files to delete
-        * @throws ObjectNotFoundException if the user or file was not found, with
-        *             the exception message mentioning the precise problem
-        * @throws InsufficientPermissionsException if the user does not have the
-        *             appropriate privileges
-        */
-       public void deleteFiles(Long userId, List<Long> fileIds)
-                       throws ObjectNotFoundException, InsufficientPermissionsException;
-
-       /**
         * Creates a new tag for the specified user and file.
         *
         * @param userId the creator of the tag
@@ -638,31 +637,6 @@ public interface ExternalAPI {
        public void removeFileFromTrash(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
 
        /**
-        * Marks  the specified files as deleted in the specified user's namespace.
-        *
-        * @param userId the ID of the current user
-        * @param fileIds the IDs of the file to delete
-        * @throws ObjectNotFoundException if the user or file was not found, with
-        *             the exception message mentioning the precise problem
-        * @throws InsufficientPermissionsException if the user does not have the
-        *             appropriate privileges
-        */
-       public void moveFilesToTrash(Long userId, List<Long> fileIds)
-                       throws ObjectNotFoundException, InsufficientPermissionsException;
-
-       /**
-        * Marks  the specified deleted files as undeleted in the specified user's namespace.
-        *
-        * @param userId the ID of the current user
-        * @param fileIds the IDs of the file to undelete
-        * @throws ObjectNotFoundException if the user or file was not found, with
-        *             the exception message mentioning the precise problem
-        * @throws InsufficientPermissionsException if the user does not have the
-        *             appropriate privileges
-        */
-       public void removeFilesFromTrash(Long userId, List<Long> fileIds) throws ObjectNotFoundException, InsufficientPermissionsException;
-
-       /**
         * Marks  the specified folder as deleted in the specified user's namespace.
         *
         * @param userId the ID of the current user
@@ -828,28 +802,18 @@ public interface ExternalAPI {
         * Create a new user with the specified name, username and e-mail address.
         *
         * @param username the username of the new user
-        * @param name the full name of the new user
+        * @param name the name of the new user
         * @param mail the e-mail of the new user
+        * @param idp the IdP of the new user
+        * @param idpid the IdP identifier of the new user
         * @return the newly-created User object
         * @throws DuplicateNameException if a user with the same username already exists
         * @throws ObjectNotFoundException if no username was provided
         */
-       public User createUser(String username, String name, String mail)
+       public User createUser(String username, String name, String mail, String idp, String idpid)
                        throws DuplicateNameException, ObjectNotFoundException;
 
        /**
-        * Update the user with the specified username with the provided name
-        * and e-mail address.
-        *
-        * @param username the username of the user
-        * @param name the modified full name of the user
-        * @param mail the modified e-mail of the user
-        * @return the updated User object
-        * @throws ObjectNotFoundException if no username was provided
-        */
-       public User updateUser(String username, String name, String mail) throws ObjectNotFoundException;
-
-       /**
         * Updates the authentication token for the specified user.
         *
         * @param userId the ID of the user whose token should be updated
@@ -992,7 +956,7 @@ public interface ExternalAPI {
         * @return list of files that match query
         * @throws ObjectNotFoundException if no user or query was specified
         */
-       public List<FileHeaderDTO> searchFiles(Long userId, String query) throws ObjectNotFoundException;
+       public List<FileHeader> searchFiles(Long userId, String query) throws ObjectNotFoundException;
 
        /**
         * Creates a nonce for the specified user.
@@ -1072,20 +1036,6 @@ public interface ExternalAPI {
                        throws ObjectNotFoundException, InsufficientPermissionsException,  GSSIOException, QuotaExceededException;
 
        /**
-        * Remove file version identified by bodyId
-        *
-        * @param userId the ID of the user
-        * @param fileId the ID of the file
-        * @param bodyId the ID of the body
-        *
-        * @throws ObjectNotFoundException
-        * @throws InsufficientPermissionsException
-        *
-        */
-       public void removeVersion(Long userId, Long fileId, Long bodyId)
-                       throws ObjectNotFoundException, InsufficientPermissionsException;
-
-       /**
         * Removes all old file versions for specified file keeping only the current revision
         *
         * @param userId the ID of the user
@@ -1101,9 +1051,14 @@ public interface ExternalAPI {
        /**
         * It is used by the Solr mbean to rebuild the index.
         */
-       public void rebuildSolrIndex();
+       public String rebuildSolrIndex();
 
        /**
+        * It is used by the Solr mbean to refresh the index. It does not delete anything just re-add everything in the index
+        */
+       public String refreshSolrIndex();
+       
+       /**
         * Creates a new file with the specified owner, parent folder and name. The
         * new file has the same permissions as its parent folder. The file contents
         * are already uploaded outside of externalAPI and the uploaded file is used as a parameter.
@@ -1219,4 +1174,133 @@ public interface ExternalAPI {
         */
        public String resetWebDAVPassword(Long userId) throws ObjectNotFoundException;
 
+       /**
+        * Find the invite for the specified invitation code.
+        *
+        * @param code the invitation code
+        * @return the Invitation or null if not found
+        */
+       public Invitation findInvite(String code);
+
+       /**
+        * Create a new user in the connected IdP.
+        *
+        * @param username the username of the new user
+        * @param firstname the first name of the new user
+        * @param lastname the last name of the new user
+        * @param email the e-mail of the new user
+        * @param password the password of the new user
+        */
+       public void createLdapUser(String username, String firstname, String lastname, String email, String password);
+
+       /**
+        * Retrieves the available user classes.
+        */
+       public List<UserClass> getUserClasses();
+
+       /**
+        * Upgrades the user class to the default "coupon bearer" class and marks
+        * the provided coupon as used.
+        *
+        * @param username the username of the user
+        * @param code the coupon code
+        * @return the new user class
+        * @throws InvitationUsedException when trying to reuse an already used invitation
+        * @throws ObjectNotFoundException if the user was not found
+        */
+       public UserClass upgradeUserClass(String username, String code)
+                       throws ObjectNotFoundException, InvitationUsedException;
+
+       /**
+        * Retrieve the user class for coupon-bearing users.
+        */
+       public UserClass getCouponUserClass();
+
+       /**
+        * Delete the actual file in the specified file system path.
+        */
+       public void deleteActualFile(String path);
+       
+       /**
+        * Update the userLogin with the values from the supplied object.
+        */
+       public void addUserLogin(UserLogin userLogin);
+       
+       /**
+        * Retrieves the user's current session login and the user's last login
+        * @param userId
+        * @return a list of last two user logins
+        * @throws ObjectNotFoundException 
+        */
+       public List<UserLogin> getLastUserLogins(Long userId) throws ObjectNotFoundException;
+
+       /**
+        * Posts the file specified by id to solr indexing server
+        *
+     * @param solr
+        * @param id
+        */
+       public void postFileToSolr(CommonsHttpSolrServer solr, Long id);
+
+       /**
+        * @param username
+        * @return
+        */
+       UserDTO getUserByUserName(String username);
+
+       /**
+        * @param lock
+        * @return
+        */
+       FileLock saveOrUpdateLock(FileLock lock);
+
+       /**
+        * @param lock
+        */
+       void removeLock(FileLock lock);
+
+       /**
+        * @param tokenId
+        * @return
+        */
+       FileLock getLockByToken(String tokenId);
+
+       /**
+        * @param id
+        * @return
+        */
+       FileLock getLockById(String id);
+
+       /**
+        * @param userId
+        * @param folderId
+        * @param name
+        * @return
+        * @throws DuplicateNameException
+        * @throws ObjectNotFoundException
+        * @throws GSSIOException
+        * @throws InsufficientPermissionsException
+        * @throws QuotaExceededException
+        */
+       FileHeaderDTO createEmptyFile(Long userId, Long folderId, String name) throws DuplicateNameException, ObjectNotFoundException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
+
+       /**
+        * @param nonce
+        * @return
+        */
+       WebDavNonce saveOrUpdateWebDavNonce(WebDavNonce nonce);
+
+       /**
+        * @param nonce
+        */
+       void removeWebDavNonce(WebDavNonce nonce);
+
+       /**
+        * @param tokenId
+        * @return
+        */
+       WebDavNonce getWebDavNonce(String tokenId);
+       
+
+
 }