use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument in project liferay-ide by liferay.
the class ServiceBuilderDescriptorHelper method addDefaultEntity.
public IStatus addDefaultEntity() {
IStatus status = Status.OK_STATUS;
IFile descriptorFile = getDescriptorFile();
if (descriptorFile != null) {
DOMModelEditOperation editOperation = new DOMModelEditOperation(descriptorFile) {
@Override
protected IStatus doExecute(IDOMDocument document) {
return doAddDefaultEntity(document);
}
};
status = editOperation.execute();
}
return status;
}
use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument in project liferay-ide by liferay.
the class ServiceBuilderDescriptorHelper method removeAllEntities.
public IStatus removeAllEntities() {
IFile descriptorFile = getDescriptorFile();
if (FileUtil.notExists(descriptorFile)) {
return Status.OK_STATUS;
}
String tagName = "entity";
DOMModelEditOperation editOperation = new DOMModelEditOperation(descriptorFile) {
@Override
protected IStatus doExecute(IDOMDocument document) {
return removeAllElements(document, tagName);
}
};
return editOperation.execute();
}
use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument in project liferay-ide by liferay.
the class LiferayMavenLegacyProjectUpdater method isNeedUpgrade.
@Override
public boolean isNeedUpgrade(IFile pomFile) {
String tagName = "artifactId";
String[] values = { "liferay-maven-plugin", "portal-service", "util-java", "util-bridges", "util-taglib", "util-slf4j" };
IDOMModel domModel = null;
boolean retval = false;
try {
domModel = (IDOMModel) StructuredModelManager.getModelManager().getModelForRead(pomFile);
IDOMDocument document = domModel.getDocument();
NodeList elements = document.getElementsByTagName(tagName);
if (elements != null) {
for (int i = 0; i < elements.getLength(); i++) {
IDOMElement element = (IDOMElement) elements.item(i);
String textContent = element.getTextContent();
if (!CoreUtil.empty(textContent)) {
textContent = textContent.trim();
for (String str : values) {
if (textContent.equals(str)) {
retval = true;
}
}
}
}
}
} catch (Exception e) {
} finally {
if (domModel != null) {
domModel.releaseFromRead();
}
}
return retval;
}
use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument 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.provisional.document.IDOMDocument 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);
}
}
Aggregations