/** Note that details is the only optional field */ public String createEntity(EntityReference ref, Object entity, Map<String, Object> params) { Poll poll = (Poll) entity; poll.setCreationDate(new Date()); if (poll.getId() == null) { poll.setId(UUID.randomUUID().toString()); } if (poll.getOwner() == null) { poll.setOwner(developerHelperService.getCurrentUserId()); } String siteId = developerHelperService.getCurrentLocationId(); if (poll.getSiteId() == null) { poll.setSiteId(siteId); } else { siteId = poll.getSiteId(); } String userReference = developerHelperService.getCurrentUserReference(); String location = "/site/" + siteId; boolean allowed = developerHelperService.isUserAllowedInEntityReference( userReference, PollListManager.PERMISSION_ADD, location); if (!allowed) { throw new SecurityException( "Current user (" + userReference + ") cannot create polls in location (" + location + ")"); } pollListManager.savePoll(poll); return poll.getPollId() + ""; }