Open Kilda Java Documentation
AuthPropertyService.java
Go to the documentation of this file.
1 package org.openkilda.service;
2 
3 import org.slf4j.Logger;
4 import org.slf4j.LoggerFactory;
5 
6 import org.springframework.beans.factory.annotation.Autowired;
7 import org.springframework.core.env.Environment;
8 import org.springframework.stereotype.Component;
9 
11 
15 @Component
16 public class AuthPropertyService {
17  private static final Logger LOGGER = LoggerFactory.getLogger(AuthPropertyService.class);
18 
19  public static final String CODE = ".code";
20  public static final String MESSAGE = ".message";
21 
22  @Autowired
23  private Environment authMessages;
24 
31  public Error getError(final String errorMsg) {
32  LOGGER.error("[getError] Error message: " + errorMsg);
33  String errorMessageCode = authMessages.getProperty(errorMsg + CODE);
34  String errorMessage = authMessages.getProperty(errorMsg + MESSAGE);
35  return new Error(Integer.valueOf(errorMessageCode), errorMessage);
36  }
37 
44  public String getMessage(final String msg) {
45  LOGGER.info("[getMessage] Message: " + msg);
46  return authMessages.getProperty(msg);
47  }
48 }