Search in sources :

Example 26 with AuditLog

use of org.craftercms.studio.api.v2.dal.AuditLog 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);
}
Also used : SiteFeed(org.craftercms.studio.api.v1.dal.SiteFeed) ArrayList(java.util.ArrayList) AuditLogParameter(org.craftercms.studio.api.v2.dal.AuditLogParameter) AuditLog(org.craftercms.studio.api.v2.dal.AuditLog)

Example 27 with AuditLog

use of org.craftercms.studio.api.v2.dal.AuditLog in project studio by craftercms.

the class AuditServiceInternalImpl method createAuditLogEntry.

@Override
public AuditLog createAuditLogEntry() {
    AuditLog auditLog = new AuditLog();
    String clusterNodeId = StringUtils.EMPTY;
    HierarchicalConfiguration<ImmutableNode> clusterNodeData = studioConfiguration.getSubConfig(CLUSTERING_NODE_REGISTRATION);
    if (clusterNodeData != null && !clusterNodeData.isEmpty()) {
        clusterNodeId = clusterNodeData.getString(CLUSTER_MEMBER_LOCAL_ADDRESS);
    }
    auditLog.setOrganizationId(1);
    auditLog.setOrigin(ORIGIN_API);
    auditLog.setClusterNodeId(clusterNodeId);
    return auditLog;
}
Also used : ImmutableNode(org.apache.commons.configuration2.tree.ImmutableNode) AuditLog(org.craftercms.studio.api.v2.dal.AuditLog)

Example 28 with AuditLog

use of org.craftercms.studio.api.v2.dal.AuditLog in project studio by craftercms.

the class DashboardController method prepareAuditResult.

private List<AuditDashboardItem> prepareAuditResult(List<AuditLog> auditLogs) {
    List<AuditDashboardItem> resultItems = new ArrayList<AuditDashboardItem>();
    for (AuditLog auditLog : auditLogs) {
        AuditDashboardItem item = new AuditDashboardItem();
        item.setSiteId(auditLog.getSiteName());
        item.setActor(auditLog.getActorId());
        item.setOperation(auditLog.getOperation());
        item.setOperationTimestamp(auditLog.getOperationTimestamp());
        item.setTarget(auditLog.getPrimaryTargetValue());
        resultItems.add(item);
    }
    return resultItems;
}
Also used : ArrayList(java.util.ArrayList) AuditLog(org.craftercms.studio.api.v2.dal.AuditLog) AuditDashboardItem(org.craftercms.studio.model.rest.dashboard.AuditDashboardItem)

Example 29 with AuditLog

use of org.craftercms.studio.api.v2.dal.AuditLog 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);
}
Also used : SiteFeed(org.craftercms.studio.api.v1.dal.SiteFeed) AuditLog(org.craftercms.studio.api.v2.dal.AuditLog)

Example 30 with AuditLog

use of org.craftercms.studio.api.v2.dal.AuditLog 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;
}
Also used : SiteFeed(org.craftercms.studio.api.v1.dal.SiteFeed) SiteNotFoundException(org.craftercms.studio.api.v1.exception.SiteNotFoundException) AuditLog(org.craftercms.studio.api.v2.dal.AuditLog)

Aggregations

AuditLog (org.craftercms.studio.api.v2.dal.AuditLog)44 SiteFeed (org.craftercms.studio.api.v1.dal.SiteFeed)38 ArrayList (java.util.ArrayList)16 ServiceLayerException (org.craftercms.studio.api.v1.exception.ServiceLayerException)11 AuditLogParameter (org.craftercms.studio.api.v2.dal.AuditLogParameter)11 HasPermission (org.craftercms.commons.security.permissions.annotations.HasPermission)10 Group (org.craftercms.studio.api.v2.dal.Group)10 User (org.craftercms.studio.api.v2.dal.User)9 HashMap (java.util.HashMap)7 SiteNotFoundException (org.craftercms.studio.api.v1.exception.SiteNotFoundException)6 ValidateParams (org.craftercms.commons.validation.annotations.param.ValidateParams)5 AuthenticationSystemException (org.craftercms.studio.api.v1.exception.security.AuthenticationSystemException)5 UserAlreadyExistsException (org.craftercms.studio.api.v1.exception.security.UserAlreadyExistsException)4 UserNotFoundException (org.craftercms.studio.api.v1.exception.security.UserNotFoundException)4 SiteService (org.craftercms.studio.api.v1.service.site.SiteService)4 UserGroup (org.craftercms.studio.api.v2.dal.UserGroup)4 AuditServiceInternal (org.craftercms.studio.api.v2.service.audit.internal.AuditServiceInternal)4 StudioConfiguration (org.craftercms.studio.api.v2.utils.StudioConfiguration)4 SimpleDateFormat (java.text.SimpleDateFormat)3 GroupDAO (org.craftercms.studio.api.v2.dal.GroupDAO)3