src/main/java/org/fcrepo/audit/InternalAuditor.java
public void createAuditNode(final FedoraEvent event) throws IOException {
        try {
            final String userAgent = event.getInfo().get(USER_AGENT);
            final String baseURL = event.getInfo().get(BASE_URL);
            final String path = event.getPath();
            final String uri = baseURL + path;
            final Instant timestamp =  event.getDate();
            final DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
            df.setTimeZone(TimeZone.getTimeZone("UTC"));
            final String eventDate = df.format(timestamp.toEpochMilli());
            final String userID = event.getUserID();
            final Set<String> eventTypes = AuditUtils.getEventURIs(event.getTypes());
            final Set<String> resourceTypes = event.getResourceTypes();
            final String auditEventType = AuditUtils.getAuditEventType(eventTypes, resourceTypes);

            final String eventPath = getEventPath(event.getEventID());
            final FedoraResource auditResource = containerService.findOrCreate(session,
                    AUDIT_CONTAINER_LOCATION + "/" + eventPath);

            LOGGER.debug("Audit node {} created for event.", event.getEventID());

            final Model m = createDefaultModel();
            final String auditResourceURI = baseURL + AUDIT_CONTAINER_LOCATION + "/" + eventPath;
            final Resource s = createResource(auditResourceURI);
            m.add(createStatement(s, RDF_TYPE, createResource(INTERNAL_EVENT)));
            m.add(createStatement(s, RDF_TYPE, createResource(PREMIS_EVENT)));
            m.add(createStatement(s, RDF_TYPE, createResource(PROV_EVENT)));
            m.add(createStatement(s, PREMIS_TIME, createTypedLiteral(eventDate, XSDdateTime)));
            m.add(createStatement(s, PREMIS_AGENT, createTypedLiteral(userID, XSDstring)));
            m.add(createStatement(s, PREMIS_AGENT, createTypedLiteral(userAgent, XSDstring)));
            if (auditEventType != null) {
                m.add(createStatement(s, PREMIS_TYPE, createResource(auditEventType)));
            }

            final IdentifierConverter<Resource, FedoraResource> translator =
                new PrefixingIdentifierTranslator(getJcrSession(session), baseURL + "/");
            auditResource.replaceProperties(translator, m,
                    auditResource.getTriples(translator, noneOf(RequiredRdfContext.class)));

            // set link to impacted object using a URI property to preserve the link if it's deleted
            try {
                getJcrNode(auditResource).setProperty(PREMIS_OBJ, new URI(uri).toString(), PropertyType.URI);
            } catch (URISyntaxException e) {
                LOGGER.warn("Error creating URI for repository resource {}", uri);
            }

            session.commit();
        } catch (RepositoryException e) {
            throw new RepositoryRuntimeException(e);
        }
    }
/**
     * Creates a node for the audit event under the configured container.
     *
     * @param event to be persisted in the repository
     * @throws java.io.IOException on json mapping error
     */
Creates a node for the audit event under the configured container.
@param event to be persisted in the repository
@throws java.io.IOException on json mapping error
Creates a node for the audit event under the configured container . @param event to be persisted in the repository @throws java . io . IOException on json mapping error
public void createAuditNode(final FedoraEvent event) throws IOException {
        try {
            final String userAgent = event.getInfo().get(USER_AGENT);
            final String baseURL = event.getInfo().get(BASE_URL);
            final String path = event.getPath();
            final String uri = baseURL + path;
            final Instant timestamp =  event.getDate();
            final DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
            df.setTimeZone(TimeZone.getTimeZone("UTC"));
            final String eventDate = df.format(timestamp.toEpochMilli());
            final String userID = event.getUserID();
            final Set<String> eventTypes = AuditUtils.getEventURIs(event.getTypes());
            final Set<String> resourceTypes = event.getResourceTypes();
            final String auditEventType = AuditUtils.getAuditEventType(eventTypes, resourceTypes);
            final String eventPath = getEventPath(event.getEventID());
            final FedoraResource auditResource = containerService.findOrCreate(session,
                    AUDIT_CONTAINER_LOCATION + "/" + eventPath);
            LOGGER.debug("Audit node {} created for event.", event.getEventID());
            final Model m = createDefaultModel();
            final String auditResourceURI = baseURL + AUDIT_CONTAINER_LOCATION + "/" + eventPath;
            final Resource s = createResource(auditResourceURI);
            m.add(createStatement(s, RDF_TYPE, createResource(INTERNAL_EVENT)));
            m.add(createStatement(s, RDF_TYPE, createResource(PREMIS_EVENT)));
            m.add(createStatement(s, RDF_TYPE, createResource(PROV_EVENT)));
            m.add(createStatement(s, PREMIS_TIME, createTypedLiteral(eventDate, XSDdateTime)));
            m.add(createStatement(s, PREMIS_AGENT, createTypedLiteral(userID, XSDstring)));
            m.add(createStatement(s, PREMIS_AGENT, createTypedLiteral(userAgent, XSDstring)));
            if (auditEventType != null) {
                m.add(createStatement(s, PREMIS_TYPE, createResource(auditEventType)));
            }
            final IdentifierConverter<Resource, FedoraResource> translator =
                new PrefixingIdentifierTranslator(getJcrSession(session), baseURL + "/");
            auditResource.replaceProperties(translator, m,
                    auditResource.getTriples(translator, noneOf(RequiredRdfContext.class)));
            try {
                getJcrNode(auditResource).setProperty(PREMIS_OBJ, new URI(uri).toString(), PropertyType.URI);
            } catch (URISyntaxException e) {
                LOGGER.warn("Error creating URI for repository resource {}", uri);
            }
            session.commit();
        } catch (RepositoryException e) {
            throw new RepositoryRuntimeException(e);
        }
    }
public void createAuditNode ( final FedoraEvent event ) throws IOException { try { final String userAgent = event . getInfo ( ) . get ( USER_AGENT ) ; final String baseURL = event . getInfo ( ) . get ( BASE_URL ) ; final String path = event . getPath ( ) ; final String uri = baseURL + path ; final Instant timestamp = event . getDate ( ) ; final DateFormat df = new SimpleDateFormat ( "yyyy-MM-dd'T'HH:mm:ss'Z'" ) ; df . setTimeZone ( TimeZone . getTimeZone ( "UTC" ) ) ; final String eventDate = df . format ( timestamp . toEpochMilli ( ) ) ; final String userID = event . getUserID ( ) ; final Set < String > eventTypes = AuditUtils . getEventURIs ( event . getTypes ( ) ) ; final Set < String > resourceTypes = event . getResourceTypes ( ) ; final String auditEventType = AuditUtils . getAuditEventType ( eventTypes , resourceTypes ) ; final String eventPath = getEventPath ( event . getEventID ( ) ) ; final FedoraResource auditResource = containerService . findOrCreate ( session , AUDIT_CONTAINER_LOCATION + "/" + eventPath ) ; LOGGER . debug ( "Audit node {} created for event." , event . getEventID ( ) ) ; final Model m = createDefaultModel ( ) ; final String auditResourceURI = baseURL + AUDIT_CONTAINER_LOCATION + "/" + eventPath ; final Resource s = createResource ( auditResourceURI ) ; m . add ( createStatement ( s , RDF_TYPE , createResource ( INTERNAL_EVENT ) ) ) ; m . add ( createStatement ( s , RDF_TYPE , createResource ( PREMIS_EVENT ) ) ) ; m . add ( createStatement ( s , RDF_TYPE , createResource ( PROV_EVENT ) ) ) ; m . add ( createStatement ( s , PREMIS_TIME , createTypedLiteral ( eventDate , XSDdateTime ) ) ) ; m . add ( createStatement ( s , PREMIS_AGENT , createTypedLiteral ( userID , XSDstring ) ) ) ; m . add ( createStatement ( s , PREMIS_AGENT , createTypedLiteral ( userAgent , XSDstring ) ) ) ; if ( auditEventType != null ) { m . add ( createStatement ( s , PREMIS_TYPE , createResource ( auditEventType ) ) ) ; } final IdentifierConverter < Resource , FedoraResource > translator = new PrefixingIdentifierTranslator ( getJcrSession ( session ) , baseURL + "/" ) ; auditResource . replaceProperties ( translator , m , auditResource . getTriples ( translator , noneOf ( RequiredRdfContext . class ) ) ) ; try { getJcrNode ( auditResource ) . setProperty ( PREMIS_OBJ , new URI ( uri ) . toString ( ) , PropertyType . URI ) ; } catch ( URISyntaxException e ) { LOGGER . warn ( "Error creating URI for repository resource {}" , uri ) ; } session . commit ( ) ; } catch ( RepositoryException e ) { throw new RepositoryRuntimeException ( e ) ; } }
Creates a node for the audit event under the configured container.
Creates a node for the audit event under the configured container .
// set link to impacted object using a URI property to preserve the link if it's deleted