this.paWsService = paWsService;
}
@Override
public String publishExpRifcs(MDRegistrationBean mdRegistrationBean) {
RegMetadata regMetadata = mdRegistrationBean.getRegMetadata();
StringBuilder rifcsBuilder = new StringBuilder();
rifcsBuilder.append(getRifcsHeader());
rifcsBuilder.append("<registryObject group=\"" + mdRegistrationBean.getRifcsGroupName() + "\">");
rifcsBuilder.append(lineSeparator);
String identifier = regMetadata.getUniqueId();
rifcsBuilder.append("<key>" + identifier + "</key>");
rifcsBuilder.append(lineSeparator);
rifcsBuilder.append("<originatingSource>" + mdRegistrationBean.getAppName() + "</originatingSource>");
rifcsBuilder.append(lineSeparator);
rifcsBuilder.append("<collection type=\"dataset\">");
rifcsBuilder.append(lineSeparator);
rifcsBuilder.append("<identifier type=\"local\">" + identifier + "</identifier>");
rifcsBuilder.append(lineSeparator);
rifcsBuilder.append("<name type=\"primary\">");
rifcsBuilder.append(lineSeparator);
rifcsBuilder.append("<namePart>" + regMetadata.getTitle() + "</namePart>");
rifcsBuilder.append(lineSeparator);
rifcsBuilder.append("</name>");
rifcsBuilder.append(lineSeparator);
String electronicURL = mdRegistrationBean.getElectronicURL();
if (StringUtils.isNotBlank(electronicURL)) {
rifcsBuilder.append("<location>");
rifcsBuilder.append(lineSeparator);
rifcsBuilder.append("<address>");
rifcsBuilder.append(lineSeparator);
rifcsBuilder.append("<electronic type=\"url\">");
rifcsBuilder.append(lineSeparator);
rifcsBuilder.append("<value>" + mdRegistrationBean.getElectronicURL() + "</value>");
rifcsBuilder.append(lineSeparator);
rifcsBuilder.append("</electronic>");
rifcsBuilder.append(lineSeparator);
rifcsBuilder.append("</address>");
rifcsBuilder.append(lineSeparator);
rifcsBuilder.append("</location>");
rifcsBuilder.append(lineSeparator);
}
String physicalAddress = mdRegistrationBean.getPhysicalAddress();
if (StringUtils.isNotBlank(physicalAddress)) {
rifcsBuilder.append("<location>");
rifcsBuilder.append(lineSeparator);
rifcsBuilder.append("<address>");
rifcsBuilder.append(lineSeparator);
rifcsBuilder.append("<physical type=\"address\">");
rifcsBuilder.append(lineSeparator);
rifcsBuilder.append("<addressPart type=\"text\">" + mdRegistrationBean.getPhysicalAddress() + "</addressPart>");
rifcsBuilder.append(lineSeparator);
rifcsBuilder.append("</physical>");
rifcsBuilder.append(lineSeparator);
rifcsBuilder.append("</address>");
rifcsBuilder.append(lineSeparator);
rifcsBuilder.append("</location>");
rifcsBuilder.append(lineSeparator);
}
List<PartyBean> partyBeans = mdRegistrationBean.getPartyBeans();
StringBuilder relatedPartiesBuilder = new StringBuilder();
for (PartyBean pb : partyBeans) {
relatedPartiesBuilder.append("<relatedObject>");
relatedPartiesBuilder.append(lineSeparator);
relatedPartiesBuilder.append("<key>" + pb.getPartyKey() + "</key>");
relatedPartiesBuilder.append(lineSeparator);
relatedPartiesBuilder.append("<relation type=\"isManagedBy\" />");
relatedPartiesBuilder.append(lineSeparator);
relatedPartiesBuilder.append("</relatedObject>");
relatedPartiesBuilder.append(lineSeparator);
}
String partiesXML = relatedPartiesBuilder.toString();
if (StringUtils.isNotBlank(partiesXML)) {
rifcsBuilder.append(partiesXML);
}
String anzsrcCodes = mdRegistrationBean.getAnzsrcCode();
List<String> codes = MercUtil.splitAnzsrcCode(anzsrcCodes);
for (String code : codes) {
rifcsBuilder.append("<subject type=\"anzsrc-for\">" + code + "</subject>");
rifcsBuilder.append(lineSeparator);
}
rifcsBuilder.append("<description type=\"rights\" xml:lang=\"en\">");
rifcsBuilder.append(lineSeparator);
rifcsBuilder.append(mdRegistrationBean.getLicenceBean().getLicenceContents());
rifcsBuilder.append(lineSeparator);
rifcsBuilder.append("</description>");
rifcsBuilder.append(lineSeparator);
rifcsBuilder.append("<description type=\"brief\" xml:lang=\"en\">");
rifcsBuilder.append(lineSeparator);
rifcsBuilder.append(regMetadata.getDescription());
rifcsBuilder.append(lineSeparator);
rifcsBuilder.append("</description>");
rifcsBuilder.append(lineSeparator);
if (StringUtils.isNotBlank(mdRegistrationBean.getAccessRights())) {
rifcsBuilder.append("<description type=\"accessRights\" xml:lang=\"en\">");
rifcsBuilder.append(lineSeparator);
rifcsBuilder.append(mdRegistrationBean.getAccessRights());
rifcsBuilder.append(lineSeparator);
rifcsBuilder.append("</description>");
rifcsBuilder.append(lineSeparator);
}
rifcsBuilder.append("</collection>");
rifcsBuilder.append(lineSeparator);
rifcsBuilder.append("</registryObject>");
rifcsBuilder.append(lineSeparator);
rifcsBuilder.append(getRifcsEnder());
String rifcsStoreLocation = mdRegistrationBean.getRifcsStoreLocation();
synchronized (fileLock) {
File rifcsFile = new File(rifcsStoreLocation + File.separator + regMetadata.getUniqueId() + ".xml");
try {
// publish collection
FileUtils.writeStringToFile(rifcsFile, rifcsBuilder.toString());
// publish parties