use of org.craftercms.studio.api.v1.dal.SiteFeed in project studio by craftercms.
the class SiteServiceImpl method updateLastSyncedGitlogCommitId.
@Override
public void updateLastSyncedGitlogCommitId(String site, String commitId) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("siteId", site);
params.put("commitId", commitId);
retryingOperationFacade.updateSiteLastSyncedGitlogCommitId(params);
try {
ClusterMember clusterMember = clusterDao.getMemberByLocalAddress(studioClusterUtils.getClusterNodeLocalAddress());
if (Objects.nonNull(clusterMember)) {
SiteFeed siteFeed = getSite(site);
retryingOperationFacade.updateClusterNodeLastSyncedGitlogCommitId(clusterMember.getId(), siteFeed.getId(), commitId);
}
} catch (SiteNotFoundException e) {
logger.error("Site not found " + site);
}
}
use of org.craftercms.studio.api.v1.dal.SiteFeed in project studio by craftercms.
the class SiteServiceImpl method insertCreateSiteAuditLog.
private void insertCreateSiteAuditLog(String siteId, String siteName, Map<String, String> createdFiles) throws SiteNotFoundException {
SiteFeed siteFeed = getSite(studioConfiguration.getProperty(CONFIGURATION_GLOBAL_SYSTEM_SITE));
String user = securityService.getCurrentUser();
AuditLog auditLog = auditServiceInternal.createAuditLogEntry();
auditLog.setOperation(OPERATION_CREATE);
auditLog.setSiteId(siteFeed.getId());
auditLog.setActorId(user);
auditLog.setPrimaryTargetId(siteId);
auditLog.setPrimaryTargetType(TARGET_TYPE_SITE);
auditLog.setPrimaryTargetValue(siteName);
List<AuditLogParameter> auditLogParameters = new ArrayList<AuditLogParameter>();
createdFiles.forEach((k, v) -> {
String targetPath = k;
if (StringUtils.length(v) > 1) {
targetPath = v;
}
AuditLogParameter auditLogParameter = new AuditLogParameter();
auditLogParameter.setTargetId(siteId + ":" + targetPath);
auditLogParameter.setTargetType(TARGET_TYPE_CONTENT_ITEM);
auditLogParameter.setTargetValue(targetPath);
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 SiteServiceImpl method deleteSite.
@Override
@ValidateParams
public boolean deleteSite(@ValidateStringParam(name = "siteId") String siteId) {
boolean success = true;
logger.debug("Deleting site:" + siteId);
try {
enablePublishing(siteId, false);
} catch (SiteNotFoundException e) {
success = false;
logger.error("Failed to stop publishing for site:" + siteId, e);
}
try {
logger.debug("Deleting Deployer targets");
deployer.deleteTargets(siteId);
} catch (Exception e) {
success = false;
logger.error("Failed to delete the Deployer target for sites:" + siteId, e);
}
try {
success = success && destroySitePreviewContext(siteId);
} catch (Exception e) {
success = false;
logger.error("Failed to destroy the preview context for site:" + siteId, e);
}
try {
logger.debug("Deleting repo");
contentRepository.deleteSite(siteId);
} catch (Exception e) {
success = false;
logger.error("Failed to delete the repository for site:" + siteId, e);
}
try {
// delete database records
logger.debug("Deleting database records");
SiteFeed siteFeed = getSite(siteId);
siteFeedMapper.deleteSite(siteId);
dependencyService.deleteSiteDependencies(siteId);
deploymentService.deleteDeploymentDataForSite(siteId);
objectStateService.deleteObjectStatesForSite(siteId);
objectMetadataManager.deleteObjectMetadataForSite(siteId);
dmPageNavigationOrderService.deleteSequencesForSite(siteId);
contentRepository.deleteGitLogForSite(siteId);
contentRepository.removeRemoteRepositoriesForSite(siteId);
auditServiceInternal.deleteAuditLogForSite(siteFeed.getId());
insertDeleteSiteAuditLog(siteId, siteFeed.getName());
} catch (Exception e) {
success = false;
logger.error("Failed to delete the database for site:" + siteId, e);
}
return success;
}
use of org.craftercms.studio.api.v1.dal.SiteFeed in project studio by craftercms.
the class SiteServiceImpl method updateLastVerifiedGitlogCommitId.
@Override
public void updateLastVerifiedGitlogCommitId(String site, String commitId) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("siteId", site);
params.put("commitId", commitId);
retryingOperationFacade.updateSiteLastVerifiedGitlogCommitId(params);
try {
ClusterMember clusterMember = clusterDao.getMemberByLocalAddress(studioClusterUtils.getClusterNodeLocalAddress());
if (Objects.nonNull(clusterMember)) {
SiteFeed siteFeed = getSite(site);
retryingOperationFacade.updateClusterNodeLastVerifiedGitlogCommitId(clusterMember.getId(), siteFeed.getId(), commitId);
}
} catch (SiteNotFoundException e) {
logger.error("Site not found " + site);
}
}
use of org.craftercms.studio.api.v1.dal.SiteFeed in project studio by craftercms.
the class RepositoryManagementServiceImpl method insertAddRemoteAuditLog.
private void insertAddRemoteAuditLog(String siteId, String operation, String primaryTargetId, String primaryTargetValue) throws SiteNotFoundException {
SiteFeed siteFeed = siteService.getSite(siteId);
String user = securityService.getCurrentUser();
AuditLog auditLog = auditServiceInternal.createAuditLogEntry();
auditLog.setOperation(operation);
auditLog.setSiteId(siteFeed.getId());
auditLog.setActorId(user);
auditLog.setPrimaryTargetId(primaryTargetId);
auditLog.setPrimaryTargetType(TARGET_TYPE_REMOTE_REPOSITORY);
auditLog.setPrimaryTargetValue(primaryTargetValue);
auditServiceInternal.insertAuditLog(auditLog);
}
Aggregations