public Details newTransientDetails(IObject object) throws ApiUsageException, SecurityViolation { return choose().newTransientDetails(object); }
@RolesAllowed("user") @Transactional(readOnly = false) public <T extends IEnum> T createEnumeration(T newEnum) { final LocalUpdate up = iUpdate; // TODO should this belong to root? Details d = getSecuritySystem().newTransientDetails(newEnum); newEnum.getDetails().copy(d); worldReadable(newEnum); return getSecuritySystem().doAction(new SecureAction() { public IObject updateObject(IObject... iObjects) { return up.saveAndReturnObject(iObjects[0]); } }, newEnum); }
public long createExperimenter(Experimenter experimenter, ExperimenterGroup defaultGroup, ExperimenterGroup... otherGroups) { Session session = sf.getSession(); SecureAction action = new SecureMerge(session); Experimenter e = copyUser(experimenter); if (isIgnoreCaseLookup()) { e.setOmeName(e.getOmeName().toLowerCase()); } e.getDetails().copy(sec.newTransientDetails(e)); e = sec.doAction(action, e); session.flush(); linkGroupAndUser(defaultGroup, e, false); if (null != otherGroups) { for (ExperimenterGroup group : otherGroups) { linkGroupAndUser(group, e, false); } } return e.getId(); }
protected GroupExperimenterMap linkGroupAndUser(ExperimenterGroup group, Experimenter e, boolean owned) { if (group == null || group.getId() == null) { throw new ApiUsageException("Group must be persistent."); } group = new ExperimenterGroup(group.getId(), false); // ticket:1021 - check for already added groups for (GroupExperimenterMap link : e.unmodifiableGroupExperimenterMap()) { ExperimenterGroup test = link.parent(); if (test.getId().equals(group.getId())) { return link; // EARLY EXIT! } } GroupExperimenterMap link = e.linkExperimenterGroup(group); // ticket:1434 link.setOwner(owned); link.getDetails().copy(sec.newTransientDetails(link)); Session session = sf.getSession(); sec.<IObject> doAction(new SecureMerge(session), userById(e.getId(), session), link); session.flush(); return link; }
newJob.getDetails().copy(sec.newTransientDetails(newJob)); newJob = secureSave(newJob);
protected ExperimenterGroup copyGroup(ExperimenterGroup g) { if (g.getName() == null) { throw new ValidationException("Group name may not be null."); } ExperimenterGroup copy = new ExperimenterGroup(); copy.setDescription(g.getDescription()); copy.setName(g.getName()); copy.setLdap(g.getLdap()); copy.setConfig(g.getConfig()); copy.getDetails().copy(sec.newTransientDetails(g)); copy.getDetails().setPermissions(g.getDetails().getPermissions()); // TODO see shallow copy comment on copy user return copy; }