Skip to content

Commit

Permalink
LBAC-13 Added implementation to create RefApp location glopal property
Browse files Browse the repository at this point in the history
LBAC-13 Added implementation to create RefApp location glopal property
  • Loading branch information
Suthagar23 committed Jul 27, 2018
1 parent 4faaa2f commit b5507b5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

package org.openmrs.module.locationbasedaccess;

import org.apache.commons.lang.StringUtils;
import org.openmrs.api.context.Context;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.openmrs.module.BaseModuleActivator;
Expand Down Expand Up @@ -45,6 +47,19 @@ public void willStart() {
* @see ModuleActivator#started()
*/
public void started() {
String refAppLocationGlobalProperty = Context.getAdministrationService().getGlobalProperty(LocationBasedAccessConstants.REF_APP_LOCATION_USER_PROPERTY_NAME);
if(StringUtils.isBlank(refAppLocationGlobalProperty)) {
Context.getAdministrationService().setGlobalProperty(LocationBasedAccessConstants.REF_APP_LOCATION_USER_PROPERTY_NAME,
LocationBasedAccessConstants.LOCATION_USER_PROPERTY_NAME);
if(log.isDebugEnabled()) {
log.debug("RefApp Location global property created with value - " + LocationBasedAccessConstants.LOCATION_USER_PROPERTY_NAME);
}
}
else if(StringUtils.isNotBlank(refAppLocationGlobalProperty) && !refAppLocationGlobalProperty.equals(LocationBasedAccessConstants.LOCATION_USER_PROPERTY_NAME)) {
log.warn("RefApp Location global property already exist in the system with different value(" + refAppLocationGlobalProperty +
"). Exiting from creating new global property with the value " + LocationBasedAccessConstants.LOCATION_USER_PROPERTY_NAME);
}

log.info("Location Based Access Control Module started");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ public class LocationBasedAccessConstants {

public static final String LOCATION_ATTRIBUTE_GLOBAL_PROPERTY_NAME = "locationbasedaccess.locationAttributeUuid";
public static final String LOCATION_USER_PROPERTY_NAME = "locationUuid";

public static final String REF_APP_LOCATION_USER_PROPERTY_NAME = "referenceapplication.locationUserPropertyName";
}

0 comments on commit b5507b5

Please sign in to comment.