}
@Override
public void createEntity(ActionMessages errors, EditLoadForm form, Hashtable<String, Object> attributes, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
UserVO activeUser = (UserVO) request.getSession().getAttribute(Globals.USER_KEY);
ContactVO contact = new ContactVO();
contact.setContactTimestamp(new Date());
contact.setAccessUser(EntityAccess.Access.WRITE_SYSTEM);
contact.setOwnerUser(activeUser.getId());
contact.setAccessGroup(EntityAccess.Access.NONE);
contact.setOwnerGroup(activeUser.getProfile().getDefaultUsergroup().getId());
contact.setAccessGlobal(EntityAccess.Access.WRITE_SYSTEM);
EditPanel lastPanel = (EditPanel)Panel.getPanelStack(request).peek();
if(lastPanel.getEntity() instanceof CompanyVO)
{
if (log.isDebugEnabled())
log.debug("contact for company");
CompanyVO company = (CompanyVO) lastPanel.getEntity();
contact.setCompany(company);
}
else if(lastPanel.getEntity() instanceof PersonVO)
{
if (log.isDebugEnabled())
log.debug("contact for person");
PersonVO person = (PersonVO)lastPanel.getEntity();
contact.getPersonContacts().add(new PersonContactVO(person, contact));
}
else
{
log.error("unknown entity foundin panel: "+lastPanel);
}
// add own user by default
if(activeUser.getPerson() != null) {
PersonVO person = activeUser.getPerson();
boolean containsPerson = false;
for(PersonContactVO personContact : contact.getPersonContacts()) {
if(person.equals(personContact.getPerson())) {
containsPerson = true;
}