Skip to content

Commit

Permalink
Submitting some enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
TaylorPhelps committed May 24, 2024
1 parent 06bfafd commit 3e01f23
Show file tree
Hide file tree
Showing 63 changed files with 187 additions and 88 deletions.
3 changes: 2 additions & 1 deletion src/lnp/java/teammates/lnp/cases/BaseLNPTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import teammates.lnp.util.LNPSpecification;
import teammates.lnp.util.LNPTestData;
import teammates.lnp.util.TestProperties;
import teammates.main.Application;
import teammates.test.BaseTestCase;
import teammates.test.FileHelper;

Expand All @@ -51,7 +52,7 @@ public abstract class BaseLNPTestCase extends BaseTestCase {
static final String PUT = HttpPut.METHOD_NAME;
static final String DELETE = HttpDelete.METHOD_NAME;

private static final Logger log = Logger.getLogger();
private static final Logger log = Logger.getLogger(Application.class);

private static final int RESULT_COUNT = 3;

Expand Down
3 changes: 2 additions & 1 deletion src/lnp/java/teammates/lnp/sql/BaseLNPTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import teammates.lnp.util.LNPSpecification;
import teammates.lnp.util.LNPSqlTestData;
import teammates.lnp.util.TestProperties;
import teammates.main.Application;
import teammates.test.BaseTestCase;
import teammates.test.FileHelper;

Expand All @@ -52,7 +53,7 @@ public abstract class BaseLNPTestCase extends BaseTestCase {
static final String PUT = HttpPut.METHOD_NAME;
static final String DELETE = HttpDelete.METHOD_NAME;

private static final Logger log = Logger.getLogger();
private static final Logger log = Logger.getLogger(Application.class);

private static final int RESULT_COUNT = 3;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import teammates.common.util.Const;
import teammates.common.util.Logger;
import teammates.common.util.StringHelper;
import teammates.main.Application;

/**
* This class represents an feedback contribution question result for a given team.
Expand All @@ -18,7 +19,7 @@ public class TeamEvalResult {
public static final int NSU = Const.POINTS_NOT_SURE;
/** did Not SuBmit. */
public static final int NSB = Const.POINTS_NOT_SUBMITTED;
private static final Logger log = Logger.getLogger();
private static final Logger log = Logger.getLogger(Application.class);

/** submission values originally from students of the team. */
public int[][] claimed;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
import teammates.common.util.FieldValidator;
import teammates.common.util.Logger;
import teammates.common.util.SanitizationHelper;
import teammates.main.Application;
import teammates.storage.entity.Course;

/**
* The data transfer object for {@link Course} entities.
*/
public final class CourseAttributes extends EntityAttributes<Course> implements Comparable<CourseAttributes> {

private static final Logger log = Logger.getLogger();
private static final Logger log = Logger.getLogger(Application.class);

private Instant createdAt;
private Instant deletedAt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import teammates.common.util.Const;
import teammates.common.util.JsonUtils;
import teammates.common.util.Logger;
import teammates.main.Application;
import teammates.storage.sqlentity.FeedbackQuestion;

/**
Expand All @@ -43,7 +44,7 @@ public class FeedbackContributionQuestionDetails extends FeedbackQuestionDetails
private static final int SUMMARY_INDEX_CLAIMED = 0;
private static final int SUMMARY_INDEX_PERCEIVED = 1;

private static final Logger log = Logger.getLogger();
private static final Logger log = Logger.getLogger(Application.class);

private boolean isZeroSum;
private boolean isNotSureAllowed;
Expand Down
18 changes: 14 additions & 4 deletions src/main/java/teammates/common/util/Config.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package teammates.common.util;

import teammates.main.Application;

import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Properties;
import java.util.logging.Logger;


/**
* Represents the deployment-specific configuration values of the system.
Expand Down Expand Up @@ -126,14 +130,20 @@ public final class Config {
/** Indicates whether the current server is dev server. */
public static final boolean IS_DEV_SERVER;

private static final Logger log = Logger.getLogger();
private static final Logger log = Logger.getLogger(Config.class.getName());

private static final String PROPERTIES_FILE_NAME = "build.template.properties";

static {
Properties properties = new Properties();
try (InputStream buildPropStream = FileHelper.getResourceAsStream("build.properties")) {
properties.load(buildPropStream);
try (InputStream buildPropStream = FileHelper.getResourceAsStream(PROPERTIES_FILE_NAME)) {
if (buildPropStream != null) {
properties.load(buildPropStream);
} else {
throw new RuntimeException(PROPERTIES_FILE_NAME + " file not found");
}
} catch (IOException e) {
assert false;
throw new RuntimeException("Failed to load properties from " + PROPERTIES_FILE_NAME, e);
}

String appVersion = properties.getProperty("app.version");
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/teammates/common/util/Logger.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;

import jakarta.servlet.http.HttpServletRequest;

Expand All @@ -19,6 +20,7 @@
import teammates.common.datatransfer.logs.RequestLogDetails;
import teammates.common.datatransfer.logs.RequestLogUser;
import teammates.common.datatransfer.logs.SourceLocation;
import teammates.main.Application;

/**
* Allows any component of the application to log messages at appropriate levels.
Expand All @@ -39,10 +41,14 @@ private Logger() {
this.errorLog = java.util.logging.Logger.getLogger(loggerName + "-err");
}

public static Logger getLogger() {
public static Logger getLogger(Class<Application> applicationClass) {
return new Logger();
}

public static Logger getLogger(String name) {
return null;
}

/**
* Logs a message at FINE level.
*/
Expand Down Expand Up @@ -335,4 +341,6 @@ private StackTraceElement getLoggerSource() {
return null;
}

public void log(Level severe, String failedToStartTheServer, Exception e) {
}
}
3 changes: 2 additions & 1 deletion src/main/java/teammates/common/util/StringHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
import com.google.common.base.CharMatcher;

import teammates.common.exception.InvalidParametersException;
import teammates.main.Application;

/**
* Holds String-related helper functions.
*/

public final class StringHelper {
private static final Logger log = Logger.getLogger();
private static final Logger log = Logger.getLogger(Application.class);

private StringHelper() {
// utility class
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/teammates/logic/api/EmailSender.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
import teammates.logic.external.MailgunService;
import teammates.logic.external.MailjetService;
import teammates.logic.external.SendgridService;
import teammates.main.Application;

/**
* Handles operations related to sending emails.
*/
public class EmailSender {

private static final Logger log = Logger.getLogger();
private static final Logger log = Logger.getLogger(Application.class);

private static final EmailSender instance = new EmailSender();
private final EmailSenderService service;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/teammates/logic/api/TaskQueuer.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import teammates.logic.external.GoogleCloudTasksService;
import teammates.logic.external.LocalTaskQueueService;
import teammates.logic.external.TaskQueueService;
import teammates.main.Application;
import teammates.ui.request.FeedbackSessionRemindRequest;
import teammates.ui.request.SendEmailRequest;

Expand All @@ -21,7 +22,7 @@
*/
public class TaskQueuer {

private static final Logger log = Logger.getLogger();
private static final Logger log = Logger.getLogger(Application.class);

private static final TaskQueuer instance = new TaskQueuer();
private final TaskQueueService service;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/teammates/logic/core/CoursesLogic.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import teammates.common.exception.InvalidParametersException;
import teammates.common.util.Const;
import teammates.common.util.Logger;
import teammates.main.Application;
import teammates.storage.api.CoursesDb;
import teammates.storage.sqlentity.Account;

Expand All @@ -28,7 +29,7 @@
*/
public final class CoursesLogic {

private static final Logger log = Logger.getLogger();
private static final Logger log = Logger.getLogger(Application.class);

private static final CoursesLogic instance = new CoursesLogic();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import teammates.common.exception.InvalidParametersException;
import teammates.common.util.Const;
import teammates.common.util.Logger;
import teammates.main.Application;
import teammates.storage.api.FeedbackQuestionsDb;

/**
Expand All @@ -38,7 +39,7 @@ public final class FeedbackQuestionsLogic {

static final String USER_NAME_FOR_SELF = "Myself";

private static final Logger log = Logger.getLogger();
private static final Logger log = Logger.getLogger(Application.class);

private static final FeedbackQuestionsLogic instance = new FeedbackQuestionsLogic();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import teammates.common.util.Const;
import teammates.common.util.Logger;
import teammates.common.util.TimeHelper;
import teammates.main.Application;
import teammates.storage.api.FeedbackSessionsDb;

/**
Expand All @@ -29,7 +30,7 @@
*/
public final class FeedbackSessionsLogic {

private static final Logger log = Logger.getLogger();
private static final Logger log = Logger.getLogger(Application.class);

private static final String ERROR_NON_EXISTENT_FS_STRING_FORMAT = "Trying to %s a non-existent feedback session: ";
private static final String ERROR_NON_EXISTENT_FS_UPDATE = String.format(ERROR_NON_EXISTENT_FS_STRING_FORMAT, "update");
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/teammates/logic/core/InstructorsLogic.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import teammates.common.exception.SearchServiceException;
import teammates.common.util.Const;
import teammates.common.util.Logger;
import teammates.main.Application;
import teammates.storage.api.InstructorsDb;

/**
Expand All @@ -28,7 +29,7 @@
*/
public final class InstructorsLogic {

private static final Logger log = Logger.getLogger();
private static final Logger log = Logger.getLogger(Application.class);

private static final InstructorsLogic instance = new InstructorsLogic();

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/teammates/logic/core/LogicStarter.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
import jakarta.servlet.ServletContextListener;

import teammates.common.util.Logger;
import teammates.main.Application;

/**
* Setup in web.xml to register logic classes at application startup.
*/
public class LogicStarter implements ServletContextListener {

private static final Logger log = Logger.getLogger();
private static final Logger log = Logger.getLogger(Application.class);

/**
* Registers dependencies between different logic classes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import teammates.common.exception.AuthException;
import teammates.common.util.FileHelper;
import teammates.common.util.Logger;
import teammates.main.Application;

/**
* Provides Firebase Admin Auth authentication services.
Expand All @@ -21,7 +22,7 @@
*/
public class FirebaseAuthService implements AuthService {

private static final Logger log = Logger.getLogger();
private static final Logger log = Logger.getLogger(Application.class);

public FirebaseAuthService() throws AuthException {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@
import teammates.common.util.JsonUtils;
import teammates.common.util.Logger;
import teammates.common.util.TaskWrapper;
import teammates.main.Application;

/**
* Holds functions for operations related to Google Cloud Tasks.
*/
public class GoogleCloudTasksService implements TaskQueueService {

private static final Logger log = Logger.getLogger();
private static final Logger log = Logger.getLogger(Application.class);

@Override
public void addDeferredTask(TaskWrapper task, long countdownTime) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import teammates.common.util.HttpRequest;
import teammates.common.util.JsonUtils;
import teammates.common.util.Logger;
import teammates.main.Application;

/**
* Google-based reCAPTCHA verifier service.
Expand All @@ -22,7 +23,7 @@ public class GoogleRecaptchaService implements RecaptchaService {
/** The Google reCAPTCHA API URL to verify the response token. */
private static final String VERIFY_URL = "https://www.google.com/recaptcha/api/siteverify";

private static final Logger log = Logger.getLogger();
private static final Logger log = Logger.getLogger(Application.class);

private final String secretKey;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@
import teammates.common.util.JsonUtils;
import teammates.common.util.Logger;
import teammates.common.util.TaskWrapper;
import teammates.main.Application;

/**
* Holds functions for operations related to task queue in local dev environment.
*/
public class LocalTaskQueueService implements TaskQueueService {

private static final Logger log = Logger.getLogger();
private static final Logger log = Logger.getLogger(Application.class);

@Override
public void addDeferredTask(TaskWrapper task, long countdownTime) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/teammates/logic/external/MailgunService.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import teammates.common.util.EmailSendingStatus;
import teammates.common.util.EmailWrapper;
import teammates.common.util.Logger;
import teammates.main.Application;

/**
* Email sender service provided by Mailgun.
Expand All @@ -25,7 +26,7 @@
*/
public class MailgunService implements EmailSenderService {

private static final Logger log = Logger.getLogger();
private static final Logger log = Logger.getLogger(Application.class);

/**
* {@inheritDoc}
Expand Down
Loading

0 comments on commit 3e01f23

Please sign in to comment.