*/
private static final long serialVersionUID = 185_781_756_712_969L;
+ /**
+ * Address book instance
+ */
+ private Addressbook addressbook;
+
/**
* Remote address book bean
*/
}
// Create address book instance with name
- Addressbook addressbook = new UserAddressbook(this.getAddressbookName());
+ Addressbook book = new UserAddressbook(this.getAddressbookName());
// Set default status to UNLOCKED and owner
- addressbook.setAddressbookStatus(AddressbokStatus.UNLOCKED);
- addressbook.setAddressbookUser(this.loginController.getLoggedInUser());
- addressbook.setAddressbookCreated(new GregorianCalendar());
+ book.setAddressbookStatus(AddressbokStatus.UNLOCKED);
+ book.setAddressbookUser(this.loginController.getLoggedInUser());
+ book.setAddressbookCreated(new GregorianCalendar());
try {
// Register this address book
- Addressbook updatedAddressbook = this.addressbookBean.createAddressbook(addressbook);
+ Addressbook updatedAddressbook = this.addressbookBean.createAddressbook(book);
// Remove name
this.setAddressbookName(null);
// event should not be null
if (null == event) {
// Throw NPE
- throw new NullPointerException("event is null");
+ throw new NullPointerException("event is null"); //NOI18N
} else if (event.getAddressbook() == null) {
// Throw NPE again
- throw new NullPointerException("event.addressbook is null");
+ throw new NullPointerException("event.addressbook is null"); //NOI18N
} else if (event.getAddressbook().getAddressbookId() == null) {
// And again a NPE
- throw new NullPointerException("event.addressbook.addressbookId is null");
+ throw new NullPointerException("event.addressbook.addressbookId is null"); //NOI18N
} else if (event.getAddressbook().getAddressbookId() < 1) {
// Invalid id number
- throw new IllegalArgumentException("Address book instance " + event.getAddressbook() + " has invalid id number: " + event.getAddressbook().getAddressbookId());
+ throw new IllegalArgumentException(MessageFormat.format("Address book instance {0} has invalid id number: {1}", event.getAddressbook(), event.getAddressbook().getAddressbookId())); //NOI18N
} else if (event.getAddressbook().getAddressbookUser() == null) {
// One more NPE ...
- throw new NullPointerException("event.addressbook.addressbookUser is null");
+ throw new NullPointerException("event.addressbook.addressbookUser is null"); //NOI18N
}
// Get address book instance
- Addressbook addressbook = event.getAddressbook();
+ Addressbook book = event.getAddressbook();
// Set address book data
- this.setAddressbookId(addressbook.getAddressbookId());
- this.setAddressbookName(addressbook.getAddressbookName());
- this.setAddressbookUser(addressbook.getAddressbookUser());
- this.setAddressbookCreated(addressbook.getAddressbookCreated());
+ this.setAddressbookId(book.getAddressbookId());
+ this.setAddressbookName(book.getAddressbookName());
+ this.setAddressbookUser(book.getAddressbookUser());
+ this.setAddressbookCreated(book.getAddressbookCreated());
+
+ // And instance ...
+ this.setAddressbook(book);
}
@Override
// Is the user logged in?
if (null == event) {
// Is null
- throw new NullPointerException("event is null");
+ throw new NullPointerException("event is null"); //NOI18N
} else if (event.getUser() == null) {
// user is null
- throw new NullPointerException("event.user is null");
+ throw new NullPointerException("event.user is null"); //NOI18N
} else if (!event.getUser().equals(this.loginController.getLoggedInUser())) {
// Not matching
- throw new IllegalStateException("event.user and loginController.loggedInUser don't match.");
+ throw new IllegalStateException("event.user and loginController.loggedInUser don't match."); //NOI18N
} else 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 List<User> allUsersNotSharing () {
+ // 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
+ }
+
+ // Call EJB
+ return this.addressbookBean.allUsersNotSharing(this.loginController.getLoggedInUser(), this.getAddressbook());
+ }
+
@Override
public Integer countAllUserSharedAddressbooks (final User user) {
// Is there cache?
return count;
}
+ @Override
+ public Addressbook getAddressbook () {
+ return this.addressbook;
+ }
+
+ @Override
+ public void setAddressbook (final Addressbook addressbook) {
+ this.addressbook = addressbook;
+ }
+
@Override
public Calendar getAddressbookCreated () {
return this.addressbookCreated;
boolean isFound = false;
// Check all entries
- for (final Addressbook addressbook : this.usersAddressbooks) {
+ for (final Addressbook book : this.usersAddressbooks) {
// Is the name same?
- if (addressbook.getAddressbookName().equals(addressbookName)) {
+ if (book.getAddressbookName().equals(addressbookName)) {
// Found a match
isFound = true;
break;
*/
private void initAddressbookList () {
// Fill list with entries
- this.usersAddressbooks = this.addressbookBean.getUsersList(this.loginController.getLoggedInUser());
+ this.usersAddressbooks = this.addressbookBean.getUsersAddressbookList(this.loginController.getLoggedInUser());
}
}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://xmlns.jcp.org/jsf/html"
+ xmlns:f="http://xmlns.jcp.org/jsf/core"
+ >
+
+ <f:metadata>
+ <f:viewParam id="addressbookId" name="addressbook_id" value="#{addressbookController.addressbookId}" required="true" requiredMessage="#{msg.PARAMETER_ADDRESSBOOK_ID_MISSING}" converterMessage="#{msg.PARAMETER_ADDRESSBOOK_ID_INVALID}" validatorMessage="#{msg.PARAMETER_ADDRESSBOOK_ID_NOT_FOUND}">
+ <f:convertNumber for="addressbookId" type="number" minIntegerDigits="1" maxIntegerDigits="20" />
+ <f:validator for="addressbookId" validatorId="AddressbookIdValidator" />
+ </f:viewParam>
+ </f:metadata>
+
+ <ui:composition template="/WEB-INF/templates/login/login_base.tpl">
+ <ui:define name="login_title">#{msg.PAGE_TITLE_LOGIN_START_SHARING_ADDRESSBOOK}</ui:define>
+
+ <ui:define name="content_header">
+ #{msg.CONTENT_TITLE_LOGIN_START_SHARING_ADDRESSBOOK}
+ </ui:define>
+
+ <ui:define name="content">
+ <div class="table_big">
+
+ <div class="table_header">
+ #{msg.TABLE_HEADER_CHOOSE_USER_FOR_SHARING}
+ </div>
+
+ <div class="para">
+ <h:dataTable id="userList" headerClass="table_header_column" var="user" value="#{addressbookController.allUsersNotSharing()}">
+ <h:column>
+ <f:facet name="header">#{msg.USER_ID}</f:facet>
+ <h:link outcome="user_profile" title="#{msg.LINK_USER_PROFILE_TITLE}" value="#{msg.LINK_USER_PROFILE}">
+ <f:param id="userId" name="userId" value="#{user.userId}" />
+ </h:link>
+ </h:column>
+
+ <h:column>
+ <f:facet name="header">#{msg.USER_NAME}</f:facet>
+ <h:outputText value="#{user.userName}" />
+ </h:column>
+
+ <h:column>
+ <f:facet name="header">#{msg.LOGIN_START_SHARING_TITLE}</f:facet>
+ <h:form acceptcharset="utf-8" id="startSharing">
+ <h:commandButton class="submit" id="submit" value="#{msg.LOGIN_START_SHARING_BUTTON}" action="#{addressbookController.startSharing(user)}" title="#{msg.LOGIN_START_SHARING_BUTTON_TITLE}" />
+ </h:form>
+ </h:column>
+ </h:dataTable>
+ </div>
+
+ <div class="table_footer">
+ <ul>
+ <li>#{msg.LOGIN_START_SHARING_NOTICE1}</li>
+ <li>#{msg.LOGIN_START_SHARING_NOTICE2}</li>
+ </ul>
+ </div>
+ </div>
+ </ui:define>
+ </ui:composition>
+</html>