Search in sources :

Example 6 with UserPreferences

use of com.emc.storageos.db.client.model.UserPreferences in project coprhd-controller by CoprHD.

the class UserPreferenceService method update.

@PUT
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("")
public UserPreferencesRestRep update(UserPreferencesUpdateParam param) {
    StorageOSUser user = getUserFromContext();
    String username = param.getUsername();
    if (StringUtils.isBlank(username)) {
        username = user.getUserName();
    }
    verifyAuthorized(username, user);
    UserPreferences userPreferences = userPreferenceManager.getPreferences(username);
    validateParam(param, userPreferences);
    updateObject(userPreferences, param);
    userPreferenceManager.updatePreferences(userPreferences);
    auditOpSuccess(OperationTypeEnum.UPDATE_USER_PREFERENCES, userPreferences.auditParameters());
    userPreferences = userPreferenceManager.getPreferences(userPreferences.getUserId());
    return map(userPreferences);
}
Also used : UserPreferences(com.emc.storageos.db.client.model.UserPreferences) StorageOSUser(com.emc.storageos.security.authentication.StorageOSUser) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT)

Example 7 with UserPreferences

use of com.emc.storageos.db.client.model.UserPreferences in project coprhd-controller by CoprHD.

the class UserPreferenceManagerImpl method getPreferences.

public UserPreferences getPreferences(String userName) {
    UserPreferences preferences = client.preferences().findByUserId(userName);
    if (preferences == null) {
        preferences = new UserPreferences();
        preferences.setNotifyByEmail(DEFAULT_NOTIFY_BY_EMAIL);
        preferences.setEmail(DEFAULT_EMAIL);
        preferences.setUserId(userName);
        client.save(preferences);
    }
    return preferences;
}
Also used : UserPreferences(com.emc.storageos.db.client.model.UserPreferences)

Aggregations

UserPreferences (com.emc.storageos.db.client.model.UserPreferences)7 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)4 NamedElementQueryResultList (com.emc.storageos.db.client.constraint.NamedElementQueryResultList)4 AlternateIdConstraintImpl (com.emc.storageos.db.client.constraint.impl.AlternateIdConstraintImpl)4 DataObjectType (com.emc.storageos.db.client.impl.DataObjectType)4 URI (java.net.URI)4 StorageOSUser (com.emc.storageos.security.authentication.StorageOSUser)2 ArrayList (java.util.ArrayList)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 Consumes (javax.ws.rs.Consumes)1 GET (javax.ws.rs.GET)1 PUT (javax.ws.rs.PUT)1