mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged 5.1.N (5.1.2) to 5.2.N (5.2.1)
125605 rmunteanu: Merged 5.1.1 (5.1.1) to 5.1.N (5.1.2) 125498 slanglois: MNT-16155 Update source headers - remove svn:eol-style property on Java and JSP source files git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@125783 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,66 +1,66 @@
|
||||
package org.alfresco.rest.api.impl;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.query.PagingResults;
|
||||
import org.alfresco.rest.api.People;
|
||||
import org.alfresco.rest.api.Preferences;
|
||||
import org.alfresco.rest.api.model.Preference;
|
||||
import org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException;
|
||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||
import org.alfresco.rest.framework.resource.parameters.Paging;
|
||||
import org.alfresco.service.cmr.preference.PreferenceService;
|
||||
import org.alfresco.util.Pair;
|
||||
|
||||
/**
|
||||
* Centralises access to preference services and maps between representations.
|
||||
*
|
||||
* @author steveglover
|
||||
* @since publicapi1.0
|
||||
*/
|
||||
public class PreferencesImpl implements Preferences
|
||||
{
|
||||
private People people;
|
||||
private PreferenceService preferenceService;
|
||||
|
||||
public void setPeople(People people)
|
||||
{
|
||||
this.people = people;
|
||||
}
|
||||
|
||||
public void setPreferenceService(PreferenceService preferenceService)
|
||||
{
|
||||
this.preferenceService = preferenceService;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
package org.alfresco.rest.api.impl;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.query.PagingResults;
|
||||
import org.alfresco.rest.api.People;
|
||||
import org.alfresco.rest.api.Preferences;
|
||||
import org.alfresco.rest.api.model.Preference;
|
||||
import org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException;
|
||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||
import org.alfresco.rest.framework.resource.parameters.Paging;
|
||||
import org.alfresco.service.cmr.preference.PreferenceService;
|
||||
import org.alfresco.util.Pair;
|
||||
|
||||
/**
|
||||
* Centralises access to preference services and maps between representations.
|
||||
*
|
||||
* @author steveglover
|
||||
* @since publicapi1.0
|
||||
*/
|
||||
public class PreferencesImpl implements Preferences
|
||||
{
|
||||
private People people;
|
||||
private PreferenceService preferenceService;
|
||||
|
||||
public void setPeople(People people)
|
||||
{
|
||||
this.people = people;
|
||||
}
|
||||
|
||||
public void setPreferenceService(PreferenceService preferenceService)
|
||||
{
|
||||
this.preferenceService = preferenceService;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user