use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class RoleService method removeRole.
@Override
public void removeRole(String roleCode) {
try {
Role role = this.getRoleManager().getRole(roleCode);
if (null == role) {
logger.info("role {} does not exists", roleCode);
return;
}
BeanPropertyBindingResult validationResult = this.validateRoleForDelete(role);
if (validationResult.hasErrors()) {
throw new ValidationConflictException(validationResult);
}
this.getRoleManager().removeRole(role);
} catch (ApsSystemException e) {
logger.error("Error in delete role {}", roleCode, e);
throw new RestServerError("error in delete role", e);
}
}
use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class LocalStorageManager method saveFile.
@Override
public void saveFile(String subPath, boolean isProtectedResource, InputStream is) throws ApsSystemException, IOException {
subPath = (null == subPath) ? "" : subPath;
String fullPath = this.createFullPath(subPath, isProtectedResource);
FileOutputStream outStream = null;
try {
File dir = new File(fullPath).getParentFile();
if (!dir.exists()) {
dir.mkdirs();
}
byte[] buffer = new byte[1024];
int length = -1;
outStream = new FileOutputStream(fullPath);
while ((length = is.read(buffer)) != -1) {
outStream.write(buffer, 0, length);
outStream.flush();
}
} catch (Throwable t) {
_logger.error("Error on saving file", t);
throw new ApsSystemException("Error on saving file", t);
} finally {
if (null != outStream) {
outStream.close();
}
if (null != is) {
is.close();
}
}
}
use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class LocalStorageManager method readFile.
@Override
public String readFile(String subPath, boolean isProtectedResource) throws ApsSystemException {
subPath = (null == subPath) ? "" : subPath;
String fullPath = this.createFullPath(subPath, isProtectedResource);
File file = new File(fullPath);
try {
return FileUtils.readFileToString(file, CharEncoding.UTF_8);
} catch (Throwable t) {
_logger.error("Error reading File with path {}", subPath, t);
throw new ApsSystemException("Error reading file", t);
}
}
use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class UserService method updateUser.
@Override
public UserDto updateUser(UserRequest userRequest) {
try {
UserDetails user = this.loadUser(userRequest.getUsername());
UserDetails newUser = this.updateUser(user, userRequest);
this.getUserManager().updateUser(newUser);
return dtoBuilder.convert(newUser);
} catch (ApsSystemException e) {
logger.error("Error in updating user {}", userRequest.getUsername(), e);
throw new RestServerError("Error in updating user", e);
}
}
use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class UserProfileManager method updateProfile.
@Override
@CacheEvict(value = ICacheInfoManager.DEFAULT_CACHE_NAME, key = "'UserProfile_'.concat(#username)")
public void updateProfile(String username, IUserProfile profile) throws ApsSystemException {
try {
profile.setId(username);
this.getProfileDAO().updateEntity(profile);
this.notifyProfileChanging(profile, ProfileChangedEvent.UPDATE_OPERATION_CODE);
} catch (Throwable t) {
logger.error("Error updating profile {}", username, t);
throw new ApsSystemException("Error updating profile", t);
}
}
Aggregations