@Override public String edit() { try { IContact contact = this.getAddressBookManager().getContact(this.getEntityId()); if (null == contact) { this.addFieldError( "contactKey", this.getText("*CONTATTO NULLO*")); // TODO LABEL DA MODIFICARE return INPUT; } if (!contact.isPublicContact() && !this.getCurrentUser().getUsername().equals(contact.getOwner())) { this.addFieldError( "contactKey", this.getText("*CONTATTO NON PUBBLICO NON AUTORIZZATO*")); // TODO LABEL DA MODIFICARE return INPUT; } contact .getContactInfo() .disableAttributes( JpaddressbookSystemConstants.ATTRIBUTE_DISABLING_CODE_ON_MANAGE_CONTACT); this.getRequest().getSession().setAttribute(SESSION_PARAM_NAME_CURRENT_CONTACT, contact); } catch (Throwable t) { ApsSystemUtils.logThrowable(t, this, "edit"); return FAILURE; } return SUCCESS; }
@Override public String save() { try { IContact contact = this.getContact(); if (contact == null) { return FAILURE; } if (null == contact.getId()) { this.getAddressBookManager().addContact(contact); } else { this.getAddressBookManager().updateContact(this.getCurrentUser().getUsername(), contact); } this.getRequest().getSession().removeAttribute(SESSION_PARAM_NAME_CURRENT_CONTACT); } catch (Throwable t) { ApsSystemUtils.logThrowable(t, this, "save"); return FAILURE; } return SUCCESS; }