Commit 7acac55e4fc696dc9ed2649e832892b98bbca149

Authored by Fernando Ribeiro
1 parent c892e1d9de
Exists in OPENAIRE5.X

Deleted folder and add new files

Readme.md
... ... @@ -0,0 +1,186 @@
  1 +# How to install the Add-on
  2 +The detailed instructions can be found in the docs folder.
  3 +
  4 +## Copy the new files
  5 +Copy the new files to the source directory
  6 +
  7 +If you are in Linux
  8 +
  9 + cp -r $PATH_TO _ADDON/setup-data/dspace-source/* $DSPACE_SRC/
  10 +
  11 +Where $PATH_TO _ADDON is the directory where you put the add-on for instalation and $DSPACE_SRC/ is the source directory.
  12 +
  13 +As an example: If the addon is in the opt directory and dspace source is in /src-dspace/dspace32 the command is:
  14 +
  15 + cp -r /opt/setup-data/dspace-source/* /src-dspace/dspace32/
  16 +
  17 +
  18 +## Adding the new entries in the Messages.properties and in Messages_pt_PT.properties
  19 +Add the fowlowing messages to Messages.properties:
  20 +
  21 + jsp.authority.confidence.description.blank = OpenAIRE project checked
  22 + jsp.tools.lookup.title = FP7/ERC project selection
  23 + jsp.tools.lookup.heading = Verifying value…
  24 + jsp.tools.lookup.accept = Accept
  25 + jsp.tools.lookup.add = Add
  26 + jsp.tools.lookup.cancel = Cancel
  27 + jsp.tools.lookup.more = See more results
  28 + jsp.tools.lookup.fail = Failed to load information:
  29 + jsp.tools.lookup.results = Results @1@ until @2@ of @3@ for the search "@4@"
  30 + jsp.tools.lookup.lookup = Search
  31 + jsp.tools.lookup.field.dc_relation.title = FP7 project containing the term
  32 + jsp.tools.lookup.field.dc_relation.help = FP7 Project ID (If accepted this value will pass to the textbox)
  33 + jsp.tools.lookup.field.dc_relation.nonauthority = Not identified
  34 +
  35 +Add the fowlowing messages to Messages_pt_PT.properties:
  36 +
  37 + jsp.authority.confidence.description.blank = Projecto OpenAIRE verificado
  38 + jsp.tools.lookup.title = Selecção do projecto FP7/ERC
  39 + jsp.tools.lookup.heading = A Verificar valor…
  40 + jsp.tools.lookup.accept = Aceitar
  41 + jsp.tools.lookup.add = Adicionar
  42 + jsp.tools.lookup.cancel = Cancelar
  43 + jsp.tools.lookup.more = Ver Mais Resultados
  44 + jsp.tools.lookup.fail = Falha ao carregar informação:
  45 + jsp.tools.lookup.results = Resultados @1@ até @2@ de @3@ para o termo "@4@"
  46 + jsp.tools.lookup.lookup = Pesquisar
  47 + jsp.tools.lookup.field.dc_relation.title = Projetos FP7 contendo o termo pesquisado
  48 + jsp.tools.lookup.field.dc_relation.help = Identificador do projeto (Se aceitar este valor ser colocado na caixa de texto do projecto)
  49 + jsp.tools.lookup.field.dc_relation.nonauthority = Projecto não identificado
  50 +
  51 +#Change the dspace.cfg
  52 +Edit dspace.cfg in $DSPACE_SRC/dspace/config/dspace.cfg.
  53 +Uncomment the lines of the authority control plugins and add OpenAire.
  54 +
  55 + plugin.named.org.dspace.content.authority.ChoiceAuthority = \
  56 + org.dspace.content.authority.OpenAIREAuthority = OpenAIRE
  57 +
  58 +If there are more Choices of authority the options must be added like the example:
  59 + plugin.named.org.dspace.content.authority.ChoiceAuthority = \
  60 + org.dspace.content.authority.SampleAuthority = Sample, \
  61 + ...
  62 + ...
  63 + org.dspace.content.authority.OpenAIREAuthority = OpenAIRE
  64 +
  65 + where ... are the other authority options
  66 +
  67 +Add also, the following options to dspace.cfg (if they exist, only change their values)
  68 +
  69 + choices.plugin.dc.relation = OpenAIRE
  70 + choices.presentation.dc.relation = suggest
  71 + authority.controlled.dc.relation = true
  72 +
  73 +Add also the following lines (if they exist, only change their values)
  74 +
  75 + openaire.projects.filename = ${dspace.dir}/config/openaire-cache.list
  76 + # One or more urls/file paths (separeted by 3 hash chars (#, i.e. ###)) in DSpace form-value-pairs XML format (take http://api.openaire.eu/projects/dspace/FP7/ALL/ALL as an example)
  77 + openaire.projects.url = "http://api.openaire.eu/projects/dspace/FP7/ALL/ALL###http://api.openaire.eu/projects/dspace/WT/ALL/ALL"
  78 + # Minimum of chars to start searching on the list (default >= 4)
  79 + openaire.projects.suggest.minchar = 4
  80 + # Maximum of projects listed (default <= 10)
  81 + openaire.projects.suggest.max = 20
  82 +
  83 +For the Portuguese projects change to:
  84 + openaire.projects.url = "http://api.openaire.eu/projects/dspace/FP7/ALL/ALL###http://api.openaire.eu/projects/dspace/WT/ALL/ALL###http://api.openaire.eu/projects/dspace/FCT/ALL/ALL"
  85 +
  86 +## Change the inupt-forms.xml
  87 +
  88 +At $DSPACE_SRC/config/input-forms.xml after '<page number="1">' add:
  89 +
  90 + <field>
  91 + <dc-schema>dc</dc-schema>
  92 + <dc-element>relation</dc-element>
  93 + <dc-qualifier></dc-qualifier>
  94 + <repeatable>false</repeatable>
  95 + <label>OpenAIRE Project Identifier</label>
  96 + <input-type>onebox</input-type>
  97 + <hint>Enter the search term (number, name or acronym) of the European project (EC / ERC), National project (FCT) or any other international project/initiative (WT)gt;</hint>
  98 + </field>
  99 +
  100 +## Change xoai.xml configuration
  101 +At $DSPACE_SRC/config/crosswalks/oai/xoai.xml
  102 +Before </Contexts> add:
  103 +
  104 + <Context baseurl="fct" name="FCT Context">
  105 + <!-- Date format, field prefixes, etc are ensured by the transformer -->
  106 + <Transformer ref="openaireTransformer"/>
  107 + <!-- OpenAIRE filter -->
  108 + <Filter ref="fctFilter"/>
  109 + <!-- Just an alias, in fact it returns all items within the driver context -->
  110 + <Set ref="fctSet"/>
  111 + <!-- Metadata Formats -->
  112 + <Format ref="oaidc"/>
  113 + <Format ref="mets"/>
  114 + <Description>
  115 + This contexts complies with FCT rules.
  116 + </Description>
  117 + </Context>
  118 +
  119 +After last </Filter> add:
  120 +
  121 + <Filter id="fctFilter">
  122 + <Definition>
  123 + <And>
  124 + <LeftCondition>
  125 + <And>
  126 + <LeftCondition>
  127 + <Custom ref="titleExistsCondition"/>
  128 + </LeftCondition>
  129 + <RightCondition>
  130 + <Custom ref="authorExistsCondition"/>
  131 + </RightCondition>
  132 + </And>
  133 + </LeftCondition>
  134 + <RightCondition>
  135 + <And>
  136 + <LeftCondition>
  137 + <Custom ref="driverDocumentTypeCondition"/>
  138 + </LeftCondition>
  139 + <RightCondition>
  140 + <Custom ref="fctRelationCondition"/>
  141 + </RightCondition>
  142 + </And>
  143 + </RightCondition>
  144 + </And>
  145 + </Definition>
  146 + </Filter>
  147 + <CustomCondition id="fctRelationCondition">
  148 + <Class>org.dspace.xoai.filter.DSpaceAtLeastOneMetadataFilter</Class>
  149 + <Configuration>
  150 + <string name="field">dc.relation</string>
  151 + <string name="operator">starts_with</string>
  152 + <string name="value">info:eu-repo/grantAgreement/FCT</string>
  153 + </Configuration>
  154 + </CustomCondition>
  155 +
  156 +
  157 +Before </Sets> add:
  158 +
  159 + <Set id="fctSet">
  160 + <Spec>fct_fundedresources</Spec>
  161 + <Name>fct_fundedresources set</Name>
  162 + <!-- Just an alias -->
  163 + </Set>
  164 +
  165 +
  166 +
  167 +## After instalation
  168 +After building DSpace (mvn & ant - see the DSpace Documentation), configure cron to refresh the openaire project list, for example:
  169 +
  170 + 0 0 * * * $DSPACE_BIN/bin/openaire-refresh-list
  171 +
  172 +Run the script (for the addon to work)
  173 +
  174 + $DSPACE_BIN/bin/openaire-refresh-list
  175 +
  176 +## Developers
  177 +The OpenaAirAuthorityControl Add-on was developed in the context of RCAAP Project[RCAAP](www.rcaap.pt) by [KEEP SOLUTIONS](http:///www.keep.pt), a spin-off of the University of Minho, specialized in digital preservation and advanced solutions for digital archives and libraries, in partnership with the [Documentation Services](http://www.sdum.uminho.pt/) of the University of Minho.
  178 +
  179 +
  180 +## Need help, or give any type of contribution?
  181 +
  182 +Please contact us at [FCT|FCCN](http://www.fccn.pt) or any commiter.
  183 +
  184 +## License
  185 +
  186 +Please contact us at [FCT|FCCN](http://www.fccn.pt).
0 187 \ No newline at end of file
... ...
info.txt
... ... @@ -0,0 +1 @@
  1 +Version: 3.1
... ...
openaireauthcontrol_v3.1_dspace5.X/Readme.md
... ... @@ -1,186 +0,0 @@
1   -# How to install the Add-on
2   -The detailed instructions can be found in the docs folder.
3   -
4   -## Copy the new files
5   -Copy the new files to the source directory
6   -
7   -If you are in Linux
8   -
9   - cp -r $PATH_TO _ADDON/setup-data/dspace-source/* $DSPACE_SRC/
10   -
11   -Where $PATH_TO _ADDON is the directory where you put the add-on for instalation and $DSPACE_SRC/ is the source directory.
12   -
13   -As an example: If the addon is in the opt directory and dspace source is in /src-dspace/dspace32 the command is:
14   -
15   - cp -r /opt/setup-data/dspace-source/* /src-dspace/dspace32/
16   -
17   -
18   -## Adding the new entries in the Messages.properties and in Messages_pt_PT.properties
19   -Add the fowlowing messages to Messages.properties:
20   -
21   - jsp.authority.confidence.description.blank = OpenAIRE project checked
22   - jsp.tools.lookup.title = FP7/ERC project selection
23   - jsp.tools.lookup.heading = Verifying value…
24   - jsp.tools.lookup.accept = Accept
25   - jsp.tools.lookup.add = Add
26   - jsp.tools.lookup.cancel = Cancel
27   - jsp.tools.lookup.more = See more results
28   - jsp.tools.lookup.fail = Failed to load information:
29   - jsp.tools.lookup.results = Results @1@ until @2@ of @3@ for the search "@4@"
30   - jsp.tools.lookup.lookup = Search
31   - jsp.tools.lookup.field.dc_relation.title = FP7 project containing the term
32   - jsp.tools.lookup.field.dc_relation.help = FP7 Project ID (If accepted this value will pass to the textbox)
33   - jsp.tools.lookup.field.dc_relation.nonauthority = Not identified
34   -
35   -Add the fowlowing messages to Messages_pt_PT.properties:
36   -
37   - jsp.authority.confidence.description.blank = Projecto OpenAIRE verificado
38   - jsp.tools.lookup.title = Selec&ccedil;&atilde;o do projecto FP7/ERC
39   - jsp.tools.lookup.heading = A Verificar valor…
40   - jsp.tools.lookup.accept = Aceitar
41   - jsp.tools.lookup.add = Adicionar
42   - jsp.tools.lookup.cancel = Cancelar
43   - jsp.tools.lookup.more = Ver Mais Resultados
44   - jsp.tools.lookup.fail = Falha ao carregar informa&ccedil;&atilde;o:
45   - jsp.tools.lookup.results = Resultados @1@ at&eacute; @2@ de @3@ para o termo "@4@"
46   - jsp.tools.lookup.lookup = Pesquisar
47   - jsp.tools.lookup.field.dc_relation.title = Projetos FP7 contendo o termo pesquisado
48   - jsp.tools.lookup.field.dc_relation.help = Identificador do projeto (Se aceitar este valor ser colocado na caixa de texto do projecto)
49   - jsp.tools.lookup.field.dc_relation.nonauthority = Projecto n&atilde;o identificado
50   -
51   -#Change the dspace.cfg
52   -Edit dspace.cfg in $DSPACE_SRC/dspace/config/dspace.cfg.
53   -Uncomment the lines of the authority control plugins and add OpenAire.
54   -
55   - plugin.named.org.dspace.content.authority.ChoiceAuthority = \
56   - org.dspace.content.authority.OpenAIREAuthority = OpenAIRE
57   -
58   -If there are more Choices of authority the options must be added like the example:
59   - plugin.named.org.dspace.content.authority.ChoiceAuthority = \
60   - org.dspace.content.authority.SampleAuthority = Sample, \
61   - ...
62   - ...
63   - org.dspace.content.authority.OpenAIREAuthority = OpenAIRE
64   -
65   - where ... are the other authority options
66   -
67   -Add also, the following options to dspace.cfg (if they exist, only change their values)
68   -
69   - choices.plugin.dc.relation = OpenAIRE
70   - choices.presentation.dc.relation = suggest
71   - authority.controlled.dc.relation = true
72   -
73   -Add also the following lines (if they exist, only change their values)
74   -
75   - openaire.projects.filename = ${dspace.dir}/config/openaire-cache.list
76   - # One or more urls/file paths (separeted by 3 hash chars (#, i.e. ###)) in DSpace form-value-pairs XML format (take http://api.openaire.eu/projects/dspace/FP7/ALL/ALL as an example)
77   - openaire.projects.url = "http://api.openaire.eu/projects/dspace/FP7/ALL/ALL###http://api.openaire.eu/projects/dspace/WT/ALL/ALL"
78   - # Minimum of chars to start searching on the list (default >= 4)
79   - openaire.projects.suggest.minchar = 4
80   - # Maximum of projects listed (default <= 10)
81   - openaire.projects.suggest.max = 20
82   -
83   -For the Portuguese projects change to:
84   - openaire.projects.url = "http://api.openaire.eu/projects/dspace/FP7/ALL/ALL###http://api.openaire.eu/projects/dspace/WT/ALL/ALL###http://api.openaire.eu/projects/dspace/FCT/ALL/ALL"
85   -
86   -## Change the inupt-forms.xml
87   -
88   -At $DSPACE_SRC/config/input-forms.xml after '<page number="1">' add:
89   -
90   - <field>
91   - <dc-schema>dc</dc-schema>
92   - <dc-element>relation</dc-element>
93   - <dc-qualifier></dc-qualifier>
94   - <repeatable>false</repeatable>
95   - <label>OpenAIRE Project Identifier</label>
96   - <input-type>onebox</input-type>
97   - <hint>Enter the search term (number, name or acronym) of the European project (EC / ERC), National project (FCT) or any other international project/initiative (WT)gt;</hint>
98   - </field>
99   -
100   -## Change xoai.xml configuration
101   -At $DSPACE_SRC/config/crosswalks/oai/xoai.xml
102   -Before </Contexts> add:
103   -
104   - <Context baseurl="fct" name="FCT Context">
105   - <!-- Date format, field prefixes, etc are ensured by the transformer -->
106   - <Transformer ref="openaireTransformer"/>
107   - <!-- OpenAIRE filter -->
108   - <Filter ref="fctFilter"/>
109   - <!-- Just an alias, in fact it returns all items within the driver context -->
110   - <Set ref="fctSet"/>
111   - <!-- Metadata Formats -->
112   - <Format ref="oaidc"/>
113   - <Format ref="mets"/>
114   - <Description>
115   - This contexts complies with FCT rules.
116   - </Description>
117   - </Context>
118   -
119   -After last </Filter> add:
120   -
121   - <Filter id="fctFilter">
122   - <Definition>
123   - <And>
124   - <LeftCondition>
125   - <And>
126   - <LeftCondition>
127   - <Custom ref="titleExistsCondition"/>
128   - </LeftCondition>
129   - <RightCondition>
130   - <Custom ref="authorExistsCondition"/>
131   - </RightCondition>
132   - </And>
133   - </LeftCondition>
134   - <RightCondition>
135   - <And>
136   - <LeftCondition>
137   - <Custom ref="driverDocumentTypeCondition"/>
138   - </LeftCondition>
139   - <RightCondition>
140   - <Custom ref="fctRelationCondition"/>
141   - </RightCondition>
142   - </And>
143   - </RightCondition>
144   - </And>
145   - </Definition>
146   - </Filter>
147   - <CustomCondition id="fctRelationCondition">
148   - <Class>org.dspace.xoai.filter.DSpaceAtLeastOneMetadataFilter</Class>
149   - <Configuration>
150   - <string name="field">dc.relation</string>
151   - <string name="operator">starts_with</string>
152   - <string name="value">info:eu-repo/grantAgreement/FCT</string>
153   - </Configuration>
154   - </CustomCondition>
155   -
156   -
157   -Before </Sets> add:
158   -
159   - <Set id="fctSet">
160   - <Spec>fct_fundedresources</Spec>
161   - <Name>fct_fundedresources set</Name>
162   - <!-- Just an alias -->
163   - </Set>
164   -
165   -
166   -
167   -## After instalation
168   -After building DSpace (mvn & ant - see the DSpace Documentation), configure cron to refresh the openaire project list, for example:
169   -
170   - 0 0 * * * $DSPACE_BIN/bin/openaire-refresh-list
171   -
172   -Run the script (for the addon to work)
173   -
174   - $DSPACE_BIN/bin/openaire-refresh-list
175   -
176   -## Developers
177   -The OpenaAirAuthorityControl Add-on was developed in the context of RCAAP Project[RCAAP](www.rcaap.pt) by [KEEP SOLUTIONS](http:///www.keep.pt), a spin-off of the University of Minho, specialized in digital preservation and advanced solutions for digital archives and libraries, in partnership with the [Documentation Services](http://www.sdum.uminho.pt/) of the University of Minho.
178   -
179   -
180   -## Need help, or give any type of contribution?
181   -
182   -Please contact us at [FCT|FCCN](http://www.fccn.pt) or any commiter.
183   -
184   -## License
185   -
186   -Please contact us at [FCT|FCCN](http://www.fccn.pt).
187 0 \ No newline at end of file
openaireauthcontrol_v3.1_dspace5.X/info.txt
... ... @@ -1 +0,0 @@
1   -Version: 3.1
openaireauthcontrol_v3.1_dspace5.X/setup-data/dspace-source/dspace-api/src/main/java/org/dspace/content/authority/OpenAIREAuthority.java
... ... @@ -1,189 +0,0 @@
1   -/*
2   - * DCInputAuthority.java
3   - *
4   - * Version: $Revision: 1.1 $
5   - *
6   - * Date: $Date: 2009/07/23 05:07:01 $
7   - *
8   - * Copyright (c) 2002-2009, The DSpace Foundation. All rights reserved.
9   - *
10   - * Redistribution and use in source and binary forms, with or without
11   - * modification, are permitted provided that the following conditions are
12   - * met:
13   - *
14   - * - Redistributions of source code must retain the above copyright
15   - * notice, this list of conditions and the following disclaimer.
16   - *
17   - * - Redistributions in binary form must reproduce the above copyright
18   - * notice, this list of conditions and the following disclaimer in the
19   - * documentation and/or other materials provided with the distribution.
20   - *
21   - * - Neither the name of the DSpace Foundation nor the names of its
22   - * contributors may be used to endorse or promote products derived from
23   - * this software without specific prior written permission.
24   - *
25   - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26   - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27   - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28   - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29   - * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30   - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31   - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
32   - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
33   - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
34   - * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
35   - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
36   - * DAMAGE.
37   - */
38   -package org.dspace.content.authority;
39   -
40   -import java.io.File;
41   -import java.util.ArrayList;
42   -import java.util.List;
43   -
44   -import javax.xml.parsers.DocumentBuilder;
45   -import javax.xml.parsers.DocumentBuilderFactory;
46   -
47   -import org.apache.log4j.Logger;
48   -import org.dspace.core.ConfigurationManager;
49   -import org.w3c.dom.Document;
50   -import org.w3c.dom.Element;
51   -import org.w3c.dom.Node;
52   -import org.w3c.dom.NodeList;
53   -
54   -/**
55   - * ChoiceAuthority source that reads the same input-forms which drive
56   - * configurable submission.
57   - *
58   - * Configuration:
59   - * This MUST be configured aas a self-named plugin, e.g.:
60   - * plugin.selfnamed.org.dspace.content.authority.ChoiceAuthority = \
61   - * org.dspace.content.authority.DCInputAuthority
62   - *
63   - * It AUTOMATICALLY configures a plugin instance for each <value-pairs>
64   - * element (within <form-value-pairs>) of the input-forms.xml. The name
65   - * of the instance is the "value-pairs-name" attribute, e.g.
66   - * the element: <value-pairs value-pairs-name="common_types" dc-term="type">
67   - * defines a plugin instance "common_types".
68   - *
69   - * IMPORTANT NOTE: Since these value-pairs do NOT include authority keys,
70   - * the choice lists derived from them do not include authority values.
71   - * So you should not use them as the choice source for authority-controlled
72   - * fields.
73   - */
74   -public class OpenAIREAuthority implements ChoiceAuthority
75   -{
76   - static {
77   - try {
78   - load();
79   - } catch (Exception ex) {
80   - OpenAIREAuthority.log.error("Error",ex);
81   - OpenAIREAuthority.pairs = new ArrayList<Pair<String,String>>();
82   - }
83   - }
84   -
85   - private static Logger log = Logger.getLogger(OpenAIREAuthority.class);
86   - private static final String FileProperty = "openaire.projects.filename";
87   - private static final String MinimumChars = "openaire.projects.suggest.minchar";
88   - private static final String MaxSuggests = "openaire.projects.suggest.max";
89   - private static final int MaxSuggestionLength = 66;
90   -
91   -
92   - private static List<Pair<String, String>> pairs = null;
93   -
94   - /**
95   - * Loads the data, parsing the file defined at the 'openaire.projects.filename' dspace
96   - * property.
97   - */
98   - @SuppressWarnings("unused")
99   - private static void load () {
100   - if (OpenAIREAuthority.pairs == null) {
101   - OpenAIREAuthority.pairs = new ArrayList<Pair<String, String>>();
102   - String defsFile = ConfigurationManager.getProperty(OpenAIREAuthority.FileProperty);
103   - if (defsFile == null) OpenAIREAuthority.log.error("Configuration "+OpenAIREAuthority.FileProperty+" not found in dspace.cfg file.");
104   - else {
105   - try {
106   - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
107   - DocumentBuilder builder = factory.newDocumentBuilder();
108   - Document doc = builder.parse(new File(defsFile));
109   - doc.getDocumentElement().normalize();
110   -
111   - NodeList nodes = doc.getElementsByTagName("pair");
112   - for (int i = 0; i < nodes.getLength(); i++) {
113   - Node node = nodes.item(i);
114   - if (node.getNodeType() == Node.ELEMENT_NODE) {
115   - // OK!
116   - Element element = (Element) node;
117   - Pair<String, String> pair = new Pair<String, String>();
118   - pair.fst = element.getElementsByTagName("displayed-value").item(0).getFirstChild().getNodeValue();
119   - pair.snd = element.getElementsByTagName("stored-value").item(0).getFirstChild().getNodeValue();
120   - OpenAIREAuthority.pairs.add(pair);
121   - } else
122   - throw new Exception("Invalid Node readed");
123   - }
124   - } catch (Exception e) {
125   - OpenAIREAuthority.log.error("Unable to parse file "+defsFile, e);
126   - }
127   - }
128   - }
129   - }
130   -
131   - private String getPrettyChoiceText (String text) {
132   - if (text.length() > OpenAIREAuthority.MaxSuggestionLength) {
133   - return text.substring(0, OpenAIREAuthority.MaxSuggestionLength - 3) + "...";
134   - } else return text;
135   - }
136   -
137   - public Choices getMatches(String field, String text, int collection, int start,
138   - int limit, String locale) {
139   - OpenAIREAuthority.load();
140   - int minChars = ConfigurationManager.getIntProperty(OpenAIREAuthority.MinimumChars, 4);
141   - int maxSuggests = ConfigurationManager.getIntProperty(OpenAIREAuthority.MaxSuggests, 10);
142   -
143   - List<Choice> result = new ArrayList<Choice>();
144   - int dflt = -1;
145   - int type = Choices.CF_NOTFOUND;
146   - int added = 0;
147   - if (text != null && text.length() >= minChars) {
148   - for (int i = 0; i < OpenAIREAuthority.pairs.size() && added < maxSuggests; ++i)
149   - {
150   - if (OpenAIREAuthority.pairs.get(i).fst.toLowerCase().contains(text.toLowerCase()))
151   - {
152   - Choice cs = new Choice(String.valueOf(i), OpenAIREAuthority.pairs.get(i).snd, this.getPrettyChoiceText(OpenAIREAuthority.pairs.get(i).fst));
153   - result.add(cs);
154   - added++;
155   - if (OpenAIREAuthority.pairs.get(i).fst.equalsIgnoreCase(text))
156   - dflt = i;
157   - }
158   - }
159   - if (added > 0) type = Choices.CF_AMBIGUOUS;
160   - else type = Choices.CF_NOTFOUND;
161   - }
162   - return new Choices(result.toArray(new Choice[] {}), 0, result.size(), type, false, dflt);
163   - }
164   -
165   - public Choices getBestMatch(String field, String text, int collection, String locale) {
166   - OpenAIREAuthority.load();
167   - for (int i = 0; i < OpenAIREAuthority.pairs.size(); ++i)
168   - {
169   - if (OpenAIREAuthority.pairs.get(i).fst.toLowerCase().equals(text.toLowerCase()))
170   - {
171   - Choice v[] = new Choice[1];
172   - v[0] = new Choice(String.valueOf(i), OpenAIREAuthority.pairs.get(i).snd, this.getPrettyChoiceText(OpenAIREAuthority.pairs.get(i).fst));
173   - return new Choices(v, 0, v.length, Choices.CF_UNCERTAIN, false, 0);
174   - }
175   - }
176   - return new Choices(Choices.CF_NOTFOUND);
177   - }
178   -
179   - public String getLabel(String field, String key, String locale) {
180   - OpenAIREAuthority.load();
181   - return OpenAIREAuthority.pairs.get(Integer.parseInt(key)).fst;
182   - }
183   -
184   -}
185   -
186   -class Pair<T, V> {
187   - public T fst;
188   - public V snd;
189   -}
openaireauthcontrol_v3.1_dspace5.X/setup-data/dspace-source/dspace/bin/openaire-refresh-list
... ... @@ -1,51 +0,0 @@
1   -#!/bin/bash
2   -
3   -# Get the DSPACE/bin directory
4   -BINDIR=$(dirname $0)
5   -
6   -echo "> Starting \"$0\" execution..."
7   -
8   -echo "Updating OpenAIRE Project list"
9   -
10   -# Read parameters from DSpace config
11   -FILE=$($BINDIR/dspace dsrun org.dspace.core.ConfigurationManager -property openaire.projects.filename)
12   -ONLINE=$($BINDIR/dspace dsrun org.dspace.core.ConfigurationManager -property openaire.projects.url)
13   -
14   -ONLINE=$(echo $ONLINE | sed 's/\"//g')
15   -
16   -
17   -XML_CLOSE_ELEMENTS="</value-pairs>\n</form-value-pairs>"
18   -
19   -IFS=$'\n'
20   -i=1
21   -
22   -for url in $(echo "$ONLINE" | sed 's_###_\n_g');
23   -do
24   - if [ $i -eq 1 ]; then
25   - if [[ $url == http* ]]; then
26   - wget --no-check-certificate "$url" -O "${i}.xml"
27   - else
28   - cp "$url" "${i}.xml"
29   - fi
30   -
31   - xmllint --format "${i}.xml" | head -n -2 > $FILE
32   - rm "${i}.xml"
33   -
34   - i=$(($i+1))
35   - else
36   - if [[ $url == http* ]]; then
37   - wget --no-check-certificate "$url" -O "${i}.xml"
38   - else
39   - cp "$url" "${i}.xml"
40   - fi
41   -
42   - xmllint --format "${i}.xml" | head -n -2 | tail -n +4 >> $FILE
43   - rm "${i}.xml"
44   -
45   - i=$(($i+1))
46   - fi
47   -done
48   -
49   -echo -e "\n$XML_CLOSE_ELEMENTS" >> $FILE
50   -
51   -echo "> Ended \"$0\" execution."
setup-data/dspace-source/dspace-api/src/main/java/org/dspace/content/authority/OpenAIREAuthority.java
... ... @@ -0,0 +1,189 @@
  1 +/*
  2 + * DCInputAuthority.java
  3 + *
  4 + * Version: $Revision: 1.1 $
  5 + *
  6 + * Date: $Date: 2009/07/23 05:07:01 $
  7 + *
  8 + * Copyright (c) 2002-2009, The DSpace Foundation. All rights reserved.
  9 + *
  10 + * Redistribution and use in source and binary forms, with or without
  11 + * modification, are permitted provided that the following conditions are
  12 + * met:
  13 + *
  14 + * - Redistributions of source code must retain the above copyright
  15 + * notice, this list of conditions and the following disclaimer.
  16 + *
  17 + * - Redistributions in binary form must reproduce the above copyright
  18 + * notice, this list of conditions and the following disclaimer in the
  19 + * documentation and/or other materials provided with the distribution.
  20 + *
  21 + * - Neither the name of the DSpace Foundation nor the names of its
  22 + * contributors may be used to endorse or promote products derived from
  23 + * this software without specific prior written permission.
  24 + *
  25 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  26 + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  27 + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  28 + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  29 + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  30 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  31 + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  32 + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  33 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  34 + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
  35 + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
  36 + * DAMAGE.
  37 + */
  38 +package org.dspace.content.authority;
  39 +
  40 +import java.io.File;
  41 +import java.util.ArrayList;
  42 +import java.util.List;
  43 +
  44 +import javax.xml.parsers.DocumentBuilder;
  45 +import javax.xml.parsers.DocumentBuilderFactory;
  46 +
  47 +import org.apache.log4j.Logger;
  48 +import org.dspace.core.ConfigurationManager;
  49 +import org.w3c.dom.Document;
  50 +import org.w3c.dom.Element;
  51 +import org.w3c.dom.Node;
  52 +import org.w3c.dom.NodeList;
  53 +
  54 +/**
  55 + * ChoiceAuthority source that reads the same input-forms which drive
  56 + * configurable submission.
  57 + *
  58 + * Configuration:
  59 + * This MUST be configured aas a self-named plugin, e.g.:
  60 + * plugin.selfnamed.org.dspace.content.authority.ChoiceAuthority = \
  61 + * org.dspace.content.authority.DCInputAuthority
  62 + *
  63 + * It AUTOMATICALLY configures a plugin instance for each <value-pairs>
  64 + * element (within <form-value-pairs>) of the input-forms.xml. The name
  65 + * of the instance is the "value-pairs-name" attribute, e.g.
  66 + * the element: <value-pairs value-pairs-name="common_types" dc-term="type">
  67 + * defines a plugin instance "common_types".
  68 + *
  69 + * IMPORTANT NOTE: Since these value-pairs do NOT include authority keys,
  70 + * the choice lists derived from them do not include authority values.
  71 + * So you should not use them as the choice source for authority-controlled
  72 + * fields.
  73 + */
  74 +public class OpenAIREAuthority implements ChoiceAuthority
  75 +{
  76 + static {
  77 + try {
  78 + load();
  79 + } catch (Exception ex) {
  80 + OpenAIREAuthority.log.error("Error",ex);
  81 + OpenAIREAuthority.pairs = new ArrayList<Pair<String,String>>();
  82 + }
  83 + }
  84 +
  85 + private static Logger log = Logger.getLogger(OpenAIREAuthority.class);
  86 + private static final String FileProperty = "openaire.projects.filename";
  87 + private static final String MinimumChars = "openaire.projects.suggest.minchar";
  88 + private static final String MaxSuggests = "openaire.projects.suggest.max";
  89 + private static final int MaxSuggestionLength = 66;
  90 +
  91 +
  92 + private static List<Pair<String, String>> pairs = null;
  93 +
  94 + /**
  95 + * Loads the data, parsing the file defined at the 'openaire.projects.filename' dspace
  96 + * property.
  97 + */
  98 + @SuppressWarnings("unused")
  99 + private static void load () {
  100 + if (OpenAIREAuthority.pairs == null) {
  101 + OpenAIREAuthority.pairs = new ArrayList<Pair<String, String>>();
  102 + String defsFile = ConfigurationManager.getProperty(OpenAIREAuthority.FileProperty);
  103 + if (defsFile == null) OpenAIREAuthority.log.error("Configuration "+OpenAIREAuthority.FileProperty+" not found in dspace.cfg file.");
  104 + else {
  105 + try {
  106 + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  107 + DocumentBuilder builder = factory.newDocumentBuilder();
  108 + Document doc = builder.parse(new File(defsFile));
  109 + doc.getDocumentElement().normalize();
  110 +
  111 + NodeList nodes = doc.getElementsByTagName("pair");
  112 + for (int i = 0; i < nodes.getLength(); i++) {
  113 + Node node = nodes.item(i);
  114 + if (node.getNodeType() == Node.ELEMENT_NODE) {
  115 + // OK!
  116 + Element element = (Element) node;
  117 + Pair<String, String> pair = new Pair<String, String>();
  118 + pair.fst = element.getElementsByTagName("displayed-value").item(0).getFirstChild().getNodeValue();
  119 + pair.snd = element.getElementsByTagName("stored-value").item(0).getFirstChild().getNodeValue();
  120 + OpenAIREAuthority.pairs.add(pair);
  121 + } else
  122 + throw new Exception("Invalid Node readed");
  123 + }
  124 + } catch (Exception e) {
  125 + OpenAIREAuthority.log.error("Unable to parse file "+defsFile, e);
  126 + }
  127 + }
  128 + }
  129 + }
  130 +
  131 + private String getPrettyChoiceText (String text) {
  132 + if (text.length() > OpenAIREAuthority.MaxSuggestionLength) {
  133 + return text.substring(0, OpenAIREAuthority.MaxSuggestionLength - 3) + "...";
  134 + } else return text;
  135 + }
  136 +
  137 + public Choices getMatches(String field, String text, int collection, int start,
  138 + int limit, String locale) {
  139 + OpenAIREAuthority.load();
  140 + int minChars = ConfigurationManager.getIntProperty(OpenAIREAuthority.MinimumChars, 4);
  141 + int maxSuggests = ConfigurationManager.getIntProperty(OpenAIREAuthority.MaxSuggests, 10);
  142 +
  143 + List<Choice> result = new ArrayList<Choice>();
  144 + int dflt = -1;
  145 + int type = Choices.CF_NOTFOUND;
  146 + int added = 0;
  147 + if (text != null && text.length() >= minChars) {
  148 + for (int i = 0; i < OpenAIREAuthority.pairs.size() && added < maxSuggests; ++i)
  149 + {
  150 + if (OpenAIREAuthority.pairs.get(i).fst.toLowerCase().contains(text.toLowerCase()))
  151 + {
  152 + Choice cs = new Choice(String.valueOf(i), OpenAIREAuthority.pairs.get(i).snd, this.getPrettyChoiceText(OpenAIREAuthority.pairs.get(i).fst));
  153 + result.add(cs);
  154 + added++;
  155 + if (OpenAIREAuthority.pairs.get(i).fst.equalsIgnoreCase(text))
  156 + dflt = i;
  157 + }
  158 + }
  159 + if (added > 0) type = Choices.CF_AMBIGUOUS;
  160 + else type = Choices.CF_NOTFOUND;
  161 + }
  162 + return new Choices(result.toArray(new Choice[] {}), 0, result.size(), type, false, dflt);
  163 + }
  164 +
  165 + public Choices getBestMatch(String field, String text, int collection, String locale) {
  166 + OpenAIREAuthority.load();
  167 + for (int i = 0; i < OpenAIREAuthority.pairs.size(); ++i)
  168 + {
  169 + if (OpenAIREAuthority.pairs.get(i).fst.toLowerCase().equals(text.toLowerCase()))
  170 + {
  171 + Choice v[] = new Choice[1];
  172 + v[0] = new Choice(String.valueOf(i), OpenAIREAuthority.pairs.get(i).snd, this.getPrettyChoiceText(OpenAIREAuthority.pairs.get(i).fst));
  173 + return new Choices(v, 0, v.length, Choices.CF_UNCERTAIN, false, 0);
  174 + }
  175 + }
  176 + return new Choices(Choices.CF_NOTFOUND);
  177 + }
  178 +
  179 + public String getLabel(String field, String key, String locale) {
  180 + OpenAIREAuthority.load();
  181 + return OpenAIREAuthority.pairs.get(Integer.parseInt(key)).fst;
  182 + }
  183 +
  184 +}
  185 +
  186 +class Pair<T, V> {
  187 + public T fst;
  188 + public V snd;
  189 +}
... ...
setup-data/dspace-source/dspace/bin/openaire-refresh-list
... ... @@ -0,0 +1,51 @@
  1 +#!/bin/bash
  2 +
  3 +# Get the DSPACE/bin directory
  4 +BINDIR=$(dirname $0)
  5 +
  6 +echo "> Starting \"$0\" execution..."
  7 +
  8 +echo "Updating OpenAIRE Project list"
  9 +
  10 +# Read parameters from DSpace config
  11 +FILE=$($BINDIR/dspace dsrun org.dspace.core.ConfigurationManager -property openaire.projects.filename)
  12 +ONLINE=$($BINDIR/dspace dsrun org.dspace.core.ConfigurationManager -property openaire.projects.url)
  13 +
  14 +ONLINE=$(echo $ONLINE | sed 's/\"//g')
  15 +
  16 +
  17 +XML_CLOSE_ELEMENTS="</value-pairs>\n</form-value-pairs>"
  18 +
  19 +IFS=$'\n'
  20 +i=1
  21 +
  22 +for url in $(echo "$ONLINE" | sed 's_###_\n_g');
  23 +do
  24 + if [ $i -eq 1 ]; then
  25 + if [[ $url == http* ]]; then
  26 + wget --no-check-certificate "$url" -O "${i}.xml"
  27 + else
  28 + cp "$url" "${i}.xml"
  29 + fi
  30 +
  31 + xmllint --format "${i}.xml" | head -n -2 > $FILE
  32 + rm "${i}.xml"
  33 +
  34 + i=$(($i+1))
  35 + else
  36 + if [[ $url == http* ]]; then
  37 + wget --no-check-certificate "$url" -O "${i}.xml"
  38 + else
  39 + cp "$url" "${i}.xml"
  40 + fi
  41 +
  42 + xmllint --format "${i}.xml" | head -n -2 | tail -n +4 >> $FILE
  43 + rm "${i}.xml"
  44 +
  45 + i=$(($i+1))
  46 + fi
  47 +done
  48 +
  49 +echo -e "\n$XML_CLOSE_ELEMENTS" >> $FILE
  50 +
  51 +echo "> Ended \"$0\" execution."
... ...