Search in sources :

Example 1 with Preference

use of org.alfresco.rest.api.model.Preference in project alfresco-remote-api by Alfresco.

the class PreferencesImpl method getPreferences.

public CollectionWithPagingInfo<Preference> getPreferences(String personId, Paging paging) {
    personId = people.validatePerson(personId);
    PagingResults<Pair<String, Serializable>> preferences = preferenceService.getPagedPreferences(personId, null, Util.getPagingRequest(paging));
    List<Preference> ret = new ArrayList<Preference>(preferences.getPage().size());
    for (Pair<String, Serializable> prefEntity : preferences.getPage()) {
        Preference pref = new Preference(prefEntity.getFirst(), prefEntity.getSecond());
        ret.add(pref);
    }
    return CollectionWithPagingInfo.asPaged(paging, ret, preferences.hasMoreItems(), preferences.getTotalResultCount().getFirst());
}
Also used : Serializable(java.io.Serializable) Preference(org.alfresco.rest.api.model.Preference) ArrayList(java.util.ArrayList) Pair(org.alfresco.util.Pair)

Example 2 with Preference

use of org.alfresco.rest.api.model.Preference in project alfresco-remote-api by Alfresco.

the class PreferencesImpl method getPreference.

public Preference getPreference(String personId, String preferenceName) {
    personId = people.validatePerson(personId);
    Serializable preferenceValue = preferenceService.getPreference(personId, preferenceName);
    if (preferenceValue != null) {
        return new Preference(preferenceName, preferenceValue);
    } else {
        throw new RelationshipResourceNotFoundException(personId, preferenceName);
    }
}
Also used : RelationshipResourceNotFoundException(org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException) Serializable(java.io.Serializable) Preference(org.alfresco.rest.api.model.Preference)

Aggregations

Serializable (java.io.Serializable)2 Preference (org.alfresco.rest.api.model.Preference)2 ArrayList (java.util.ArrayList)1 RelationshipResourceNotFoundException (org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException)1 Pair (org.alfresco.util.Pair)1