    public Response createOrUpdateUser(@PathParam("U_ID") String urlSafeUserId, String username)
            throws DigitalLibraryException, ConflictException, ClassNotFoundException, IOException, NamingException,
            SQLException, pl.psnc.dl.wf4ever.dl.NotFoundException {
        String userId = new String(Base64.decodeBase64(urlSafeUserId));
        boolean updated = false;
        UserProfileDAO userProfileDAO = new UserProfileDAO();
        try {
            new URI(userId);
            UserProfile user = userProfileDAO.findByLogin(userId);
            if (user != null && username != null && !(user.getName().equals(username))) {
                updated = true;
            }
        } catch (URISyntaxException e) {
            LOGGER.warn("URI " + userId + " is not valid", e);
        }
        String password = UUID.randomUUID().toString().replaceAll("-", "").substring(0, 20);
        boolean created = DigitalLibraryFactory.getDigitalLibrary().createOrUpdateUser(userId, password,
            username != null && !username.isEmpty() ? username : userId);
        if (created) {
            return Response.created(uriInfo.getAbsolutePath()).build();
        } else {
            if (updated) {
                UserProfile user = userProfileDAO.findByLogin(userId);
                UpdateUserIndexThread updateThread = new UpdateUserIndexThread(ResearchObject.getAll(builder, user));
                updateThread.run();
            }
            return Response.ok().build();
        }
    }

    public Response createOrUpdateUser(@PathParam("U_ID") String urlSafeUserId, String username)
            throws DigitalLibraryException, ConflictException, ClassNotFoundException, IOException, NamingException,
            SQLException, pl.psnc.dl.wf4ever.dl.NotFoundException {
        String userId = new String(Base64.decodeBase64(urlSafeUserId));
        boolean updated = false;
        UserProfileDAO userProfileDAO = new UserProfileDAO();
        try {
            new URI(userId);
            UserProfile user = userProfileDAO.findByLogin(userId);
            if (user != null && username != null && !(user.getName().equals(username))) {
                updated = true;
            }
        } catch (URISyntaxException e) {
            LOGGER.warn("URI " + userId + " is not valid", e);
        }
        String password = UUID.randomUUID().toString().replaceAll("-", "").substring(0, 20);
        boolean created = DigitalLibraryFactory.getDigitalLibrary().createOrUpdateUser(userId, password,
            username != null && !username.isEmpty() ? username : userId);
        if (created) {
            return Response.created(uriInfo.getAbsolutePath()).build();
        } else {
            if (updated) {
                UserProfile user = userProfileDAO.findByLogin(userId);
                UpdateUserIndexThread updateThread = new UpdateUserIndexThread(ResearchObject.getAll(builder, user));
                updateThread.start();
            }
            return Response.ok().build();
        }
    }
