Adding constants

revert-70aa11f8
Ace 6 years ago
parent 8bc15e1f14
commit b39be48919

@ -63,6 +63,12 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
private static Log log = LogFactory.getLog(GeoLocationBasedServiceImpl.class);
public static final String EMAIL_DOMAIN_SEPARATOR = "@";
public static final String EMAIL_DOMAIN_SEPARATOR_REPLACEMENT = "-AT-";
public static final String SECONDERY_USER_STORE_SEPERATOR = ":";
public static final String SECONDERY_USER_STORE_DEFAULT_SEPERATOR = "/";
@Path("stats/{deviceType}/{deviceId}")
@GET
@Consumes("application/json")
@ -96,7 +102,7 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
sortByFields.add(sortByField);
// this is the user who initiates the request
String authorizedUser = CarbonContext.getThreadLocalCarbonContext().getUsername() + "@" +
String authorizedUser = CarbonContext.getThreadLocalCarbonContext().getUsername() + EMAIL_DOMAIN_SEPARATOR +
CarbonContext.getThreadLocalCarbonContext().getTenantDomain();
try {
@ -577,4 +583,46 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
eventBean.setValues(record.getValues());
return eventBean;
}
/**
* When an input is having '@',replace it with '-AT-' [This is required to
* persist WebApp data in registry,as registry paths don't allow '@' sign.]
*
* @param input
* inputString
* @return String modifiedString
*/
public static String replaceEmailDomain(String input) {
if (input != null && input.contains(EMAIL_DOMAIN_SEPARATOR)) {
input =
input.replace(EMAIL_DOMAIN_SEPARATOR,
EMAIL_DOMAIN_SEPARATOR_REPLACEMENT);
}
return input;
}
/**
* When an input is having '-AT-',replace it with @ [This is required to
* persist WebApp data between registry and database]
*
* @param input
* inputString
* @return String modifiedString
*/
public static String replaceEmailDomainBack(String input) {
if (input != null){
if (input.contains(EMAIL_DOMAIN_SEPARATOR_REPLACEMENT)) {
input =
input.replace(EMAIL_DOMAIN_SEPARATOR_REPLACEMENT,
EMAIL_DOMAIN_SEPARATOR);
}else if (input.contains(SECONDERY_USER_STORE_SEPERATOR)){
input =
input.replace(SECONDERY_USER_STORE_SEPERATOR,
SECONDERY_USER_STORE_DEFAULT_SEPERATOR);
}
}
return input;
}
}

Loading…
Cancel
Save