Search in sources :

Example 6 with AuditApplication

use of org.alfresco.repo.audit.model.AuditApplication in project alfresco-repository by Alfresco.

the class AuditComponentImpl method getAuditEntriesCountByApp.

@Override
public int getAuditEntriesCountByApp(String applicationName) {
    // Get the id for the application
    AuditApplication app = auditModelRegistry.getAuditApplicationByName(applicationName);
    Long applicationId = app.getApplicationId();
    if (applicationId == null) {
        throw new AuditException("No persisted instance exists for audit application: " + app);
    }
    return auditDAO.getAuditEntriesCountByApp(applicationId);
}
Also used : AuditApplication(org.alfresco.repo.audit.model.AuditApplication)

Example 7 with AuditApplication

use of org.alfresco.repo.audit.model.AuditApplication in project alfresco-repository by Alfresco.

the class AuditComponentImpl method isAuditPathEnabled.

/**
 * {@inheritDoc}
 * @since 3.2
 */
public boolean isAuditPathEnabled(String applicationName, String path) {
    ParameterCheck.mandatory("applicationName", applicationName);
    AlfrescoTransactionSupport.checkTransactionReadState(false);
    AuditApplication application = auditModelRegistry.getAuditApplicationByName(applicationName);
    if (application == null) {
        if (logger.isDebugEnabled()) {
            logger.debug("No audit application named '" + applicationName + "' has been registered.");
        }
        return false;
    }
    // Ensure that the path gets a valid value
    if (path == null) {
        path = AuditApplication.AUDIT_PATH_SEPARATOR + application.getApplicationKey();
    } else {
        // Check the path against the application
        application.checkPath(path);
    }
    Set<String> disabledPaths = getDisabledPaths(application);
    // Check if there are any entries that match or supercede the given path
    String disablingPath = null;
    ;
    for (String disabledPath : disabledPaths) {
        if (path.startsWith(disabledPath)) {
            disablingPath = disabledPath;
            break;
        }
    }
    // Done
    if (logger.isDebugEnabled()) {
        logger.debug("Audit path enabled check: \n" + "   Application:    " + applicationName + "\n" + "   Path:           " + path + "\n" + "   Disabling Path: " + disablingPath);
    }
    return disablingPath == null;
}
Also used : AuditApplication(org.alfresco.repo.audit.model.AuditApplication)

Example 8 with AuditApplication

use of org.alfresco.repo.audit.model.AuditApplication in project alfresco-repository by Alfresco.

the class AuditComponentImpl method getAuditMinMaxByApp.

/**
 * {@inheritDoc}
 */
public HashMap<String, Long> getAuditMinMaxByApp(String applicationName, List<String> extremes) {
    // Get the id for the application
    AuditApplication app = auditModelRegistry.getAuditApplicationByName(applicationName);
    Long applicationId = app.getApplicationId();
    if (applicationId == null) {
        throw new AuditException("No persisted instance exists for audit application: " + app);
    }
    return auditDAO.getAuditMinMaxByApp(applicationId, extremes);
}
Also used : AuditApplication(org.alfresco.repo.audit.model.AuditApplication)

Example 9 with AuditApplication

use of org.alfresco.repo.audit.model.AuditApplication in project alfresco-repository by Alfresco.

the class AuditComponentImpl method enableAudit.

/**
 * {@inheritDoc}
 * @since 3.2
 */
public void enableAudit(String applicationName, String path) {
    ParameterCheck.mandatory("applicationName", applicationName);
    AlfrescoTransactionSupport.checkTransactionReadState(true);
    AuditApplication application = auditModelRegistry.getAuditApplicationByName(applicationName);
    if (application == null) {
        if (logger.isDebugEnabled()) {
            logger.debug("No audit application named '" + applicationName + "' has been registered.");
        }
        return;
    }
    // Ensure that the path gets a valid value
    if (path == null) {
        path = AuditApplication.AUDIT_PATH_SEPARATOR + application.getApplicationKey();
    } else {
        // Check the path against the application
        application.checkPath(path);
    }
    Long disabledPathsId = application.getDisabledPathsId();
    Set<String> disabledPaths = getDisabledPaths(application);
    // Remove any paths that start with the given path
    boolean changed = false;
    Iterator<String> iterateDisabledPaths = disabledPaths.iterator();
    while (iterateDisabledPaths.hasNext()) {
        String disabledPath = iterateDisabledPaths.next();
        if (disabledPath.startsWith(path)) {
            iterateDisabledPaths.remove();
            changed = true;
        }
    }
    // Persist, if necessary
    if (changed) {
        propertyValueDAO.updateProperty(disabledPathsId, (Serializable) disabledPaths);
        if (logger.isDebugEnabled()) {
            logger.debug("Audit disabled paths updated: \n" + "   Application: " + applicationName + "\n" + "   Disabled:    " + disabledPaths);
        }
    }
// Done
}
Also used : AuditApplication(org.alfresco.repo.audit.model.AuditApplication)

Example 10 with AuditApplication

use of org.alfresco.repo.audit.model.AuditApplication in project alfresco-repository by Alfresco.

the class AuditComponentImpl method disableAudit.

/**
 * {@inheritDoc}
 * @since 3.2
 */
public void disableAudit(String applicationName, String path) {
    ParameterCheck.mandatory("applicationName", applicationName);
    AlfrescoTransactionSupport.checkTransactionReadState(true);
    AuditApplication application = auditModelRegistry.getAuditApplicationByName(applicationName);
    if (application == null) {
        if (logger.isDebugEnabled()) {
            logger.debug("No audit application named '" + applicationName + "' has been registered.");
        }
        return;
    }
    // Ensure that the path gets a valid value
    if (path == null) {
        path = AuditApplication.AUDIT_PATH_SEPARATOR + application.getApplicationKey();
    } else {
        // Check the path against the application
        application.checkPath(path);
    }
    Long disabledPathsId = application.getDisabledPathsId();
    Set<String> disabledPaths = getDisabledPaths(application);
    // Shortcut if the disabled paths contain the exact path
    if (disabledPaths.contains(path)) {
        if (logger.isDebugEnabled()) {
            logger.debug("Audit disable path already present: \n" + "   Path:       " + path);
        }
        return;
    }
    // Bring the set up to date by stripping out unwanted paths
    Iterator<String> iterateDisabledPaths = disabledPaths.iterator();
    while (iterateDisabledPaths.hasNext()) {
        String disabledPath = iterateDisabledPaths.next();
        if (disabledPath.startsWith(path)) {
            // We will be superceding this
            iterateDisabledPaths.remove();
        } else if (path.startsWith(disabledPath)) {
            // There is already a superceding path
            if (logger.isDebugEnabled()) {
                logger.debug("Audit disable path superceded: \n" + "   Path:          " + path + "\n" + "   Superceded by: " + disabledPath);
            }
            return;
        }
    }
    // Add our path in
    disabledPaths.add(path);
    // Upload the new set
    propertyValueDAO.updateProperty(disabledPathsId, (Serializable) disabledPaths);
    // Done
    if (logger.isDebugEnabled()) {
        logger.debug("Audit disabled paths updated: \n" + "   Application: " + applicationName + "\n" + "   Disabled:    " + disabledPaths);
    }
}
Also used : AuditApplication(org.alfresco.repo.audit.model.AuditApplication)

Aggregations

AuditApplication (org.alfresco.repo.audit.model.AuditApplication)14 Serializable (java.io.Serializable)2 URL (java.net.URL)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 DataGenerator (org.alfresco.repo.audit.generator.DataGenerator)1 DataExtractorDefinition (org.alfresco.repo.audit.model.AuditApplication.DataExtractorDefinition)1