public void updatePriorityCoefficient(PerunSession sess, Integer userId, Double rank) throws CabinetException { try { // get definition AttributeDefinition attrDef = perun.getAttributesManager().getAttributeDefinition(cabinetSession, ATTR_COEF_NAMESPACE+":"+ATTR_COEF_FRIENDLY_NAME); // Set attribute value Attribute attr = new Attribute(attrDef); DecimalFormat twoDForm = new DecimalFormat("#.##"); attr.setValue(String.valueOf(twoDForm.format(rank))); // get user User user = perun.getUsersManager().getUserById(cabinetSession, userId); // assign or update user's attribute perun.getAttributesManager().setAttribute(cabinetSession, user, attr); } catch (PerunException e) { throw new CabinetException("Failed to update priority coefficient in Perun.",ErrorCodes.PERUN_EXCEPTION, e); } }
perun.getAttributesManager().setAttribute(session, user, manualExpirationAttr);
Attribute eduroamIdentities = perun.getAttributesManager().getAttribute(session, user, "urn:perun:user:attribute-def:def:eduroamIdentities"); Attribute loginMu = perun.getAttributesManager().getAttribute(session, user, "urn:perun:user:attribute-def:def:login-namespace:mu");
AttributeDefinition attrDef = perun.getAttributesManager().getAttributeDefinition(cabinetSession, ATTR_PUBS_NAMESPACE + ":" + ATTR_PUBS_FRIENDLY_NAME); Attribute attr = new Attribute(attrDef); perun.getAttributesManager().setAttribute(cabinetSession, u, attr); } else { perun.getAttributesManager().removeAttribute(cabinetSession, u, attrDef);
try { attrDef = perun.getAttributesManager().getAttributeDefinition(cabinetSession,ATTR_COEF_NAMESPACE+":"+ATTR_COEF_FRIENDLY_NAME); } catch (AttributeNotExistsException e) { try { attrDef = perun.getAttributesManager().createAttribute(cabinetSession, attributeDefinition); perun.getAttributesManager().setAttributeRights(cabinetSession, rights); } catch (PerunException pe) { log.error("Failed to create attribute "+ ATTR_COEF_NAMESPACE+":"+ATTR_COEF_FRIENDLY_NAME +" in Perun."); try { attrDef2 = perun.getAttributesManager().getAttributeDefinition(cabinetSession,ATTR_PUBS_NAMESPACE+":"+ATTR_PUBS_FRIENDLY_NAME); } catch (AttributeNotExistsException e) { attributeDefinition.setType(ATTR_PUBS_TYPE); try { attrDef2 = perun.getAttributesManager().createAttribute(cabinetSession, attributeDefinition); perun.getAttributesManager().setAttributeRights(cabinetSession, rights); } catch (PerunException pe) { log.error("Failed to create attribute "+ ATTR_PUBS_NAMESPACE+":"+ATTR_PUBS_FRIENDLY_NAME +" in Perun.");
/** * Init method, instantiate PerunSession * * @throws PerunException */ protected void initialize() throws PerunException { // gets session for a system principal "perunRegistrar" final PerunPrincipal pp = new PerunPrincipal("perunRegistrar", ExtSourcesManager.EXTSOURCE_NAME_INTERNAL, ExtSourcesManager.EXTSOURCE_INTERNAL); registrarSession = perun.getPerunSession(pp, new PerunClient()); this.attrManager = perun.getAttributesManager(); this.membersManager = perun.getMembersManager(); this.usersManager = perun.getUsersManager(); this.groupsManager = perun.getGroupsManager(); }
this.attrManager = perun.getAttributesManager(); this.membersManager = perun.getMembersManager(); this.groupsManager = perun.getGroupsManager(); perun.getAttributesManager().setAttributeRights(registrarSession, rights); perun.getAttributesManager().setAttributeRights(registrarSession, rights); rights.add(new AttributeRights(attrDef.getId(), Role.VOADMIN, Arrays.asList(ActionType.READ, ActionType.WRITE))); rights.add(new AttributeRights(attrDef.getId(), Role.GROUPADMIN, Arrays.asList(ActionType.READ, ActionType.WRITE))); perun.getAttributesManager().setAttributeRights(registrarSession, rights); rights.add(new AttributeRights(attrDef.getId(), Role.VOADMIN, Arrays.asList(ActionType.READ, ActionType.WRITE))); rights.add(new AttributeRights(attrDef.getId(), Role.GROUPADMIN, Arrays.asList(ActionType.READ, ActionType.WRITE))); perun.getAttributesManager().setAttributeRights(registrarSession, rights); perun.getAttributesManager().setAttributeRights(registrarSession, rights); rights.add(new AttributeRights(attrDef.getId(), Role.VOADMIN, Arrays.asList(ActionType.READ, ActionType.WRITE))); rights.add(new AttributeRights(attrDef.getId(), Role.GROUPADMIN, Arrays.asList(ActionType.READ, ActionType.WRITE))); perun.getAttributesManager().setAttributeRights(registrarSession, rights); perun.getAttributesManager().setAttributeRights(registrarSession, rights); rights.add(new AttributeRights(attrDef.getId(), Role.VOADMIN, Arrays.asList(ActionType.READ, ActionType.WRITE))); rights.add(new AttributeRights(attrDef.getId(), Role.GROUPADMIN, Arrays.asList(ActionType.READ, ActionType.WRITE))); perun.getAttributesManager().setAttributeRights(registrarSession, rights); perun.getAttributesManager().setAttributeRights(registrarSession, rights);