use of org.alfresco.rest.framework.core.exceptions.NotFoundException in project alfresco-remote-api by Alfresco.
the class AuthenticationsImpl method deleteTicket.
@Override
public void deleteTicket(String me, Parameters parameters, WithResponse withResponse) {
if (!People.DEFAULT_USER.equals(me)) {
throw new InvalidArgumentException("Invalid parameter: " + me);
}
final String ticket = getTicket(parameters);
try {
final String ticketUser = ticketComponent.validateTicket(ticket);
final String currentUser = AuthenticationUtil.getFullyAuthenticatedUser();
// or the user is not fully authenticated
if (currentUser == null || !currentUser.equals(ticketUser)) {
throw new NotFoundException(NotFoundException.DEFAULT_MESSAGE_ID, new String[] { ticket });
} else {
// delete the ticket
authenticationService.invalidateTicket(ticket);
}
} catch (AuthenticationException e) {
throw new NotFoundException(NotFoundException.DEFAULT_MESSAGE_ID, new String[] { ticket });
}
}
use of org.alfresco.rest.framework.core.exceptions.NotFoundException in project alfresco-remote-api by Alfresco.
the class AuthenticationsImpl method validateTicket.
@Override
public LoginTicketResponse validateTicket(String me, Parameters parameters, WithResponse withResponse) {
if (!People.DEFAULT_USER.equals(me)) {
throw new InvalidArgumentException("Invalid parameter: " + me);
}
final String ticket = getTicket(parameters);
try {
final String ticketUser = ticketComponent.validateTicket(ticket);
final String currentUser = AuthenticationUtil.getFullyAuthenticatedUser();
// or the user is not fully authenticated
if (currentUser == null || !currentUser.equals(ticketUser)) {
throw new NotFoundException(NotFoundException.DEFAULT_MESSAGE_ID, new String[] { ticket });
}
} catch (AuthenticationException e) {
throw new NotFoundException(NotFoundException.DEFAULT_MESSAGE_ID, new String[] { ticket });
}
LoginTicketResponse response = new LoginTicketResponse();
response.setId(ticket);
return response;
}
use of org.alfresco.rest.framework.core.exceptions.NotFoundException in project alfresco-remote-api by Alfresco.
the class SitesImpl method removeFavouriteSite.
public void removeFavouriteSite(String personId, String siteId) {
personId = people.validatePerson(personId);
SiteInfo siteInfo = validateSite(siteId);
if (siteInfo == null) {
// site does not exist
throw new RelationshipResourceNotFoundException(personId, siteId);
}
siteId = siteInfo.getShortName();
StringBuilder prefKey = new StringBuilder(FAVOURITE_SITES_PREFIX);
prefKey.append(siteId);
String value = (String) preferenceService.getPreference(personId, prefKey.toString());
boolean isFavouriteSite = (value != null && value.equalsIgnoreCase("true"));
if (!isFavouriteSite) {
throw new NotFoundException("Site " + siteId + " is not a favourite site");
}
preferenceService.clearPreferences(personId, prefKey.toString());
}
use of org.alfresco.rest.framework.core.exceptions.NotFoundException in project alfresco-remote-api by Alfresco.
the class TagsImpl method changeTag.
public Tag changeTag(StoreRef storeRef, String tagId, Tag tag) {
try {
NodeRef existingTagNodeRef = validateTag(storeRef, tagId);
String existingTagName = taggingService.getTagName(existingTagNodeRef);
String newTagName = tag.getTag();
NodeRef newTagNodeRef = taggingService.changeTag(storeRef, existingTagName, newTagName);
return new Tag(newTagNodeRef, newTagName);
} catch (NonExistentTagException e) {
throw new NotFoundException(e.getMessage());
} catch (TagExistsException e) {
throw new ConstraintViolatedException(e.getMessage());
} catch (TaggingException e) {
throw new InvalidArgumentException(e.getMessage());
}
}
use of org.alfresco.rest.framework.core.exceptions.NotFoundException in project alfresco-remote-api by Alfresco.
the class RenditionsImpl method findVersionIfApplicable.
private NodeRef findVersionIfApplicable(NodeRef nodeRef, String versionLabelId) {
if (versionLabelId != null) {
nodeRef = nodes.validateOrLookupNode(nodeRef.getId(), null);
VersionHistory vh = versionService.getVersionHistory(nodeRef);
if (vh != null) {
try {
Version v = vh.getVersion(versionLabelId);
nodeRef = VersionUtil.convertNodeRef(v.getFrozenStateNodeRef());
} catch (VersionDoesNotExistException vdne) {
throw new NotFoundException("Couldn't find version: [" + nodeRef.getId() + ", " + versionLabelId + "]");
}
}
}
return nodeRef;
}
Aggregations