use of org.craftercms.studio.model.rest.Result 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;
}
use of org.craftercms.studio.model.rest.Result 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;
}
use of org.craftercms.studio.model.rest.Result in project studio by craftercms.
the class UsersController method validateToken.
@GetMapping(value = VALIDATE_TOKEN, produces = APPLICATION_JSON_VALUE)
public ResponseBody validateToken(HttpServletResponse response, @RequestParam(value = REQUEST_PARAM_TOKEN, required = true) String token) throws UserNotFoundException, UserExternallyManagedException, ServiceLayerException {
int delay = studioConfiguration.getProperty(SECURITY_SET_PASSWORD_DELAY, Integer.class);
try {
TimeUnit.SECONDS.sleep(delay);
} catch (InterruptedException e) {
logger.debug("Interrupted while delaying request by " + delay + " seconds.", e);
}
boolean valid = userService.validateToken(token);
ResponseBody responseBody = new ResponseBody();
Result result = new Result();
if (valid) {
result.setResponse(OK);
} else {
result.setResponse(UNAUTHORIZED);
response.setStatus(HttpStatus.UNAUTHORIZED.value());
}
responseBody.setResult(result);
return responseBody;
}
use of org.craftercms.studio.model.rest.Result in project studio by craftercms.
the class ConfigurationController method writeConfiguration.
@PostMapping("/write_configuration")
public ResponseBody writeConfiguration(@RequestBody WriteConfigurationRequest wcRequest) throws ServiceLayerException {
InputStream is = IOUtils.toInputStream(wcRequest.getContent());
String siteId = wcRequest.getSiteId();
if (StringUtils.equals(siteId, studioConfiguration.getProperty(CONFIGURATION_GLOBAL_SYSTEM_SITE))) {
configurationService.writeGlobalConfiguration(wcRequest.getPath(), is);
} else {
configurationService.writeConfiguration(siteId, wcRequest.getModule(), wcRequest.getPath(), wcRequest.getEnvironment(), is);
}
ResponseBody responseBody = new ResponseBody();
Result result = new Result();
result.setResponse(OK);
responseBody.setResult(result);
return responseBody;
}
use of org.craftercms.studio.model.rest.Result in project studio by craftercms.
the class RepositoryManagementController method removeRemote.
@PostMapping(REMOVE_REMOTE)
public ResponseBody removeRemote(HttpServletResponse response, @RequestBody RemoveRemoteRequest removeRemoteRequest) throws CryptoException, SiteNotFoundException, RemoteNotRemovableException {
if (!siteService.exists(removeRemoteRequest.getSiteId())) {
throw new SiteNotFoundException(removeRemoteRequest.getSiteId());
}
boolean res = repositoryManagementService.removeRemote(removeRemoteRequest.getSiteId(), removeRemoteRequest.getRemoteName());
ResponseBody responseBody = new ResponseBody();
Result result = new Result();
if (res) {
result.setResponse(OK);
} else {
response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
result.setResponse(REMOVE_REMOTE_FAILED);
}
responseBody.setResult(result);
return responseBody;
}
Aggregations