use of org.craftercms.studio.api.v1.dal.SiteFeed in project studio by craftercms.
the class ContentServiceImpl method insertDeleteContentApprovedActivity.
private void insertDeleteContentApprovedActivity(String siteId, String aprover, List<String> contentToDelete) throws SiteNotFoundException {
SiteFeed siteFeed = siteService.getSite(siteId);
AuditLog auditLog = auditServiceInternal.createAuditLogEntry();
auditLog.setOperation(OPERATION_APPROVE);
auditLog.setActorId(aprover);
auditLog.setSiteId(siteFeed.getId());
auditLog.setPrimaryTargetId(siteId);
auditLog.setPrimaryTargetType(TARGET_TYPE_SITE);
auditLog.setPrimaryTargetValue(siteId);
List<AuditLogParameter> auditLogParameters = new ArrayList<AuditLogParameter>();
for (String itemToDelete : contentToDelete) {
AuditLogParameter auditLogParameter = new AuditLogParameter();
auditLogParameter.setTargetId(siteId + ":" + itemToDelete);
auditLogParameter.setTargetType(TARGET_TYPE_CONTENT_ITEM);
auditLogParameter.setTargetValue(itemToDelete);
auditLogParameters.add(auditLogParameter);
}
auditLog.setParameters(auditLogParameters);
auditServiceInternal.insertAuditLog(auditLog);
}
use of org.craftercms.studio.api.v1.dal.SiteFeed in project studio by craftercms.
the class StudioPublisherTask method generateWorkflowActivity.
protected void generateWorkflowActivity(String site, String environment, Set<String> packageIds, String username, String operation) throws SiteNotFoundException {
SiteFeed siteFeed = siteService.getSite(site);
AuditLog auditLog = auditServiceInternal.createAuditLogEntry();
auditLog.setOperation(operation);
auditLog.setActorId(username);
auditLog.setSiteId(siteFeed.getId());
auditLog.setPrimaryTargetId(site + ":" + environment);
auditLog.setPrimaryTargetType(TARGET_TYPE_CONTENT_ITEM);
auditLog.setPrimaryTargetValue(environment);
List<AuditLogParameter> auditLogParameters = new ArrayList<AuditLogParameter>();
for (String packageId : packageIds) {
AuditLogParameter auditLogParameter = new AuditLogParameter();
auditLogParameter.setTargetId(site + ":" + environment);
auditLogParameter.setTargetType(TARGET_TYPE_CONTENT_ITEM);
auditLogParameter.setTargetValue(packageId);
auditLogParameters.add(auditLogParameter);
}
auditLog.setParameters(auditLogParameters);
auditServiceInternal.insertAuditLog(auditLog);
}
use of org.craftercms.studio.api.v1.dal.SiteFeed in project studio by craftercms.
the class StudioSyncRepositoryTask method syncRepository.
private void syncRepository(String site) throws SiteNotFoundException, IOException {
logger.debug("Getting last verified commit for site: " + site);
SiteFeed siteFeed = siteService.getSite(site);
if (checkSiteUuid(site, siteFeed.getSiteUuid())) {
String lastProcessedCommit = siteService.getLastVerifiedGitlogCommitId(site);
if (StringUtils.isNotEmpty(lastProcessedCommit)) {
GitLog gl = contentRepository.getGitLog(site, lastProcessedCommit);
if (Objects.nonNull(gl)) {
String lastRepoCommitId = contentRepository.getRepoLastCommitId(site);
if (StringUtils.equals(lastRepoCommitId, lastProcessedCommit)) {
contentRepository.markGitLogVerifiedProcessed(site, gl.getCommitId());
contentRepository.markGitLogProcessedBeforeMarker(site, gl.getId(), 1);
} else {
logger.debug("Syncing database with repository for site " + site + " from last processed commit " + lastProcessedCommit);
List<GitLog> unprocessedCommitIds = contentRepository.getUnprocessedCommits(site, gl.getId());
if (unprocessedCommitIds != null && unprocessedCommitIds.size() > 0) {
siteService.syncDatabaseWithRepoUnprocessedCommits(site, unprocessedCommitIds);
GitLog gitLog = unprocessedCommitIds.get(0);
String commitBeforeUnprocessedCommit = contentRepository.getPreviousCommitId(site, gitLog.getCommitId());
siteService.syncDatabaseWithRepo(site, commitBeforeUnprocessedCommit);
unprocessedCommitIds.forEach(x -> {
contentRepository.markGitLogVerifiedProcessed(site, x.getCommitId());
});
// Sync all preview deployers
try {
logger.debug("Sync preview for site " + site);
deploymentService.syncAllContentToPreview(site, false);
} catch (ServiceLayerException e) {
logger.error("Error synchronizing preview with repository for site: " + site, e);
}
} else {
GitLog gl2 = contentRepository.getGitLog(site, lastRepoCommitId);
if (Objects.nonNull(gl2) && !StringUtils.equals(lastRepoCommitId, lastProcessedCommit)) {
siteService.updateLastVerifiedGitlogCommitId(site, lastRepoCommitId);
contentRepository.markGitLogProcessedBeforeMarker(site, gl2.getId(), 1);
} else {
contentRepository.markGitLogProcessedBeforeMarker(site, gl.getId(), 1);
}
}
}
}
}
}
}
use of org.craftercms.studio.api.v1.dal.SiteFeed in project studio by craftercms.
the class SiteServiceImpl method insertRemoveRemoteAuditLog.
private void insertRemoveRemoteAuditLog(String siteId, String remoteName) throws SiteNotFoundException {
SiteFeed siteFeed = getSite(siteId);
String user = securityService.getCurrentUser();
AuditLog auditLog = auditServiceInternal.createAuditLogEntry();
auditLog.setOperation(OPERATION_REMOVE_REMOTE);
auditLog.setActorId(user);
auditLog.setSiteId(siteFeed.getId());
auditLog.setPrimaryTargetId(remoteName);
auditLog.setPrimaryTargetType(TARGET_TYPE_REMOTE_REPOSITORY);
auditLog.setPrimaryTargetValue(remoteName);
auditServiceInternal.insertAuditLog(auditLog);
}
use of org.craftercms.studio.api.v1.dal.SiteFeed in project studio by craftercms.
the class SiteServiceImpl method setPublishedRepoCreated.
@Override
public void setPublishedRepoCreated(String siteId) {
siteFeedMapper.setPublishedRepoCreated(siteId);
try {
ClusterMember clusterMember = clusterDao.getMemberByLocalAddress(studioClusterUtils.getClusterNodeLocalAddress());
if (Objects.nonNull(clusterMember)) {
SiteFeed siteFeed = getSite(siteId);
clusterDao.setPublishedRepoCreated(clusterMember.getId(), siteFeed.getId());
}
} catch (SiteNotFoundException e) {
logger.error("Site not found " + siteId);
}
}
Aggregations