use of org.eclipse.che.api.core.rest.annotations.GenerateLink in project che by eclipse.
the class ProfileService method updateAttributes.
@PUT
@Path("/attributes")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@GenerateLink(rel = LINK_REL_CURRENT_PROFILE_ATTRIBUTES)
@ApiOperation(value = "Update the profile attributes of the currently logged in user", notes = "The replace strategy is used for the update, so all the existing profile " + "attributes will be override with incoming values")
public ProfileDto updateAttributes(@ApiParam("New profile attributes") Map<String, String> updates) throws NotFoundException, ServerException, BadRequestException {
checkAttributes(updates);
final ProfileImpl profile = new ProfileImpl(profileManager.getById(userId()));
profile.setAttributes(updates);
profileManager.update(profile);
return linksInjector.injectLinks(asDto(profile, userManager.getById(profile.getUserId())), getServiceContext());
}
use of org.eclipse.che.api.core.rest.annotations.GenerateLink in project che by eclipse.
the class ProfileService method removeAttributes.
@DELETE
@Path("/attributes")
@GenerateLink(rel = LINK_REL_CURRENT_PROFILE_ATTRIBUTES)
@Consumes(APPLICATION_JSON)
@ApiOperation(value = "Remove profile attributes which names are equal to given", notes = "If names list is not send, all the attributes will be removed, " + "if there are no attributes which names equal to some of the given names, " + "then those names are skipped.")
@ApiResponses({ @ApiResponse(code = 204, message = "Attributes successfully removed"), @ApiResponse(code = 500, message = "Couldn't remove attributes due to internal server error") })
public void removeAttributes(@ApiParam("The names of the profile attributes to remove") List<String> names) throws NotFoundException, ServerException {
final Profile profile = profileManager.getById(userId());
final Map<String, String> attributes = profile.getAttributes();
if (names == null) {
attributes.clear();
} else {
names.forEach(attributes::remove);
}
profileManager.update(profile);
}
use of org.eclipse.che.api.core.rest.annotations.GenerateLink in project che by eclipse.
the class UserService method create.
@POST
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@GenerateLink(rel = LINK_REL_USER)
@ApiOperation(value = "Create a new user", response = UserDto.class)
@ApiResponses({ @ApiResponse(code = 201, message = "User successfully created, response contains created entity"), @ApiResponse(code = 400, message = "Missed required parameters, parameters are not valid"), @ApiResponse(code = 401, message = "Missed token parameter"), @ApiResponse(code = 500, message = "Couldn't create user due to internal server error") })
public Response create(@ApiParam("New user") UserDto userDto, @ApiParam("Authentication token") @QueryParam("token") String token, @ApiParam("User type") @QueryParam("temporary") @DefaultValue("false") Boolean isTemporary) throws BadRequestException, UnauthorizedException, ConflictException, ServerException {
if (userDto != null) {
//should be generated by userManager
userDto.setId(null);
}
final User newUser = token == null ? userDto : tokenValidator.validateToken(token);
userValidator.checkUser(newUser);
return Response.status(CREATED).entity(linksInjector.injectLinks(asDto(userManager.create(newUser, isTemporary)), getServiceContext())).build();
}
use of org.eclipse.che.api.core.rest.annotations.GenerateLink in project che by eclipse.
the class UserService method updatePassword.
@POST
@Path("/password")
@Consumes(APPLICATION_FORM_URLENCODED)
@GenerateLink(rel = LINK_REL_CURRENT_USER_PASSWORD)
@ApiOperation(value = "Update password of logged in user", notes = "Password must contain at least 8 characters, " + "passport must contain letters and digits")
@ApiResponses({ @ApiResponse(code = 204, message = "Password successfully updated"), @ApiResponse(code = 400, message = "Incoming password is invalid value." + "Valid password must contain at least 8 character " + "which are letters and digits"), @ApiResponse(code = 500, message = "Couldn't update password due to internal server error") })
public void updatePassword(@ApiParam(value = "New password", required = true) @FormParam("password") String password) throws NotFoundException, BadRequestException, ServerException, ConflictException {
userValidator.checkPassword(password);
final UserImpl user = new UserImpl(userManager.getById(userId()));
user.setPassword(password);
userManager.update(user);
}
use of org.eclipse.che.api.core.rest.annotations.GenerateLink in project che by eclipse.
the class SshService method generatePair.
@POST
@Path("generate")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@GenerateLink(rel = Constants.LINK_REL_GENERATE_PAIR)
@ApiOperation(value = "Generate and stores ssh pair based on the request", notes = "This operation can be performed only by authorized user," + "this user will be the owner of the created ssh pair", response = SshPairDto.class)
@ApiResponses({ @ApiResponse(code = 201, message = "The ssh pair successfully generated"), @ApiResponse(code = 400, message = "Missed required parameters, parameters are not valid"), @ApiResponse(code = 409, message = "Conflict error occurred during the ssh pair generation" + "(e.g. The Ssh pair with such name and service already exists)"), @ApiResponse(code = 500, message = "Internal server error occurred") })
public Response generatePair(@ApiParam(value = "The configuration to generate the new ssh pair", required = true) GenerateSshPairRequest request) throws BadRequestException, ServerException, ConflictException {
requiredNotNull(request, "Generate ssh pair request required");
requiredNotNull(request.getService(), "Service name required");
requiredNotNull(request.getName(), "Name required");
final SshPairImpl generatedPair = sshManager.generatePair(getCurrentUserId(), request.getService(), request.getName());
return Response.status(Response.Status.CREATED).entity(asDto(injectLinks(asDto(generatedPair)))).build();
}
Aggregations