Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADDR-132: Add 'Get Global Properties' proxy privilege #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
public class AddressHierarchyServiceImpl implements AddressHierarchyService {

protected static final Log log = LogFactory.getLog(AddressHierarchyServiceImpl.class);


private static final String GET_GLOBAL_PROPERTIES = "Get Global Properties";
private AddressHierarchyDAO dao;

private Map<Locale, Map<String,List<String>> > fullAddressCache;
Expand Down Expand Up @@ -705,18 +706,26 @@ else if (level.getParent() == null){
synchronized public void initializeFullAddressCache() {

// generally, this global property should be set to true; it just allows cache load to be disabled to speed startup
if (Context.getAdministrationService().getGlobalProperty(AddressHierarchyConstants.GLOBAL_PROP_INITIALIZE_ADDRESS_HIERARCHY_CACHE_ON_STARTUP).equalsIgnoreCase("true")) {

// only initialize if necessary (and if we have entries)
if ((this.fullAddressCacheInitialized == false || MapUtils.isEmpty(this.fullAddressCache))
&& this.getAddressHierarchyEntryCount() > 0) {

this.fullAddressCache = new HashMap<Locale, Map<String,List<String>> >();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we revert the formatting changes?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. let me do that

Locale locale = i18nCache.getLocaleForFullAddressCache();
getAddressesForLocale(locale);
this.fullAddressCacheInitialized = true;
try {
Context.addProxyPrivilege(GET_GLOBAL_PROPERTIES);
if (Context.getAdministrationService()
.getGlobalProperty(AddressHierarchyConstants.GLOBAL_PROP_INITIALIZE_ADDRESS_HIERARCHY_CACHE_ON_STARTUP)
.equalsIgnoreCase("true")) {

// only initialize if necessary (and if we have entries)
if ((this.fullAddressCacheInitialized == false || MapUtils.isEmpty(this.fullAddressCache))
&& this.getAddressHierarchyEntryCount() > 0) {

this.fullAddressCache = new HashMap<Locale, Map<String, List<String>>>();
Locale locale = i18nCache.getLocaleForFullAddressCache();
getAddressesForLocale(locale);
this.fullAddressCacheInitialized = true;
}
}
}
finally {
Context.removeProxyPrivilege(GET_GLOBAL_PROPERTIES);
}

}

Expand Down