String uuidAction, List<Element> md, String schema, int index,
String source, String sourceName, ServiceContext context,
List<String> id, String createDate, String changeDate,
String groupId, MetadataType isTemplate) throws Exception {
GeonetContext gc = (GeonetContext) context
.getHandlerContext(Geonet.CONTEXT_NAME);
DataManager dm = gc.getBean(DataManager.class);
if (uuid == null || uuid.equals("")
|| uuidAction.equals(Params.GENERATE_UUID)) {
String newuuid = UUID.randomUUID().toString();
source = null;
Log
.debug(Geonet.MEF, "Replacing UUID " + uuid + " with "
+ newuuid);
uuid = newuuid;
// --- set uuid inside metadata
md.add(index, dm.setUUID(schema, uuid, md.get(index)));
} else {
if (sourceName == null)
sourceName = "???";
if (source == null || source.trim().length() == 0)
throw new Exception(
"Missing siteId parameter from info.xml file");
// --- only update sources table if source is not current site
if (!source.equals(gc.getBean(SettingManager.class).getSiteId())) {
Source source1 = new Source(source, sourceName, true);
context.getBean(SourceRepository.class).save(source1);
}
}