Search in sources :

Example 6 with XmlFileConnectionItem

use of org.talend.core.model.properties.XmlFileConnectionItem in project tesb-studio-se by Talend.

the class PublishMetadataRunnable method run.

@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    final IWorkspaceRunnable op = new IWorkspaceRunnable() {

        @Override
        public void run(IProgressMonitor monitor) throws CoreException {
            monitor.beginTask(Messages.PublishMetadataAction_Importing, 3);
            final Collection<XmlFileConnectionItem> xmlObjs;
            try {
                xmlObjs = initFileConnection();
            } catch (Exception e) {
                String message = (null != e.getMessage()) ? e.getMessage() : e.getClass().getName();
                throw new CoreException(new Status(IStatus.ERROR, ServicesPlugin.getDefault().getBundle().getSymbolicName(), "Can't retrieve schemas from metadata: " + message, e));
            }
            Collection<XmlFileConnectionItem> selectTables;
            if (xmlObjs.size() > 0) {
                RewriteSchemaDialogRunnable runnable = new RewriteSchemaDialogRunnable(shell, xmlObjs);
                Display.getDefault().syncExec(runnable);
                selectTables = runnable.getSelectTables();
                if (null == selectTables) {
                    return;
                }
            } else {
                selectTables = Collections.emptyList();
            }
            monitor.worked(1);
            if (monitor.isCanceled()) {
                return;
            }
            boolean validateWsdl = ServicesPlugin.getDefault().getPreferenceStore().getBoolean(EsbSoapServicePreferencePage.ENABLE_WSDL_VALIDATION);
            if (validateWsdl) {
                WSDLUtils.validateWsdl(wsdlDefinition.getDocumentBaseURI());
            }
            monitor.worked(1);
            if (monitor.isCanceled()) {
                return;
            }
            try {
                process(wsdlDefinition, selectTables);
            } catch (Exception e) {
                throw new CoreException(new Status(IStatus.ERROR, ServicesPlugin.PLUGIN_ID, "Error during schema processing", e));
            }
            monitor.done();
        }
    };
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    try {
        ISchedulingRule schedulingRule = workspace.getRoot();
        // the update the project files need to be done in the workspace runnable to avoid all
        // notification
        // of changes before the end of the modifications.
        workspace.run(op, schedulingRule, IWorkspace.AVOID_UPDATE, monitor);
    } catch (CoreException e) {
        throw new InvocationTargetException(e);
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IWorkspaceRunnable(org.eclipse.core.resources.IWorkspaceRunnable) URISyntaxException(java.net.URISyntaxException) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException) PersistenceException(org.talend.commons.exception.PersistenceException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ISchedulingRule(org.eclipse.core.runtime.jobs.ISchedulingRule) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) IWorkspace(org.eclipse.core.resources.IWorkspace) XmlFileConnectionItem(org.talend.core.model.properties.XmlFileConnectionItem)

Aggregations

XmlFileConnectionItem (org.talend.core.model.properties.XmlFileConnectionItem)6 PersistenceException (org.talend.commons.exception.PersistenceException)4 Item (org.talend.core.model.properties.Item)4 XmlFileConnection (org.talend.core.model.metadata.builder.connection.XmlFileConnection)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 IElementParameter (org.talend.core.model.process.IElementParameter)2 ConnectionItem (org.talend.core.model.properties.ConnectionItem)2 MDMConnectionItem (org.talend.core.model.properties.MDMConnectionItem)2 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)2 RepositoryNode (org.talend.repository.model.RepositoryNode)2 FileNotFoundException (java.io.FileNotFoundException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 URISyntaxException (java.net.URISyntaxException)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 HashedMap (org.apache.commons.collections.map.HashedMap)1 IWorkspace (org.eclipse.core.resources.IWorkspace)1 IWorkspaceRunnable (org.eclipse.core.resources.IWorkspaceRunnable)1