use of org.opencastproject.matterhorn.search.SearchIndexException in project opencast by opencast.
the class CommentMessageReceiverImpl method execute.
@Override
protected void execute(CommentItem commentItem) {
String organization = getSecurityService().getOrganization().getId();
User user = getSecurityService().getUser();
switch(commentItem.getType()) {
case Update:
logger.debug("Received Comment update for {} search index", getSearchIndex().getIndexName());
try {
EventIndexUtils.updateComments(commentItem.getEventId(), commentItem.hasComments(), commentItem.hasOpenComments(), commentItem.needsCutting(), organization, user, getSearchIndex());
logger.debug("Event {} comment status updated from search index", commentItem.getEventId());
} catch (SearchIndexException e) {
logger.error("Error updating comment status of event {} from the search index: {}", commentItem.getEventId(), ExceptionUtils.getStackTrace(e));
} catch (NotFoundException e) {
// This is expected if the event's comments have been removed as part of the event's removal
logger.debug("Event {} not found for comment status updating", commentItem.getEventId());
}
return;
default:
throw new IllegalArgumentException("Unhandled type of CommentItem");
}
}
use of org.opencastproject.matterhorn.search.SearchIndexException in project opencast by opencast.
the class GroupMessageReceiverImpl method execute.
@Override
protected void execute(GroupItem groupItem) {
String organization = getSecurityService().getOrganization().getId();
User user = getSecurityService().getUser();
switch(groupItem.getType()) {
case Update:
org.opencastproject.security.api.Group jaxbGroup = groupItem.getGroup();
logger.debug("Update the group with id '{}', name '{}', description '{}', organization '{}', roles '{}', members '{}'", jaxbGroup.getGroupId(), jaxbGroup.getName(), jaxbGroup.getDescription(), jaxbGroup.getOrganization(), jaxbGroup.getRoles(), jaxbGroup.getMembers());
try {
Group group = GroupIndexUtils.getOrCreate(jaxbGroup.getGroupId(), organization, user, getSearchIndex());
group.setName(jaxbGroup.getName());
group.setDescription(jaxbGroup.getDescription());
group.setMembers(jaxbGroup.getMembers());
Set<String> roles = new HashSet<>();
for (Role role : jaxbGroup.getRoles()) {
roles.add(role.getName());
}
group.setRoles(roles);
getSearchIndex().addOrUpdate(group);
} catch (SearchIndexException e) {
logger.error("Error storing the group {} to the search index: {}", jaxbGroup.getGroupId(), ExceptionUtils.getStackTrace(e));
return;
}
break;
case Delete:
logger.debug("Received Delete Group Event {}", groupItem.getGroupId());
// Remove the group from the search index
try {
getSearchIndex().delete(Group.DOCUMENT_TYPE, groupItem.getGroupId().concat(organization));
logger.debug("Group {} removed from external search index", groupItem.getGroupId());
} catch (SearchIndexException e) {
logger.error("Error deleting the group {} from the search index: {}", groupItem.getGroupId(), ExceptionUtils.getStackTrace(e));
return;
}
return;
default:
throw new IllegalArgumentException("Unhandled type of GroupItem");
}
}
use of org.opencastproject.matterhorn.search.SearchIndexException in project opencast by opencast.
the class AbstractElasticsearchIndex method delete.
/**
* Removes the given document from the specified index.
*
* @param type
* the document type
* @param uid
* the identifier
* @return <code>true</code> if the element was found and deleted
* @throws SearchIndexException
* if deletion fails
*/
protected boolean delete(String type, String uid) throws SearchIndexException {
if (!preparedIndices.contains(index)) {
try {
createIndex(index);
} catch (IOException e) {
throw new SearchIndexException(e);
}
}
logger.debug("Removing element with id '{}' from searching index", uid);
DeleteRequestBuilder deleteRequest = nodeClient.prepareDelete(index, type, uid);
deleteRequest.setRefresh(true);
DeleteResponse delete = deleteRequest.execute().actionGet();
if (!delete.isFound()) {
logger.trace("Document {} to delete was not found", uid);
return false;
}
return true;
}
Aggregations