use of org.eclipse.wst.xml.core.internal.document.DocumentTypeImpl in project liferay-ide by liferay.
the class LiferayMavenProjectProvider method updateDtdVersion.
protected void updateDtdVersion(IProject project, String dtdVersion, String archetypeVesion) {
String tmpPublicId = dtdVersion;
String tmpSystemId = dtdVersion.replaceAll("\\.", "_");
IStructuredModel editModel = null;
IFile[] metaFiles = _getLiferayMetaFiles(project);
for (IFile file : metaFiles) {
try {
editModel = StructuredModelManager.getModelManager().getModelForEdit(file);
if ((editModel != null) && editModel instanceof IDOMModel) {
IDOMDocument xmlDocument = ((IDOMModel) editModel).getDocument();
DocumentTypeImpl docType = (DocumentTypeImpl) xmlDocument.getDoctype();
String publicId = docType.getPublicId();
String newPublicId = _getNewDoctTypeSetting(publicId, tmpPublicId, _publicid_pattern);
if (newPublicId != null) {
docType.setPublicId(newPublicId);
}
String systemId = docType.getSystemId();
String newSystemId = _getNewDoctTypeSetting(systemId, tmpSystemId, _systemid_pattern);
if (newSystemId != null) {
docType.setSystemId(newSystemId);
}
editModel.save();
}
} catch (Exception e) {
IStatus error = ProjectCore.createErrorStatus("Unable to upgrade deployment meta file for " + file.getName(), e);
ProjectCore.logError(error);
} finally {
if (editModel != null) {
editModel.releaseFromEdit();
}
}
}
ProjectCore.operate(project, UpdateDescriptorVersionOperation.class, archetypeVesion, dtdVersion);
}
use of org.eclipse.wst.xml.core.internal.document.DocumentTypeImpl in project liferay-ide by liferay.
the class DescriptorsPage method doUpgrade.
@Override
protected void doUpgrade(IFile srcFile, IProject project) {
IDOMModel domModel = null;
try {
domModel = (IDOMModel) StructuredModelManager.getModelManager().getModelForEdit(srcFile);
domModel.aboutToChangeModel();
IDOMDocument document = domModel.getDocument();
DocumentTypeImpl docType = (DocumentTypeImpl) document.getDoctype();
if (docType != null) {
final String publicId = docType.getPublicId();
final String newPublicId = _getNewDoctTypeSetting(publicId, "7.0.0", _publicidRegrex);
docType.setPublicId(newPublicId);
final String systemId = docType.getSystemId();
final String newSystemId = _getNewDoctTypeSetting(systemId, "7_0_0", _systemidRegrex);
docType.setSystemId(newSystemId);
}
_removeLayoutWapNode(srcFile, document);
domModel.save();
} catch (Exception e) {
ProjectUI.logError(e);
}
}
use of org.eclipse.wst.xml.core.internal.document.DocumentTypeImpl in project webtools.sourceediting by eclipse.
the class EMF2DOMSSERenderer method replaceDocumentType.
/*
* (non-Javadoc)
*
* @see org.eclipse.jem.internal.util.emf.xml.EMF2DOMRenderer#replaceDocumentType(java.lang.String,
* java.lang.String, java.lang.String)
*/
public void replaceDocumentType(String docTypeName, String publicId, String systemId) {
if (document == null)
return;
DocumentTypeImpl docType = (DocumentTypeImpl) document.getDoctype();
if (docType == null)
return;
if (publicId == null && systemId == null)
document.removeChild(docType);
else {
docType.setPublicId(publicId);
docType.setSystemId(systemId);
}
}
use of org.eclipse.wst.xml.core.internal.document.DocumentTypeImpl in project liferay-ide by liferay.
the class UpgradeMetadataHandler method execute.
@Override
public Status execute(IProject project, String runtimeName, IProgressMonitor monitor, int perUnit) {
Status retval = Status.createOkStatus();
try {
int worked = 0;
IProgressMonitor submon = CoreUtil.newSubMonitor(monitor, 25);
submon.subTask("Prograde Upgrade Update DTD Header");
IFile[] metaFiles = _getUpgradeDTDFiles(project);
for (IFile file : metaFiles) {
IStructuredModel editModel = StructuredModelManager.getModelManager().getModelForEdit(file);
try {
if ((editModel != null) && (editModel instanceof IDOMModel)) {
worked = worked + perUnit;
submon.worked(worked);
IDOMDocument xmlDocument = ((IDOMModel) editModel).getDocument();
DocumentTypeImpl docType = (DocumentTypeImpl) xmlDocument.getDoctype();
String publicId = docType.getPublicId();
String newPublicId = _getNewDoctTypeSetting(publicId, "6.2.0", _publicid_regrex);
if (newPublicId != null) {
docType.setPublicId(newPublicId);
}
worked = worked + perUnit;
submon.worked(worked);
String systemId = docType.getSystemId();
String newSystemId = _getNewDoctTypeSetting(systemId, "6_2_0", _systemid_regrex);
if (newSystemId != null) {
docType.setSystemId(newSystemId);
}
editModel.save();
worked = worked + perUnit;
submon.worked(worked);
} else {
_updateProperties(file, "liferay-versions", "6.2.0+");
}
} finally {
editModel.releaseFromEdit();
}
}
} catch (Exception e) {
IStatus error = ProjectCore.createErrorStatus("Unable to upgrade deployment meta file for " + project.getName(), e);
ProjectCore.logError(error);
retval = StatusBridge.create(error);
}
return retval;
}
use of org.eclipse.wst.xml.core.internal.document.DocumentTypeImpl in project liferay-ide by liferay.
the class DescriptorsPage method createTempFile.
@Override
protected void createTempFile(IFile srcFile, File templateFile, String projectName) {
IDOMModel domModel = null;
try {
domModel = (IDOMModel) StructuredModelManager.getModelManager().getModelForEdit(srcFile);
domModel.aboutToChangeModel();
IDOMDocument document = domModel.getDocument();
DocumentTypeImpl docType = (DocumentTypeImpl) document.getDoctype();
if (docType != null) {
final String publicId = docType.getPublicId();
final String newPublicId = _getNewDoctTypeSetting(publicId, "7.0.0", _publicidRegrex);
docType.setPublicId(newPublicId);
final String systemId = docType.getSystemId();
final String newSystemId = _getNewDoctTypeSetting(systemId, "7_0_0", _systemidRegrex);
docType.setSystemId(newSystemId);
}
_removeLayoutWapNode(srcFile, document);
OutputStream tmpOutputStream = Files.newOutputStream(templateFile.toPath(), StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.CREATE_NEW);
domModel.save(tmpOutputStream);
} catch (Exception e) {
ProjectCore.logError(e);
} finally {
domModel.releaseFromEdit();
}
}
Aggregations