use of org.craftercms.studio.api.v1.dal.SiteFeed in project studio by craftercms.
the class ContentServiceImpl method pushToRemote.
@Override
public boolean pushToRemote(String siteId, String remoteName, String remoteBranch) throws ServiceLayerException, InvalidRemoteUrlException, AuthenticationException, CryptoException {
if (!siteService.exists(siteId)) {
throw new SiteNotFoundException();
}
boolean toRet = _contentRepository.pushToRemote(siteId, remoteName, remoteBranch);
SiteFeed siteFeed = siteService.getSite(siteId);
AuditLog auditLog = auditServiceInternal.createAuditLogEntry();
auditLog.setOperation(OPERATION_PUSH_TO_REMOTE);
auditLog.setSiteId(siteFeed.getId());
auditLog.setActorId(userService.getCurrentUser().getUsername());
auditLog.setPrimaryTargetId(remoteName + "/" + remoteBranch);
auditLog.setPrimaryTargetType(TARGET_TYPE_REMOTE_REPOSITORY);
auditLog.setPrimaryTargetValue(remoteName + "/" + remoteBranch);
auditServiceInternal.insertAuditLog(auditLog);
return toRet;
}
use of org.craftercms.studio.api.v1.dal.SiteFeed in project studio by craftercms.
the class ContentServiceImpl method revertContentItem.
@Override
@ValidateParams
public boolean revertContentItem(@ValidateStringParam(name = "site") String site, @ValidateSecurePathParam(name = "path") String path, @ValidateStringParam(name = "version") String version, boolean major, @ValidateStringParam(name = "comment") String comment) throws SiteNotFoundException {
boolean toReturn = false;
String commitId = _contentRepository.revertContent(site, path, version, major, comment);
if (commitId != null) {
try {
dependencyService.upsertDependencies(site, path);
} catch (ServiceLayerException e) {
logger.error("Error while extracting dependencies for reverted content. Site: " + site + " path: " + path + " version: " + version);
}
// Update the database with the commitId for the target item
objectStateService.transition(site, path, REVERT);
objectMetadataManager.updateCommitId(site, path, commitId);
SiteFeed siteFeed = siteService.getSite(site);
AuditLog auditLog = auditServiceInternal.createAuditLogEntry();
auditLog.setOperation(OPERATION_REVERT);
auditLog.setSiteId(siteFeed.getId());
auditLog.setActorId(securityService.getCurrentUser());
auditLog.setPrimaryTargetId(site + ":" + path);
auditLog.setPrimaryTargetType(TARGET_TYPE_CONTENT_ITEM);
auditLog.setPrimaryTargetValue(path);
auditLog.setPrimaryTargetSubtype(getContentTypeClass(site, path));
auditServiceInternal.insertAuditLog(auditLog);
contentRepository.insertGitLog(site, commitId, 1, 1);
siteService.updateLastCommitId(site, commitId);
toReturn = true;
}
if (toReturn) {
PreviewEventContext context = new PreviewEventContext();
context.setSite(site);
eventService.publish(EVENT_PREVIEW_SYNC, context);
}
return toReturn;
}
use of org.craftercms.studio.api.v1.dal.SiteFeed in project studio by craftercms.
the class ContentServiceImpl method pullFromRemote.
@Override
public boolean pullFromRemote(String siteId, String remoteName, String remoteBranch) throws ServiceLayerException, InvalidRemoteUrlException, AuthenticationException, CryptoException {
if (!siteService.exists(siteId)) {
throw new SiteNotFoundException(siteId);
}
boolean toRet = _contentRepository.pullFromRemote(siteId, remoteName, remoteBranch);
SiteFeed siteFeed = siteService.getSite(siteId);
AuditLog auditLog = auditServiceInternal.createAuditLogEntry();
auditLog.setOperation(OPERATION_PULL_FROM_REMOTE);
auditLog.setSiteId(siteFeed.getId());
auditLog.setActorId(userService.getCurrentUser().getUsername());
auditLog.setPrimaryTargetId(remoteName + "/" + remoteBranch);
auditLog.setPrimaryTargetType(TARGET_TYPE_REMOTE_REPOSITORY);
auditLog.setPrimaryTargetValue(remoteName + "/" + remoteBranch);
auditServiceInternal.insertAuditLog(auditLog);
return toRet;
}
use of org.craftercms.studio.api.v1.dal.SiteFeed in project studio by craftercms.
the class ContentServiceImpl method generateDeleteActivity.
protected void generateDeleteActivity(String site, String path, String approver) throws SiteNotFoundException {
// TODO: SJ: activities. Fix in 3.1+ by introducing the audit service and refactoring accordingly
if (StringUtils.isEmpty(approver)) {
approver = securityService.getCurrentUser();
}
boolean exists = contentExists(site, path);
if (exists) {
ContentItemTO item = getContentItem(site, path, 0);
ItemMetadata properties = objectMetadataManager.getProperties(site, path);
String user = (properties != null && !StringUtils.isEmpty(properties.getSubmittedBy()) ? properties.getSubmittedBy() : approver);
Map<String, String> extraInfo = new HashMap<String, String>();
if (item.isFolder()) {
extraInfo.put(DmConstants.KEY_CONTENT_TYPE, CONTENT_TYPE_FOLDER);
} else {
extraInfo.put(DmConstants.KEY_CONTENT_TYPE, getContentTypeClass(site, path));
}
logger.debug("[DELETE] posting delete activity on " + path + " by " + user + " in " + site);
SiteFeed siteFeed = siteService.getSite(site);
AuditLog auditLog = auditServiceInternal.createAuditLogEntry();
auditLog.setOperation(OPERATION_DELETE);
auditLog.setSiteId(siteFeed.getId());
auditLog.setActorId(user);
auditLog.setPrimaryTargetId(site + ":" + path);
auditLog.setPrimaryTargetType(TARGET_TYPE_CONTENT_ITEM);
auditLog.setPrimaryTargetValue(path);
auditLog.setPrimaryTargetSubtype(getContentTypeClass(site, path));
auditServiceInternal.insertAuditLog(auditLog);
// process content life cycle
if (path.endsWith(DmConstants.XML_PATTERN)) {
String contentType = item.getContentType();
dmContentLifeCycleService.process(site, user, path, contentType, DmContentLifeCycleService.ContentLifeCycleOperation.DELETE, null);
}
}
}
use of org.craftercms.studio.api.v1.dal.SiteFeed in project studio by craftercms.
the class SecurityServiceImpl method logout.
@Override
public boolean logout() throws SiteNotFoundException {
String username = getCurrentUser();
RequestContext context = RequestContext.getCurrent();
if (username != null && context != null) {
HttpServletRequest httpServletRequest = context.getRequest();
String ipAddress = httpServletRequest.getRemoteAddr();
SiteFeed siteFeed = siteService.getSite(studioConfiguration.getProperty(CONFIGURATION_GLOBAL_SYSTEM_SITE));
AuditLog auditLog = auditServiceInternal.createAuditLogEntry();
auditLog.setOperation(OPERATION_LOGOUT);
auditLog.setActorId(username);
auditLog.setSiteId(siteFeed.getId());
auditLog.setPrimaryTargetId(username);
auditLog.setPrimaryTargetType(TARGET_TYPE_USER);
auditLog.setPrimaryTargetValue(username);
auditServiceInternal.insertAuditLog(auditLog);
logger.info("User " + username + " logged out from IP: " + ipAddress);
}
return true;
}
Aggregations