Commit f6ec6234fd16a0d73c9d53012c38275a79e0b6ac

Authored by Fernando Ribeiro
1 parent 491ddb62f3
Exists in OPENAIRE5.X

The previous version only loads projects if they were created after restarting s…

…ervices. Now it will load also the projects if the file read form Openaire changed its size, meaning some additions/removals and therefore creates a new pairs that will be shown in the field to associate projects in the input-forms. It will not add an overhead because the file only loads again if there are changes to it and not always the authority is called.
setup-data/dspace-source/dspace-api/src/main/java/org/dspace/content/authority/OpenAIREAuthority.java
... ... @@ -87,6 +87,7 @@ public class OpenAIREAuthority implements ChoiceAuthority
87 87 private static final String MinimumChars = "openaire.projects.suggest.minchar";
88 88 private static final String MaxSuggests = "openaire.projects.suggest.max";
89 89 private static final int MaxSuggestionLength = 66;
  90 + private static long filelength = 0;
90 91  
91 92  
92 93 private static List<Pair<String, String>> pairs = null;
... ... @@ -97,7 +98,10 @@ public class OpenAIREAuthority implements ChoiceAuthority
97 98 */
98 99 @SuppressWarnings("unused")
99 100 private static void load () {
100   - if (OpenAIREAuthority.pairs == null) {
  101 + String defsFile = ConfigurationManager.getProperty(OpenAIREAuthority.FileProperty);
  102 + long newFilelength = (new File(defsFile)).length();
  103 +
  104 + if (OpenAIREAuthority.pairs == null || (newFilelength > 0 && filelength != newFilelength)) {
101 105 OpenAIREAuthority.pairs = new ArrayList<Pair<String, String>>();
102 106 String defsFile = ConfigurationManager.getProperty(OpenAIREAuthority.FileProperty);
103 107 if (defsFile == null) OpenAIREAuthority.log.error("Configuration "+OpenAIREAuthority.FileProperty+" not found in dspace.cfg file.");
... ...