update the java docs for the changes added

This commit is contained in:
Rodica Sutu
2018-04-25 09:41:39 +03:00
parent 535d50edd1
commit 62d4840ae1
5 changed files with 32 additions and 16 deletions

View File

@@ -34,13 +34,17 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import org.alfresco.utility.model.TestModel; import org.alfresco.utility.model.TestModel;
/**
* POJO for audit entry
*
* @author Rodica Sutu
* @since 2.7
*/
@Builder @Builder
@Data @Data
@EqualsAndHashCode (callSuper = true)
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@JsonIgnoreProperties (ignoreUnknown = true) @JsonIgnoreProperties (ignoreUnknown = true)

View File

@@ -28,6 +28,7 @@ package org.alfresco.rest.rm.community.model.audit;
/** /**
* Enumerates the list of events audited * Enumerates the list of events audited
*
* @author Rodica Sutu * @author Rodica Sutu
* @since 2.7 * @since 2.7
* *
@@ -36,6 +37,7 @@ public enum AuditEvents
{ {
CREATE_PERSON("Create Person","Create User"), CREATE_PERSON("Create Person","Create User"),
DELETE_PERSON("Delete Person","Delete User"); DELETE_PERSON("Delete Person","Delete User");
/** event audited */ /** event audited */
public final String event; public final String event;

View File

@@ -101,10 +101,10 @@ public class PojoUtility
} }
/** /**
* Converting json to object * Converting json to java object
* *
* @param json The json object to convert * @param json The json object to convert
* @param classz Class (or interface) whose annotations to effectively override * @param classz Class for the java object
* @return The converted java object * @return The converted java object
* @throws JsonProcessingException Throws exceptions if the given object doesn't match to the POJO class model * @throws JsonProcessingException Throws exceptions if the given object doesn't match to the POJO class model
*/ */
@@ -126,6 +126,14 @@ public class PojoUtility
return (T) obj; return (T) obj;
} }
/**
* Converting json array into a list of java objects
*
* @param json The json array to convert
* @param classz Class for the java object
* @return The list of converted java objects
* @throws JsonProcessingException Throws exceptions if the given object doesn't match to the POJO class model
*/
public static <T> List<T> jsonToObject(JSONArray json, Class<T> classz) public static <T> List<T> jsonToObject(JSONArray json, Class<T> classz)
{ {

View File

@@ -43,20 +43,18 @@ import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
/** /**
* The v0 REST API for copy-to (which supports multi-item copy). * The v0 REST API for rm audit logs
* *
* @author Tom Page * @author Rodica Sutu
* @since 2.6 * @since 2.7
*/ */
@Component @Component
public class RMAuditAPI extends BaseAPI public class RMAuditAPI extends BaseAPI
{ {
/** Logger for the class. */ /** Logger for the class. */
private static final Logger LOGGER = LoggerFactory.getLogger(RMAuditAPI.class); private static final Logger LOGGER = LoggerFactory.getLogger(RMAuditAPI.class);
/** The URI for the audit API. */ /** The URI for the audit API. */
/**
* The URI for the copy-to API.
*/
private static final String RM_AUDIT_API = "{0}rma/admin/rmauditlog"; private static final String RM_AUDIT_API = "{0}rma/admin/rmauditlog";
private static final String RM_AUDIT_LOG_API = RM_AUDIT_API + "?{1}"; private static final String RM_AUDIT_LOG_API = RM_AUDIT_API + "?{1}";
@@ -66,8 +64,8 @@ public class RMAuditAPI extends BaseAPI
* @param user The username of the user to use. * @param user The username of the user to use.
* @param password The password of the user. * @param password The password of the user.
* @param size Maximum number of log entries to return * @param size Maximum number of log entries to return
* @param event Only return log entries matching this event * @param event The name of audit event to be retrieved
* @return return the A * @return return Only return log entries matching this event
*/ */
public List<AuditEntry> getRMAuditLog(String user, String password, final int size, final String event) public List<AuditEntry> getRMAuditLog(String user, String password, final int size, final String event)
{ {
@@ -91,7 +89,7 @@ public class RMAuditAPI extends BaseAPI
* *
* @param username The username of the user to use. * @param username The username of the user to use.
* @param password The password of the user. * @param password The password of the user.
* @throws AssertionError If the API call didn't return a 200 response. * @throws AssertionError If the API call didn't clear the audit log.
*/ */
public void clearAuditLog(String username, String password) public void clearAuditLog(String username, String password)
{ {

View File

@@ -28,6 +28,7 @@ package org.alfresco.rest.rm.community.audit;
import static org.alfresco.rest.rm.community.model.audit.AuditEvents.CREATE_PERSON; import static org.alfresco.rest.rm.community.model.audit.AuditEvents.CREATE_PERSON;
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix; import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
import static org.alfresco.utility.report.log.Step.STEP;
import static org.testng.AssertJUnit.assertTrue; import static org.testng.AssertJUnit.assertTrue;
import java.util.List; import java.util.List;
@@ -67,12 +68,15 @@ public class AuditUserEventsTests extends BaseRMRestTest
@AlfrescoTest(jira = "RM-6223") @AlfrescoTest(jira = "RM-6223")
public void createUserEventIsAudited() throws Exception public void createUserEventIsAudited() throws Exception
{ {
STEP("Create a new user.");
String userName = "auditCreateUser" + PREFIX; String userName = "auditCreateUser" + PREFIX;
createUser = getDataUser().createUser(userName); createUser = getDataUser().createUser(userName);
STEP("Get the list of audit entries for the create person event.");
List<AuditEntry> auditEntries = rmAuditAPI.getRMAuditLog(getAdminUser().getPassword(), List<AuditEntry> auditEntries = rmAuditAPI.getRMAuditLog(getAdminUser().getPassword(),
getAdminUser().getPassword(), 100, CREATE_PERSON.event); getAdminUser().getPassword(), 100, CREATE_PERSON.event);
STEP("Check the audit log contains only the entries for the created user.");
assertTrue("The list of events is not filtered by " + CREATE_PERSON.event, assertTrue("The list of events is not filtered by " + CREATE_PERSON.event,
auditEntries.stream().allMatch(auditEntry -> auditEntry.getEvent().equals(CREATE_PERSON.eventDisplayName))); auditEntries.stream().allMatch(auditEntry -> auditEntry.getEvent().equals(CREATE_PERSON.eventDisplayName)));