Search in sources :

Example 1 with ResultOne

use of org.craftercms.studio.model.rest.ResultOne in project studio by craftercms.

the class SecurityController method encryptText.

@PostMapping("/encrypt")
public ResponseBody encryptText(@RequestBody EncryptRequest request) throws ServiceLayerException {
    String encrypted = encryptionService.encrypt(request.getSiteId(), request.getText());
    ResultOne<String> result = new ResultOne<>();
    result.setEntity(RESULT_KEY_ITEM, encrypted);
    result.setResponse(ApiResponse.OK);
    ResponseBody response = new ResponseBody();
    response.setResult(result);
    return response;
}
Also used : ResultOne(org.craftercms.studio.model.rest.ResultOne) ResponseBody(org.craftercms.studio.model.rest.ResponseBody) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 2 with ResultOne

use of org.craftercms.studio.model.rest.ResultOne in project studio by craftercms.

the class UiController method getActiveEnvironment.

@GetMapping("/system/active_environment")
public ResponseBody getActiveEnvironment() throws AuthenticationException {
    ResultOne<String> result = new ResultOne<String>();
    result.setResponse(ApiResponse.OK);
    result.setEntity(RESULT_KEY_ENVIRONMENT, uiService.getActiveEnvironment());
    ResponseBody responseBody = new ResponseBody();
    responseBody.setResult(result);
    return responseBody;
}
Also used : ResultOne(org.craftercms.studio.model.rest.ResultOne) ResponseBody(org.craftercms.studio.model.rest.ResponseBody) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 3 with ResultOne

use of org.craftercms.studio.model.rest.ResultOne in project studio by craftercms.

the class UsersController method getCurrentUserSsoLogoutUrl.

/**
 * Get the SSO SP logout URL for the current authenticated user. The system should redirect to this logout URL
 * <strong>AFTER</strong> local logout. Response entity can be null if user is not authenticated through SSO
 * or if logout is disabled
 *
 * @return Response containing SSO logout URL for the current authenticated user
 */
@GetMapping(ME + LOGOUT_SSO_URL)
public ResponseBody getCurrentUserSsoLogoutUrl() throws ServiceLayerException, AuthenticationException {
    String logoutUrl = userService.getCurrentUserSsoLogoutUrl();
    ResultOne<String> result = new ResultOne<>();
    result.setResponse(OK);
    result.setEntity(RESULT_KEY_LOGOUT_URL, logoutUrl);
    ResponseBody responseBody = new ResponseBody();
    responseBody.setResult(result);
    return responseBody;
}
Also used : ResultOne(org.craftercms.studio.model.rest.ResultOne) ResponseBody(org.craftercms.studio.model.rest.ResponseBody) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 4 with ResultOne

use of org.craftercms.studio.model.rest.ResultOne in project studio by craftercms.

the class UsersController method changePassword.

@PostMapping(ME + CHANGE_PASSWORD)
public ResponseBody changePassword(@RequestBody ChangePasswordRequest changePasswordRequest) throws PasswordDoesNotMatchException, ServiceLayerException, UserExternallyManagedException, AuthenticationException, UserNotFoundException {
    User result = userService.changePassword(changePasswordRequest.getUsername(), changePasswordRequest.getCurrent(), changePasswordRequest.getNewPassword());
    ResponseBody responseBody = new ResponseBody();
    ResultOne<User> resultOne = new ResultOne<User>();
    resultOne.setEntity(RESULT_KEY_USER, result);
    resultOne.setResponse(OK);
    responseBody.setResult(resultOne);
    return responseBody;
}
Also used : User(org.craftercms.studio.api.v2.dal.User) AuthenticatedUser(org.craftercms.studio.model.AuthenticatedUser) ResultOne(org.craftercms.studio.model.rest.ResultOne) ResponseBody(org.craftercms.studio.model.rest.ResponseBody) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 5 with ResultOne

use of org.craftercms.studio.model.rest.ResultOne in project studio by craftercms.

the class UsersController method updateUser.

/**
 * Update user API
 *
 * @param user User to update
 * @return Response object
 */
@PatchMapping(value = "", consumes = APPLICATION_JSON_VALUE)
public ResponseBody updateUser(@RequestBody User user) throws ServiceLayerException, UserNotFoundException, AuthenticationException {
    userService.updateUser(user);
    ResponseBody responseBody = new ResponseBody();
    ResultOne<User> result = new ResultOne<>();
    result.setResponse(OK);
    result.setEntity(RESULT_KEY_USER, user);
    responseBody.setResult(result);
    return responseBody;
}
Also used : User(org.craftercms.studio.api.v2.dal.User) AuthenticatedUser(org.craftercms.studio.model.AuthenticatedUser) ResultOne(org.craftercms.studio.model.rest.ResultOne) ResponseBody(org.craftercms.studio.model.rest.ResponseBody) PatchMapping(org.springframework.web.bind.annotation.PatchMapping)

Aggregations

ResultOne (org.craftercms.studio.model.rest.ResultOne)31 ResponseBody (org.craftercms.studio.model.rest.ResponseBody)28 GetMapping (org.springframework.web.bind.annotation.GetMapping)15 PostMapping (org.springframework.web.bind.annotation.PostMapping)13 SiteNotFoundException (org.craftercms.studio.api.v1.exception.SiteNotFoundException)7 AuthenticatedUser (org.craftercms.studio.model.AuthenticatedUser)6 User (org.craftercms.studio.api.v2.dal.User)5 InputStream (java.io.InputStream)4 FileItemIterator (org.apache.commons.fileupload.FileItemIterator)4 FileItemStream (org.apache.commons.fileupload.FileItemStream)4 ServletFileUpload (org.apache.commons.fileupload.servlet.ServletFileUpload)4 RepositoryStatus (org.craftercms.studio.api.v2.dal.RepositoryStatus)4 InvalidParametersException (org.craftercms.studio.api.v2.exception.InvalidParametersException)4 FileUploadException (org.apache.commons.fileupload.FileUploadException)3 Group (org.craftercms.studio.api.v2.dal.Group)3 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 PatchMapping (org.springframework.web.bind.annotation.PatchMapping)2 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)2