use of org.craftercms.studio.api.v2.dal.AuditLog in project studio by craftercms.
the class SiteServiceImpl method writeConfiguration.
@Override
@ValidateParams
public boolean writeConfiguration(@ValidateStringParam(name = "site") String site, @ValidateSecurePathParam(name = "path") String path, InputStream content) throws ServiceLayerException {
// Write site configuration
String operation = OPERATION_UPDATE;
if (!contentRepository.contentExists(site, path)) {
operation = OPERATION_CREATE;
}
String commitId = contentRepository.writeContent(site, path, content);
contentRepository.reloadRepository(site);
PreviewEventContext context = new PreviewEventContext();
context.setSite(site);
eventService.publish(EVENT_PREVIEW_SYNC, context);
String user = securityService.getCurrentUser();
Map<String, String> extraInfo = new HashMap<String, String>();
if (StringUtils.startsWith(path, contentTypeService.getConfigPath())) {
extraInfo.put(DmConstants.KEY_CONTENT_TYPE, StudioConstants.CONTENT_TYPE_CONTENT_TYPE);
} else {
extraInfo.put(DmConstants.KEY_CONTENT_TYPE, StudioConstants.CONTENT_TYPE_CONFIGURATION);
}
SiteFeed siteFeed = getSite(site);
AuditLog auditLog = auditServiceInternal.createAuditLogEntry();
auditLog.setOperation(operation);
auditLog.setSiteId(siteFeed.getId());
auditLog.setActorId(user);
auditLog.setPrimaryTargetId(site + ":" + path);
auditLog.setPrimaryTargetType(TARGET_TYPE_CONTENT_ITEM);
auditLog.setPrimaryTargetValue(path);
auditServiceInternal.insertAuditLog(auditLog);
objectStateService.transition(site, path, TransitionEvent.SAVE);
if (!objectMetadataManager.metadataExist(site, path)) {
objectMetadataManager.insertNewObjectMetadata(site, path);
}
Map<String, Object> properties = new HashMap<>();
properties.put(ItemMetadata.PROP_NAME, FilenameUtils.getName(path));
properties.put(ItemMetadata.PROP_MODIFIED, ZonedDateTime.now(ZoneOffset.UTC));
properties.put(ItemMetadata.PROP_MODIFIER, user);
objectMetadataManager.setObjectMetadata(site, path, properties);
if (commitId != null) {
objectMetadataManager.updateCommitId(site, path, commitId);
contentRepositoryV2.insertGitLog(site, commitId, 1);
}
boolean toRet = StringUtils.isEmpty(commitId);
return toRet;
}
use of org.craftercms.studio.api.v2.dal.AuditLog in project studio by craftercms.
the class SiteServiceImpl method insertAddRemoteAuditLog.
private void insertAddRemoteAuditLog(String siteId, String remoteName) throws SiteNotFoundException {
SiteFeed siteFeed = getSite(siteId);
String user = securityService.getCurrentUser();
AuditLog auditLog = auditServiceInternal.createAuditLogEntry();
auditLog.setOperation(OPERATION_ADD_REMOTE);
auditLog.setSiteId(siteFeed.getId());
auditLog.setActorId(user);
auditLog.setPrimaryTargetId(remoteName);
auditLog.setPrimaryTargetType(TARGET_TYPE_REMOTE_REPOSITORY);
auditLog.setPrimaryTargetValue(remoteName);
auditServiceInternal.insertAuditLog(auditLog);
}
use of org.craftercms.studio.api.v2.dal.AuditLog 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.v2.dal.AuditLog 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);
}
use of org.craftercms.studio.api.v2.dal.AuditLog 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);
}
Aggregations