use of com.salesmanager.shop.store.api.exception.RestApiException in project shopizer by shopizer-ecommerce.
the class MerchantStoreApi method addLogo.
@ResponseStatus(HttpStatus.CREATED)
@PostMapping(value = { "/private/store/{code}/marketing/logo" })
@ApiOperation(httpMethod = "POST", value = "Add store logo", notes = "")
public void addLogo(@PathVariable String code, @RequestParam("file") MultipartFile uploadfile, HttpServletRequest request) {
// user doing action must be attached to the store being modified
String userName = getUserFromRequest(request);
validateUserPermission(userName, code);
if (uploadfile.isEmpty()) {
throw new RestApiException("Upload file is empty");
}
InputContentFile cmsContentImage = createInputContentFile(uploadfile);
storeFacade.addStoreLogo(code, cmsContentImage);
}
use of com.salesmanager.shop.store.api.exception.RestApiException in project shopizer by shopizer-ecommerce.
the class MerchantStoreApi method createInputContentFile.
private InputContentFile createInputContentFile(MultipartFile image) {
InputContentFile cmsContentImage = null;
try {
InputStream input = new ByteArrayInputStream(image.getBytes());
cmsContentImage = new InputContentFile();
cmsContentImage.setFileName(image.getOriginalFilename());
cmsContentImage.setMimeType(image.getContentType());
cmsContentImage.setFileContentType(FileContentType.LOGO);
cmsContentImage.setFile(input);
} catch (IOException ioe) {
throw new RestApiException(ioe);
}
return cmsContentImage;
}
use of com.salesmanager.shop.store.api.exception.RestApiException in project shopizer by shopizer-ecommerce.
the class SearchToolsApi method contact.
@PostMapping("/private/system/search/index")
@ApiOperation(httpMethod = "POST", value = "Indexes all products", notes = "", produces = "application/json")
@ApiImplicitParams({ @ApiImplicitParam(name = "store", dataType = "String", defaultValue = "DEFAULT"), @ApiImplicitParam(name = "lang", dataType = "String", defaultValue = "en") })
public ResponseEntity<Void> contact(@ApiIgnore MerchantStore merchantStore, @ApiIgnore Language language, HttpServletRequest request) {
// superadmin, admin and admin_catalogue
String authenticatedUser = userFacade.authenticatedUser();
if (authenticatedUser == null) {
throw new UnauthorizedException();
}
Principal principal = request.getUserPrincipal();
String userName = principal.getName();
ReadableUser user = userFacade.findByUserName(userName, null, language);
if (user == null) {
throw new UnauthorizedException();
}
userFacade.authorizedGroup(authenticatedUser, Stream.of(Constants.GROUP_SUPERADMIN, Constants.GROUP_ADMIN, Constants.GROUP_ADMIN_CATALOGUE, Constants.GROUP_ADMIN_RETAIL).collect(Collectors.toList()));
if (!user.getMerchant().equals(merchantStore.getCode())) {
throw new UnauthorizedException();
}
try {
searchFacade.indexAllData(merchantStore);
} catch (Exception e) {
throw new RestApiException("Exception while indexing store data", e);
}
return new ResponseEntity<Void>(HttpStatus.CREATED);
}
Aggregations