Commit 4133d663 authored by Steinberg, Jan's avatar Steinberg, Jan
Browse files

adding set to BundlesSource reference for oai pmh sources

parent b9df07e7
This diff is collapsed.
......@@ -25,6 +25,7 @@ import org.gesis.dda.wizard.security.SecurityUtils;
import org.gesis.dda.wizard.service.FeederService;
import org.gesis.dda.wizard.web.rest.util.HeaderUtil;
import org.gesis.dda.wizard.web.rest.util.PaginationUtil;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
......@@ -80,8 +81,16 @@ public class BundlesSourceResource {
if (bundlesSource.getId() != null) {
return ResponseEntity.badRequest().headers(HeaderUtil.createFailureAlert("bundlesSource", "idexists", "A new bundlesSource cannot already have an ID")).body(null);
}
final String setSpec = getSetSpec(bundlesSource.getData());
BundlesSource result = bundlesSourceRepository.save(bundlesSource);
if ( result.getType().equals(BundlesSourceType.XML_XSLT_SOURCE) ) {
if ( result.getType().equals(BundlesSourceType.XSLT_OAI_PMH) && null != setSpec) {
final String currentReference = result.getReference();
result.setReference(currentReference + "___" + setSpec);
result = bundlesSourceRepository.save(result);
}
else if ( result.getType().equals(BundlesSourceType.XML_XSLT_SOURCE) ) {
result.setReference("xmlxslt-bundlessource-" + result.getId() );
result = bundlesSourceRepository.save(result);
}
......@@ -94,6 +103,16 @@ public class BundlesSourceResource {
.body(result);
}
private String getSetSpec(String data) {
if (null != data) {
final JSONObject obj = new JSONObject(data);
if (null != obj.get("setSpec")) {
return (String) obj.get("setSpec");
}
}
return null;
}
/**
* POST /bundlesSources/forCurrentUser -> Create a new bundlesSource, setting its owner to currentUser.
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment