Revision 47374
Added by Alessia Bardi over 7 years ago
modules/dnet-openaireplus-workflows/trunk/src/main/java/eu/dnetlib/msro/openaireplus/api/OpenaireResultSubmitter.java | ||
---|---|---|
93 | 93 |
@RequestMapping(value = {"/api/publications/feedJson", "/api/results/feedJson"}, method = RequestMethod.POST) |
94 | 94 |
public |
95 | 95 |
@ResponseBody |
96 |
boolean feedResultJson(@RequestParam(value = "json", required = true) final String json,
|
|
96 |
boolean feedObjectJson(@RequestParam(value = "json", required = true) final String json,
|
|
97 | 97 |
@RequestParam(value = "commit", required = false, defaultValue = "true") final boolean commit) throws MSROException { |
98 | 98 |
final ResultEntry pub = new Gson().fromJson(json, ResultEntry.class); |
99 |
return feedResult(pub, commit);
|
|
99 |
return feedObject(pub, commit);
|
|
100 | 100 |
} |
101 | 101 |
|
102 | 102 |
|
103 |
@RequestMapping(value = {"/api/publications/feedObject", "/api/results/feedObject"} , method = RequestMethod.POST)
|
|
103 |
@RequestMapping(value = {"/api/results/feedObject"} , method = RequestMethod.POST) |
|
104 | 104 |
public |
105 | 105 |
@ResponseBody |
106 |
boolean feedResult(@RequestBody final ResultEntry pub,
|
|
106 |
String feedResult(@RequestBody final ResultEntry pub,
|
|
107 | 107 |
@RequestParam(value = "commit", required = false, defaultValue = "true") final boolean commit) |
108 | 108 |
throws MSROException { |
109 |
try { |
|
110 |
if(feedObject(pub, commit)) { |
|
111 |
return ResultEntry.calculateObjId(pub.getOriginalId(), pub.getCollectedFromId(), serviceLocator.getService(ISLookUpService.class)); |
|
112 |
} |
|
113 |
else return null; |
|
114 |
} catch (final Throwable e) { |
|
115 |
throw new MSROException("Error adding publication: " + e.getMessage(), e); |
|
116 |
} |
|
117 |
} |
|
109 | 118 |
|
110 |
if (StringUtils.isBlank(pub.getOriginalId())) { throw new MSROException("A required field is missing: originalId"); } |
|
111 |
if (StringUtils.isBlank(pub.getTitle())) { throw new MSROException("A required field is missing: title"); } |
|
112 |
if (StringUtils.isBlank(pub.getUrl())) { throw new MSROException("A required field is missing: url"); } |
|
113 |
if (StringUtils.isBlank(pub.getLicenseCode())) { throw new MSROException("A required field is missing: licenseCode"); } |
|
114 |
if (StringUtils.isBlank(pub.getResourceType())) { throw new MSROException("A required field is missing: resourceType"); } |
|
115 |
if (StringUtils.isBlank(pub.getCollectedFromId())) { throw new MSROException("A required field is missing: collectedFromId"); } |
|
116 |
if (StringUtils.isBlank(pub.getType())) { throw new MSROException("A required field is missing: type"); } |
|
119 |
@RequestMapping(value = {"/api/publications/feedObject"} , method = RequestMethod.POST) |
|
120 |
public |
|
121 |
@ResponseBody |
|
122 |
boolean feedObject(@RequestBody final ResultEntry pub, |
|
123 |
@RequestParam(value = "commit", required = false, defaultValue = "true") final boolean commit) |
|
124 |
throws MSROException { |
|
117 | 125 |
|
118 |
|
|
126 |
checkParameters(pub); |
|
119 | 127 |
final List<IndexDsInfo> idxList; |
120 | 128 |
try { |
121 | 129 |
idxList = calculateCurrentIndexDsInfo(); |
... | ... | |
146 | 154 |
|
147 | 155 |
} |
148 | 156 |
|
157 |
|
|
158 |
|
|
149 | 159 |
@RequestMapping(value = "/api/results", method = RequestMethod.DELETE) |
150 | 160 |
public |
151 | 161 |
@ResponseBody |
... | ... | |
206 | 216 |
return new ErrorMessage(e); |
207 | 217 |
} |
208 | 218 |
|
219 |
private void checkParameters(ResultEntry pub) throws MSROException{ |
|
220 |
if (StringUtils.isBlank(pub.getOriginalId())) { throw new MSROException("A required field is missing: originalId"); } |
|
221 |
if (StringUtils.isBlank(pub.getTitle())) { throw new MSROException("A required field is missing: title"); } |
|
222 |
if (StringUtils.isBlank(pub.getUrl())) { throw new MSROException("A required field is missing: url"); } |
|
223 |
if (StringUtils.isBlank(pub.getLicenseCode())) { throw new MSROException("A required field is missing: licenseCode"); } |
|
224 |
if (StringUtils.isBlank(pub.getResourceType())) { throw new MSROException("A required field is missing: resourceType"); } |
|
225 |
if (StringUtils.isBlank(pub.getCollectedFromId())) { throw new MSROException("A required field is missing: collectedFromId"); } |
|
226 |
if (StringUtils.isBlank(pub.getType())) { throw new MSROException("A required field is missing: type"); } |
|
227 |
} |
|
228 |
|
|
209 | 229 |
private List<IndexDsInfo> calculateCurrentIndexDsInfo() throws IOException, ISLookUpException { |
210 | 230 |
List<IndexDsInfo> list = Lists.newArrayList(); |
211 | 231 |
|
Also available in: Unified diff
feedResult returns the openaire identifier