public Response getUser(String identifier) throws SCIMException { log.debug("Calling SCIM REST method getUser by id {}", identifier); if (identifier == null) { throw new NullPointerException("identifier is null"); } try { User perunUser = perunBl.getUsersManagerBl().getUserById(session, Integer.parseInt(identifier)); ObjectMapper mapper = new ObjectMapper(); return Response.ok(mapper.writeValueAsString(mapPerunUserToScimUser(perunUser))).build(); } catch (InternalErrorException ex) { log.warn("Internal exception occured while getting user with id {}.", identifier); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } catch (UserNotExistsException ex) { log.warn("User with id {} does not exists.", identifier); return Response.status(Response.Status.NOT_FOUND).build(); } catch (IOException ex) { throw new SCIMException("Cannot convert user resource to json string", ex); } }
try { String userLocale = (String) perun.getAttributesManagerBl().getAttribute(session, perun.getUsersManagerBl() .getUserById(session, id), "urn:perun:user:attribute-def:def:preferredLanguage").getValue(); if (userLocale == null) {
private Author convertAuthorToAuthorWithAttributes(Author author) { try { if (session == null) { session = perun.getPerunSession(new PerunPrincipal("perunCabinet", ExtSourcesManager.EXTSOURCE_NAME_INTERNAL, ExtSourcesManager.EXTSOURCE_INTERNAL), new PerunClient()); } User user = perun.getUsersManagerBl().getUserById(session, author.getId()); Attribute a = perun.getAttributesManagerBl().getAttribute(session, user, AttributesManager.NS_USER_ATTR_DEF + ":preferredMail"); Attribute b = perun.getAttributesManagerBl().getAttribute(session, user, AttributesManager.NS_USER_ATTR_DEF + ":organization"); author.setAttributes(Arrays.asList(a,b)); } catch (Exception ex) { log.error("Unable to get attributes for {}: {}", author, ex); } return author; }
User user = perun.getUsersManagerBl().getUserById(session, id); Attribute emailAttribute = perun.getAttributesManagerBl().getAttribute(session, user, "urn:perun:user:attribute-def:def:preferredMail"); if (emailAttribute != null && StringUtils.hasText(emailAttribute.toString())) {
User user = perun.getUsersManagerBl().getUserById(session, id); Attribute emailAttribute = perun.getAttributesManagerBl().getAttribute(session, user, "urn:perun:user:attribute-def:def:jabber"); if (emailAttribute != null && StringUtils.hasText(emailAttribute.toString())) {
user = perun.getUsersManagerBl().getUserById(sess, userId); } catch (UserNotExistsException ex) { throw new CabinetException("User with ID: "+userId+" doesn't exists.", ErrorCodes.PERUN_EXCEPTION, ex);