Search in sources :

Example 1 with ResponseBody

use of org.craftercms.studio.model.rest.ResponseBody 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 ResponseBody

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

the class SitesController method createSite.

@PostMapping("/create_site_from_marketplace")
public ResponseBody createSite(@Valid @RequestBody CreateSiteRequest request) throws RemoteRepositoryNotFoundException, InvalidRemoteRepositoryException, ServiceLayerException, InvalidRemoteRepositoryCredentialsException, InvalidRemoteUrlException, RemoteRepositoryNotBareException {
    marketplaceService.createSite(request);
    Result result = new Result();
    result.setResponse(ApiResponse.CREATED);
    ResponseBody response = new ResponseBody();
    response.setResult(result);
    return response;
}
Also used : Result(org.craftercms.studio.model.rest.Result) ResponseBody(org.craftercms.studio.model.rest.ResponseBody) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 3 with ResponseBody

use of org.craftercms.studio.model.rest.ResponseBody 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 4 with ResponseBody

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

the class UsersController method resetPassword.

@PostMapping(PATH_PARAM_ID + RESET_PASSWORD)
public ResponseBody resetPassword(@PathVariable(REQUEST_PARAM_ID) String userId, @RequestBody ResetPasswordRequest resetPasswordRequest) throws UserNotFoundException, UserExternallyManagedException, ServiceLayerException {
    userService.resetPassword(resetPasswordRequest.getUsername(), resetPasswordRequest.getNewPassword());
    ResponseBody responseBody = new ResponseBody();
    Result result = new Result();
    result.setResponse(OK);
    responseBody.setResult(result);
    return responseBody;
}
Also used : ResponseBody(org.craftercms.studio.model.rest.ResponseBody) Result(org.craftercms.studio.model.rest.Result) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 5 with ResponseBody

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

the class UsersController method enableUsers.

/**
 * Enable users API
 *
 * @param enableUsers Enable users request body (json representation)
 * @return Response object
 */
@PatchMapping(value = ENABLE, consumes = APPLICATION_JSON_VALUE)
public ResponseBody enableUsers(@RequestBody EnableUsers enableUsers) throws ServiceLayerException, UserNotFoundException, AuthenticationException {
    ValidationUtils.validateEnableUsers(enableUsers);
    List<User> users = userService.enableUsers(enableUsers.getIds(), enableUsers.getUsernames(), true);
    ResponseBody responseBody = new ResponseBody();
    ResultList<User> result = new ResultList<>();
    result.setResponse(OK);
    result.setEntities(RESULT_KEY_USERS, users);
    responseBody.setResult(result);
    return responseBody;
}
Also used : User(org.craftercms.studio.api.v2.dal.User) AuthenticatedUser(org.craftercms.studio.model.AuthenticatedUser) ResultList(org.craftercms.studio.model.rest.ResultList) PaginatedResultList(org.craftercms.studio.model.rest.PaginatedResultList) ResponseBody(org.craftercms.studio.model.rest.ResponseBody) PatchMapping(org.springframework.web.bind.annotation.PatchMapping)

Aggregations

ResponseBody (org.craftercms.studio.model.rest.ResponseBody)70 GetMapping (org.springframework.web.bind.annotation.GetMapping)37 ResultOne (org.craftercms.studio.model.rest.ResultOne)28 PostMapping (org.springframework.web.bind.annotation.PostMapping)23 SiteNotFoundException (org.craftercms.studio.api.v1.exception.SiteNotFoundException)20 PaginatedResultList (org.craftercms.studio.model.rest.PaginatedResultList)19 Result (org.craftercms.studio.model.rest.Result)18 ResultList (org.craftercms.studio.model.rest.ResultList)11 User (org.craftercms.studio.api.v2.dal.User)10 AuthenticatedUser (org.craftercms.studio.model.AuthenticatedUser)9 DeleteMapping (org.springframework.web.bind.annotation.DeleteMapping)5 Group (org.craftercms.studio.api.v2.dal.Group)4 RepositoryStatus (org.craftercms.studio.api.v2.dal.RepositoryStatus)4 PatchMapping (org.springframework.web.bind.annotation.PatchMapping)4 ZonedDateTime (java.time.ZonedDateTime)3 Map (java.util.Map)3 AuditLog (org.craftercms.studio.api.v2.dal.AuditLog)3 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2