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
}
}
- @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
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
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
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>
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
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);
}