fileName = FileUtil.stripExtension(fileName);
String name = getName(fileName);
DDMStructure ddmStructure = DDMStructureLocalServiceUtil.fetchStructure(
groupId, PortalUtil.getClassNameId(JournalArticle.class),
getKey(fileName));
if (ddmStructure != null) {
if (!developerModeEnabled) {
if (_log.isInfoEnabled()) {
_log.info(
"DDM structure with name " + name + " and version " +
version + " already exists");
}
return;
}
DDMStructureLocalServiceUtil.deleteDDMStructure(ddmStructure);
}
String xsd = StringUtil.read(inputStream);
if (isJournalStructureXSD(xsd)) {
xsd = JournalConverterUtil.getDDMXSD(xsd);
}
setServiceContext(fileName);
ddmStructure = DDMStructureLocalServiceUtil.addStructure(
userId, groupId, parentDDMStructureKey,
PortalUtil.getClassNameId(JournalArticle.class), getKey(fileName),
getMap(name), null, xsd,
PropsUtil.get(PropsKeys.JOURNAL_ARTICLE_STORAGE_TYPE),
DDMStructureConstants.TYPE_DEFAULT, serviceContext);
addDDMTemplates(
ddmStructure.getStructureKey(),
_JOURNAL_DDM_TEMPLATES_DIR_NAME + fileName);
if (Validator.isNull(parentDDMStructureKey)) {
addDDMStructures(
ddmStructure.getStructureKey(),
_JOURNAL_DDM_STRUCTURES_DIR_NAME + fileName);
}
}