use of org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException in project alfresco-remote-api by Alfresco.
the class FavouritesImpl method removeFavourite.
@Override
public void removeFavourite(String personId, String id) {
personId = people.validatePerson(personId, true);
NodeRef nodeRef = nodes.validateNode(id);
boolean exists = false;
Type type = favouritesService.getType(nodeRef);
if (type.equals(Type.SITE)) {
SiteInfo siteInfo = siteService.getSite(nodeRef);
if (siteInfo == null) {
// shouldn't happen because the type implies it's a site
throw new AlfrescoRuntimeException("Unable to find site with nodeRef " + nodeRef);
}
exists = favouritesService.removeFavourite(personId, siteInfo.getNodeRef());
} else if (type.equals(Type.FILE)) {
exists = favouritesService.removeFavourite(personId, nodeRef);
} else if (type.equals(Type.FOLDER)) {
exists = favouritesService.removeFavourite(personId, nodeRef);
}
if (!exists) {
throw new RelationshipResourceNotFoundException(personId, id);
}
}
use of org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException 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);
}
}
use of org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException in project alfresco-remote-api by Alfresco.
the class SiteMembershipRequestsImpl method rejectSiteMembershipRequest.
@Override
public void rejectSiteMembershipRequest(String siteId, String inviteeId, SiteMembershipRejection siteMembershipRejection) {
SiteInfo siteInfo = sites.validateSite(siteId);
if (siteInfo == null) {
throw new EntityNotFoundException(siteId);
}
// set the site id to the short name (to deal with case sensitivity issues with
// using the siteId from the url)
siteId = siteInfo.getShortName();
// Validate invitation.
Invitation invitation = getSiteInvitation(inviteeId, siteId);
if (invitation == null || !(invitation instanceof ModeratedInvitation)) {
throw new RelationshipResourceNotFoundException(siteId, inviteeId);
}
ModeratedInvitation moderatedInvitation = (ModeratedInvitation) invitation;
ResourceType resourceType = moderatedInvitation.getResourceType();
if (!resourceType.equals(ResourceType.WEB_SITE) || !SiteVisibility.MODERATED.equals(siteInfo.getVisibility())) {
// note: security, no indication that this has a different visibility
throw new RelationshipResourceNotFoundException(siteId, inviteeId);
}
String reason = null;
if (siteMembershipRejection != null && !(siteMembershipRejection.getComment() == null || siteMembershipRejection.getComment().isEmpty())) {
reason = siteMembershipRejection.getComment();
}
try {
invitationService.reject(invitation.getInviteId(), reason);
} catch (InvitationExceptionForbidden ex) {
throw new PermissionDeniedException();
}
}
use of org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException in project alfresco-remote-api by Alfresco.
the class SitesImpl method getMemberOfSite.
/**
* people/<personId>/sites/<siteId>
*
* @param siteId String
* @param personId String
* @return MemberOfSite
*/
public MemberOfSite getMemberOfSite(String personId, String siteId) {
MemberOfSite siteMember = null;
personId = people.validatePerson(personId);
SiteInfo siteInfo = validateSite(siteId);
if (siteInfo == null) {
// site does not exist
throw new RelationshipResourceNotFoundException(personId, siteId);
}
// set the site id to the short name (to deal with case sensitivity issues with using the siteId from the url)
siteId = siteInfo.getShortName();
String roleStr = siteService.getMembersRole(siteInfo.getShortName(), personId);
if (roleStr != null) {
Site site = new Site(siteInfo, roleStr);
siteMember = new MemberOfSite(site.getId(), siteInfo.getNodeRef(), roleStr);
} else {
throw new RelationshipResourceNotFoundException(personId, siteId);
}
return siteMember;
}
use of org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException in project alfresco-remote-api by Alfresco.
the class SitesImpl method getFavouriteSite.
public FavouriteSite getFavouriteSite(String personId, String siteId) {
personId = people.validatePerson(personId);
SiteInfo siteInfo = validateSite(siteId);
if (siteInfo == null) {
// site does not exist
throw new RelationshipResourceNotFoundException(personId, siteId);
}
// set the site id to the short name (to deal with case sensitivity issues with using the siteId from the url)
siteId = siteInfo.getShortName();
NodeRef nodeRef = siteInfo.getNodeRef();
if (favouritesService.isFavourite(personId, nodeRef)) {
String role = getSiteRole(siteId, personId);
return new FavouriteSite(siteInfo, role);
} else {
throw new RelationshipResourceNotFoundException(personId, siteId);
}
}
Aggregations