Search in sources :

Example 1 with UpdateDescriptorVersionOperation

use of com.liferay.ide.project.core.descriptor.UpdateDescriptorVersionOperation in project liferay-ide by liferay.

the class JSFLiferayPortletDescriptorHelper method addDescriptorOperations.

@Override
protected void addDescriptorOperations() {
    super.addDescriptorOperations();
    UpdateDescriptorVersionOperation operation = new UpdateDescriptorVersionOperation() {

        @Override
        public IStatus update(Version preVersion, Version postVersion) {
            if ((CoreUtil.compareVersions(preVersion, ILiferayConstants.V620) >= 0) && (CoreUtil.compareVersions(postVersion, ILiferayConstants.V620) < 0)) {
                IFile descriptorFile = getDescriptorFile();
                IDOMModel domModel = null;
                try {
                    domModel = (IDOMModel) StructuredModelManager.getModelManager().getModelForEdit(descriptorFile);
                    IDOMDocument document = domModel.getDocument();
                    IStatus status = _downgradeJSFLiferayPortletXMLTo61(document);
                    if (!status.isOK()) {
                        return status;
                    }
                    domModel.save();
                } catch (Exception e) {
                    PortletCore.logError("Error editing liferay-portlet.xml", e);
                } finally {
                    if (domModel != null) {
                        domModel.releaseFromEdit();
                    }
                }
            }
            return Status.OK_STATUS;
        }
    };
    addDescriptorOperation(operation);
}
Also used : UpdateDescriptorVersionOperation(com.liferay.ide.project.core.descriptor.UpdateDescriptorVersionOperation) IStatus(org.eclipse.core.runtime.IStatus) IFile(org.eclipse.core.resources.IFile) Version(org.osgi.framework.Version) IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) IDOMDocument(org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument)

Aggregations

UpdateDescriptorVersionOperation (com.liferay.ide.project.core.descriptor.UpdateDescriptorVersionOperation)1 IFile (org.eclipse.core.resources.IFile)1 IStatus (org.eclipse.core.runtime.IStatus)1 IDOMDocument (org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument)1 IDOMModel (org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel)1 Version (org.osgi.framework.Version)1