]> git.mxchange.org Git - addressbook-war.git/commitdiff
sorted members
authorRoland Haeder <roland@mxchange.org>
Fri, 16 Oct 2015 09:30:22 +0000 (11:30 +0200)
committerRoland Haeder <roland@mxchange.org>
Fri, 16 Oct 2015 09:30:22 +0000 (11:30 +0200)
Signed-off-by:Roland Häder <roland@mxchange.org>

src/java/org/mxchange/addressbook/beans/shares/SharesWebBean.java
src/java/org/mxchange/addressbook/beans/shares/SharesWebController.java

index 809c4392145d7fa146384c94f8c541f6106adb8f..c98cbfcbfa6e901cf8b1b4d1b8b2ec8569ce9b2b 100644 (file)
@@ -72,14 +72,14 @@ public class SharesWebBean implements SharesWebController {
        private ShareableAddressbook share;
 
        /**
-        * A list of all user's shared (with others) address books
+        * Remote bean for sharing address books
         */
-       private List<ShareableAddressbook> sharedAddressbooks;
+       private SharedAddressbooksSessionBeanRemote shareBean;
 
        /**
-        * Remote bean for sharing address books
+        * A list of all user's shared (with others) address books
         */
-       private SharedAddressbooksSessionBeanRemote shareBean;
+       private List<ShareableAddressbook> sharedAddressbooks;
 
        /**
         * User id of sharee
@@ -110,10 +110,61 @@ public class SharesWebBean implements SharesWebController {
                }
        }
 
-       @PostConstruct
-       public void init () {
-               // Init share list
-               this.sharedAddressbooks = this.shareBean.allSharedAddressbooks(this.loginController.getLoggedInUser());
+       @Override
+       public void afterAdressbookShareEnded (final @Observes AddressbookSharingEvent event) {
+               // Validate parameter
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getSharingType() != SharingType.ENDED) {
+                       // Wrong event
+                       return;
+               }
+
+               // Validate event
+               this.validateEvent(event);
+
+               // Add it to list
+               this.sharedAddressbooks.remove(event.getShareableAddressbook());
+       }
+
+       @Override
+       public void afterAdressbookShareStarted (final @Observes AddressbookSharingEvent event) {
+               // Validate parameter
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getSharingType() != SharingType.STARTED) {
+                       // Wrong event
+                       return;
+               }
+
+               // Validate event
+               this.validateEvent(event);
+
+               // Add it to list
+               this.sharedAddressbooks.add(event.getShareableAddressbook());
+       }
+
+       @Override
+       public List<ShareableAddressbook> allShares () {
+               // Is the user logged in?
+               if (!this.loginController.isUserLoggedIn()) {
+                       // Not logged in
+                       throw new FaceletException("This method can only be called as logged-in user."); //NOI18N
+               }
+
+               return Collections.unmodifiableList(this.sharedAddressbooks);
+       }
+
+       @Override
+       public ShareableAddressbook getShare () {
+               return this.share;
+       }
+
+       @Override
+       public void setShare (final ShareableAddressbook share) {
+               this.share = share;
        }
 
        @Override
@@ -126,9 +177,10 @@ public class SharesWebBean implements SharesWebController {
                this.shareeUserId = shareeUserId;
        }
 
-       @Override
-       public boolean isShareeUserIdSet () {
-               return ((this.getShareeUserId() instanceof Long) && (this.getShareeUserId() > 0));
+       @PostConstruct
+       public void init () {
+               // Init share list
+               this.sharedAddressbooks = this.shareBean.allSharedAddressbooks(this.loginController.getLoggedInUser());
        }
 
        @Override
@@ -136,6 +188,11 @@ public class SharesWebBean implements SharesWebController {
                return (!this.isShareeUserIdSet());
        }
 
+       @Override
+       public boolean isShareeUserIdSet () {
+               return ((this.getShareeUserId() instanceof Long) && (this.getShareeUserId() > 0));
+       }
+
        @Override
        public boolean isSharingAddressbooks () {
                // Only to be called for logged-in users
@@ -204,63 +261,6 @@ public class SharesWebBean implements SharesWebController {
                return null;
        }
 
-       @Override
-       public List<ShareableAddressbook> allShares () {
-               // Is the user logged in?
-               if (!this.loginController.isUserLoggedIn()) {
-                       // Not logged in
-                       throw new FaceletException("This method can only be called as logged-in user."); //NOI18N
-               }
-
-               return Collections.unmodifiableList(this.sharedAddressbooks);
-       }
-
-       @Override
-       public ShareableAddressbook getShare () {
-               return this.share;
-       }
-
-       @Override
-       public void setShare (final ShareableAddressbook share) {
-               this.share = share;
-       }
-
-       @Override
-       public void afterAdressbookShareStarted (final @Observes AddressbookSharingEvent event) {
-               // Validate parameter
-               if (null == event) {
-                       // Throw NPE
-                       throw new NullPointerException("event is null"); //NOI18N
-               } else if (event.getSharingType() != SharingType.STARTED) {
-                       // Wrong event
-                       return;
-               }
-
-               // Validate event
-               this.validateEvent(event);
-
-               // Add it to list
-               this.sharedAddressbooks.add(event.getShareableAddressbook());
-       }
-
-       @Override
-       public void afterAdressbookShareEnded (final @Observes AddressbookSharingEvent event) {
-               // Validate parameter
-               if (null == event) {
-                       // Throw NPE
-                       throw new NullPointerException("event is null"); //NOI18N
-               } else if (event.getSharingType() != SharingType.ENDED) {
-                       // Wrong event
-                       return;
-               }
-
-               // Validate event
-               this.validateEvent(event);
-
-               // Add it to list
-               this.sharedAddressbooks.remove(event.getShareableAddressbook());
-       }
-
        /**
         * Validates given event for all values and throws exceptions
         * <p>
index 3a4196bfc1012190c2d76afcfe170efeb5beef1a..650e27f95cc7a521ee0bf1b16cf9428f5be2a82a 100644 (file)
@@ -31,25 +31,25 @@ import org.mxchange.jusercore.model.user.User;
 public interface SharesWebController extends Serializable {
 
        /**
-        * Checks wether the current user is sharing address books with others
+        * Observer method for ended sharing events
         * <p>
-        * @return Whether the current user is sharing address books
+        * @param event Event instance
         */
-       boolean isSharingAddressbooks ();
+       void afterAdressbookShareEnded (final AddressbookSharingEvent event);
 
        /**
-        * Getter for sharee's user id
+        * Observer method for started sharing events
         * <p>
-        * @return Sharee's user id
+        * @param event Event instance
         */
-       Long getShareeUserId ();
+       void afterAdressbookShareStarted (final AddressbookSharingEvent event);
 
        /**
-        * Setter for sharee's user id
+        * Returns a list of all address books the user is sharing with others.
         * <p>
-        * @param shareeUserId Sharee's user id
+        * @return List of all shared address books
         */
-       void setShareeUserId (final Long shareeUserId);
+       List<ShareableAddressbook> allShares ();
 
        /**
         * Getter for share instance
@@ -66,47 +66,47 @@ public interface SharesWebController extends Serializable {
        void setShare (final ShareableAddressbook share);
 
        /**
-        * Checks whether the sharee's user id is set
+        * Getter for sharee's user id
         * <p>
-        * @return Whether the sharee's user id is set
+        * @return Sharee's user id
         */
-       boolean isShareeUserIdSet ();
+       Long getShareeUserId ();
 
        /**
-        * Checks if the sharee's user id is empty.
+        * Setter for sharee's user id
         * <p>
-        * @return Whether the sharee's user id is empty.
+        * @param shareeUserId Sharee's user id
         */
-       boolean isShareeUserIdEmpty ();
+       void setShareeUserId (final Long shareeUserId);
 
        /**
-        * Starts an address book share between currently logged-in user and
-        * assigned user for current address book.
+        * Checks if the sharee's user id is empty.
         * <p>
-        * @param user User instance
-        * @param addressbook Address book instance
-        * @return Redirect target
+        * @return Whether the sharee's user id is empty.
         */
-       String startSharing (final User user, final Addressbook addressbook);
+       boolean isShareeUserIdEmpty ();
 
        /**
-        * Returns a list of all address books the user is sharing with others.
+        * Checks whether the sharee's user id is set
         * <p>
-        * @return List of all shared address books
+        * @return Whether the sharee's user id is set
         */
-       List<ShareableAddressbook> allShares ();
+       boolean isShareeUserIdSet ();
 
        /**
-        * Observer method for started sharing events
+        * Checks wether the current user is sharing address books with others
         * <p>
-        * @param event Event instance
+        * @return Whether the current user is sharing address books
         */
-       void afterAdressbookShareStarted (final AddressbookSharingEvent event);
+       boolean isSharingAddressbooks ();
 
        /**
-        * Observer method for ended sharing events
+        * Starts an address book share between currently logged-in user and
+        * assigned user for current address book.
         * <p>
-        * @param event Event instance
+        * @param user User instance
+        * @param addressbook Address book instance
+        * @return Redirect target
         */
-       void afterAdressbookShareEnded (final AddressbookSharingEvent event);
+       String startSharing (final User user, final Addressbook addressbook);
 }