use of org.alfresco.repo.domain.activities.ActivityPostEntity in project alfresco-repository by Alfresco.
the class PostLookup method updatePosts.
private void updatePosts(List<ActivityPostEntity> activityPosts) throws SQLException {
for (final ActivityPostEntity activityPost : activityPosts) {
// MT share
final String tenantDomain = activityPost.getTenantDomain();
TenantUtil.runAsSystemTenant(new TenantUtil.TenantRunAsWork<Object>() {
public Object doWork() throws Exception {
try {
postDAO.startTransaction();
ActivityPostEntity.STATUS status = ActivityPostEntity.STATUS.valueOf(activityPost.getStatus());
switch(status) {
case ERROR:
case PROCESSED:
postDAO.updatePostStatus(activityPost.getId(), status);
break;
case POSTED:
if (activityPost.getId() == null) {
// eg. rolled-up post
postDAO.insertPost(activityPost);
}
break;
case PENDING:
postDAO.updatePost(activityPost.getId(), activityPost.getSiteNetwork(), activityPost.getActivityData(), ActivityPostEntity.STATUS.POSTED);
// for debug output
activityPost.setStatus(ActivityPostEntity.STATUS.POSTED.toString());
break;
default:
throw new Exception("Unexpected status: " + status);
}
if (logger.isDebugEnabled()) {
logger.debug("Updated: " + activityPost);
}
postDAO.commitTransaction();
} catch (SQLException e) {
logger.error("Exception during update of post: ", e);
throw new JobExecutionException(e);
} catch (Exception e) {
// log error, but consume exception (skip this post)
logger.error("Skipping activity post " + activityPost.getId() + ": " + e);
postDAO.updatePostStatus(activityPost.getId(), ActivityPostEntity.STATUS.ERROR);
postDAO.commitTransaction();
} finally {
postDAO.endTransaction();
}
return null;
}
}, tenantDomain);
}
}
Aggregations