Search in sources :

Example 66 with ApsSystemException

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);
    }
}
Also used : Role(com.agiletec.aps.system.services.role.Role) BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) RestServerError(org.entando.entando.aps.system.exception.RestServerError) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ValidationConflictException(org.entando.entando.web.common.exceptions.ValidationConflictException)

Example 67 with ApsSystemException

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();
        }
    }
}
Also used : FileOutputStream(java.io.FileOutputStream) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) File(java.io.File)

Example 68 with ApsSystemException

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);
    }
}
Also used : ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) File(java.io.File)

Example 69 with ApsSystemException

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);
    }
}
Also used : UserDetails(com.agiletec.aps.system.services.user.UserDetails) RestServerError(org.entando.entando.aps.system.exception.RestServerError) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException)

Example 70 with ApsSystemException

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);
    }
}
Also used : ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) CacheEvict(org.springframework.cache.annotation.CacheEvict)

Aggregations

ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)452 ArrayList (java.util.ArrayList)53 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)48 RestServerError (org.entando.entando.aps.system.exception.RestServerError)39 ApsProperties (com.agiletec.aps.util.ApsProperties)26 IApsEntity (com.agiletec.aps.system.common.entity.model.IApsEntity)23 HashMap (java.util.HashMap)23 UserDetails (com.agiletec.aps.system.services.user.UserDetails)21 StringApiResponse (org.entando.entando.aps.system.services.api.model.StringApiResponse)21 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)20 Date (java.util.Date)20 StringReader (java.io.StringReader)18 IPage (com.agiletec.aps.system.services.page.IPage)17 List (java.util.List)17 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)16 File (java.io.File)16 BeanPropertyBindingResult (org.springframework.validation.BeanPropertyBindingResult)16 Widget (com.agiletec.aps.system.services.page.Widget)15 IOException (java.io.IOException)15 Cache (org.springframework.cache.Cache)15