use of teammates.common.util.ActivityLogEntry.Builder in project teammates by TEAMMATES.
the class LogMessageGenerator method generatePageActionLogMessage.
/**
* Generates the log message for an *Action.
*
* @param url URL of the action
* @param params parameterMap of the request
* @param currUser login information generated by {@link teammates.logic.api.GateKeeper}
* @param userAccount authentication user account generated by action
* @param unregisteredStudent authentication unregisteredStudent attributes generated by action
* @param logMessage log message to show to admin
* @return log message in the form specified in {@link ActivityLogEntry}
*/
public String generatePageActionLogMessage(String url, Map<String, String[]> params, UserType currUser, AccountAttributes userAccount, StudentAttributes unregisteredStudent, String logMessage) {
Builder builder = generateBasicLogEntryBuilder(url, params, currUser);
boolean isUnregisteredStudent = unregisteredStudent != null;
boolean isAccountWithGoogleId = userAccount != null && userAccount.googleId != null;
if (isUnregisteredStudent) {
updateInfoForUnregisteredStudent(builder, unregisteredStudent);
} else if (isAccountWithGoogleId) {
updateInfoForNormalUser(builder, currUser, userAccount);
}
builder.withLogMessage(logMessage);
return builder.build().generateLogMessage();
}
use of teammates.common.util.ActivityLogEntry.Builder in project teammates by TEAMMATES.
the class LogMessageGenerator method generateBasicLogEntryBuilder.
/**
* Generates a basic builder for activityLogEntry.
*
* @param url URL of the request
* @param params parameterMap of the request
* @param currUser login information generated by {@link teammates.logic.api.GateKeeper}
* @return Builder builder with basic information
*/
private Builder generateBasicLogEntryBuilder(String url, Map<String, String[]> params, UserType currUser) {
String actionName = getActionNameFromUrl(url);
long currTime = System.currentTimeMillis();
Builder builder = new Builder(actionName, url, currTime);
if (isAutomatedAction(url)) {
builder.withLogId(generateLogIdForAutomatedAction(currTime)).withUserRole(Const.ActivityLog.ROLE_AUTO);
} else if (currUser == null) {
builder.withLogId(generateLogIdWithoutGoogleId(params, currTime)).withUserGoogleId(Const.ActivityLog.AUTH_NOT_LOGIN);
} else {
builder.withLogId(generateLogIdWithGoogleId(currUser.id, currTime)).withUserGoogleId(currUser.id);
updateRoleForLoggedInUser(builder, currUser);
}
return builder;
}
Aggregations