Search in sources :

Example 11 with XtentisException

use of com.amalto.workbench.utils.XtentisException in project tmdm-studio-se by Talend.

the class ViewMainPage method getWsViewObject.

protected WSView getWsViewObject() {
    WSView wsObject = null;
    try {
        if (getXObject().getWsObject() == null) {
            // then fetch from server
            TMDMService port = Util.getMDMService(getXObject());
            wsObject = port.getView(new WSGetView((WSViewPK) getXObject().getWsKey()));
            getXObject().setWsObject(wsObject);
        } else {
            // it has been opened by an editor - use the object there
            wsObject = (WSView) getXObject().getWsObject();
        }
    } catch (XtentisException e) {
        log.error(e.getMessage(), e);
    }
    return wsObject;
}
Also used : TMDMService(com.amalto.workbench.webservices.TMDMService) WSGetView(com.amalto.workbench.webservices.WSGetView) WSView(com.amalto.workbench.webservices.WSView) XtentisException(com.amalto.workbench.utils.XtentisException)

Example 12 with XtentisException

use of com.amalto.workbench.utils.XtentisException in project tmdm-studio-se by Talend.

the class DataClusterDialog method showInTextWidget.

private void showInTextWidget(LineItem lineItem) {
    if (lineItem == null) {
        // $NON-NLS-1$
        textViewer.setText("");
        // $NON-NLS-1$
        recordContent = "";
        return;
    }
    try {
        final TMDMService service = Util.getMDMService(model);
        final WSItem wsItem = service.getItem(new WSGetItem(new WSItemPK(lineItem.getConcept().trim(), Arrays.asList(lineItem.getIds()), (WSDataClusterPK) model.getWsKey())));
        recordContent = Util.formatXsdSource(wsItem.getContent());
        textViewer.setText(recordContent);
    } catch (WebServiceException e) {
        log.error(e.getMessage(), e);
    } catch (XtentisException e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(getShell(), Messages._Error, Messages.bind(Messages.DataClusterBrowserMainPage_36, e.getLocalizedMessage()));
    }
}
Also used : WSGetItem(com.amalto.workbench.webservices.WSGetItem) WebServiceException(javax.xml.ws.WebServiceException) TMDMService(com.amalto.workbench.webservices.TMDMService) WSItem(com.amalto.workbench.webservices.WSItem) WSItemPK(com.amalto.workbench.webservices.WSItemPK) XtentisException(com.amalto.workbench.utils.XtentisException)

Example 13 with XtentisException

use of com.amalto.workbench.utils.XtentisException in project tmdm-studio-se by Talend.

the class RoutingEngineV2BrowserMainPage method getResults.

protected WSRoutingOrderV2[] getResults() {
    Cursor waitCursor = null;
    try {
        Display display = getEditor().getSite().getPage().getWorkbenchWindow().getWorkbench().getDisplay();
        waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
        this.getSite().getShell().setCursor(waitCursor);
        TMDMService service = getMDMService();
        long from = -1;
        long to = -1;
        // $NON-NLS-1$
        Pattern pattern = Pattern.compile("^\\d{4}\\d{2}\\d{2} \\d{2}:\\d{2}:\\d{2}$");
        if (!BLANK.equals(fromText.getText())) {
            String dateTimeText = fromText.getText().trim();
            Matcher matcher = pattern.matcher(dateTimeText);
            if (!matcher.matches()) {
                MessageDialog.openWarning(this.getSite().getShell(), Messages.Warning, Messages.RoutingEngineV2BrowserMainPage_FormatIllegal);
                return new WSRoutingOrderV2[0];
            }
            try {
                Date d = sdf.parse(fromText.getText());
                from = d.getTime();
            } catch (ParseException pe) {
            }
        }
        if (!BLANK.equals(toText.getText())) {
            String dateTimeText = toText.getText().trim();
            Matcher matcher = pattern.matcher(dateTimeText);
            if (!matcher.matches()) {
                MessageDialog.openWarning(this.getSite().getShell(), Messages.Warning, Messages.RoutingEngineV2BrowserMainPage_FormatIllegal);
                return new WSRoutingOrderV2[0];
            }
            try {
                Date d = sdf.parse(toText.getText());
                to = d.getTime();
            } catch (ParseException pe) {
            }
        }
        long timeCreatedMin = -1;
        long timeCreatedMax = -1;
        long timeScheduledMin = -1;
        long timeScheduledMax = -1;
        long timeLastRunStartedMin = -1;
        long timeLastRunStartedMax = -1;
        long timeLastRunCompletedMin = -1;
        long timeLastRunCompletedMax = -1;
        WSRoutingOrderV2Status status = null;
        String statusText = statusCombo.getItem(statusCombo.getSelectionIndex());
        if ("COMPLETED".equals(statusText)) {
            // $NON-NLS-1$
            timeLastRunCompletedMin = from;
            timeLastRunCompletedMax = to;
            status = WSRoutingOrderV2Status.COMPLETED;
        } else if ("FAILED".equals(statusText)) {
            // $NON-NLS-1$
            timeLastRunCompletedMin = from;
            timeLastRunCompletedMax = to;
            status = WSRoutingOrderV2Status.FAILED;
        } else {
            throw new XtentisException(Messages.RoutingEngineV2BrowserMainPage_ExceptionInfo + statusText + Messages.RoutingEngineV2BrowserMainPage_ExceptionInfoA);
        }
        String serviceJNDI = serviceCombo.getItem(serviceCombo.getSelectionIndex());
        if (BLANK.equals(serviceJNDI)) {
            serviceJNDI = null;
        }
        int start = pageToolBar.getStart();
        int limit = pageToolBar.getLimit();
        List<WSRoutingOrderV2> wsRoutingOrder = service.getRoutingOrderV2ByCriteriaWithPaging(new WSGetRoutingOrderV2ByCriteriaWithPaging(new WSRoutingOrderV2SearchCriteriaWithPaging(// $NON-NLS-1$
        "*".equals(anyFieldText.getText()) || BLANK.equals(anyFieldText.getText()) ? null : anyFieldText.getText(), // $NON-NLS-1$
        "*".equals(documentTypeText.getText()) || BLANK.equals(documentTypeText.getText()) ? // $NON-NLS-1$
        null : documentTypeText.getText(), // $NON-NLS-1$
        "*".equals(idText.getText()) || BLANK.equals(idText.getText()) ? // $NON-NLS-1$
        null : idText.getText(), limit, null, null, serviceJNDI, null, start, status, timeCreatedMax, timeCreatedMin, timeLastRunCompletedMax, timeLastRunCompletedMin, timeLastRunStartedMax, timeLastRunStartedMin, timeScheduledMax, timeScheduledMin, true))).getWsRoutingOrder();
        if (wsRoutingOrder.size() == 1) {
            MessageDialog.openInformation(this.getSite().getShell(), Messages.RoutingEngineV2BrowserMainPage_Info, Messages.RoutingEngineV2BrowserMainPage_SorryNoResult);
            return new WSRoutingOrderV2[0];
        }
        int totalSize = Integer.parseInt(wsRoutingOrder.get(0).getName());
        pageToolBar.setTotalsize(totalSize);
        pageToolBar.refreshUI();
        WSRoutingOrderV2[] resultOrderV2s = new WSRoutingOrderV2[wsRoutingOrder.size() - 1];
        System.arraycopy(wsRoutingOrder.toArray(new WSRoutingOrderV2[0]), 1, resultOrderV2s, 0, resultOrderV2s.length);
        return resultOrderV2s;
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        if ((e.getLocalizedMessage() != null) && e.getLocalizedMessage().contains("10000")) {
            MessageDialog.openError(this.getSite().getShell(), Messages.RoutingEngineV2BrowserMainPage_TooManyResults, Messages.RoutingEngineV2BrowserMainPage_ErrorMsg1);
        } else if (!Util.handleConnectionException(this.getSite().getShell(), e, null)) {
            MessageDialog.openError(this.getSite().getShell(), Messages.ErrorTitle1, e.getLocalizedMessage());
        }
        return null;
    } finally {
        try {
            this.getSite().getShell().setCursor(null);
            if (waitCursor != null) {
                waitCursor.dispose();
            }
        } catch (Exception e) {
        // do nothing
        }
    }
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) WSRoutingOrderV2(com.amalto.workbench.webservices.WSRoutingOrderV2) WSGetRoutingOrderV2ByCriteriaWithPaging(com.amalto.workbench.webservices.WSGetRoutingOrderV2ByCriteriaWithPaging) Cursor(org.eclipse.swt.graphics.Cursor) Date(java.util.Date) XtentisException(com.amalto.workbench.utils.XtentisException) ParseException(java.text.ParseException) WSRoutingOrderV2Status(com.amalto.workbench.webservices.WSRoutingOrderV2Status) TMDMService(com.amalto.workbench.webservices.TMDMService) ParseException(java.text.ParseException) Display(org.eclipse.swt.widgets.Display) XtentisException(com.amalto.workbench.utils.XtentisException) WSRoutingOrderV2SearchCriteriaWithPaging(com.amalto.workbench.webservices.WSRoutingOrderV2SearchCriteriaWithPaging)

Example 14 with XtentisException

use of com.amalto.workbench.utils.XtentisException in project tmdm-studio-se by Talend.

the class ObjectRetriever method run.

public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    // $NON-NLS-1$
    monitor.beginTask(Messages.bind(Messages.ObjectRetriever_TaskName, IConstants.TALEND), "admin".equals(username) ? 12 : 9);
    try {
        switch(parentObject.getType()) {
            case TreeObject.WORKFLOW:
                // $NON-NLS-1$
                objectName = "WorkflowAvailableModel";
                break;
            case TreeObject.JOB_REGISTRY:
                // $NON-NLS-1$
                objectName = "JobAvailableModel";
                break;
        }
        TMDMService service = Util.getMDMService(new URL(endpointaddress), username, password);
        // commented this by jsxie to fix bug 21371
        // parentObject.getServerRoot().removeChildFromUI(parentObject);
        List<IAvailableModel> availablemodels = AvailableModelUtil.getAvailableModels();
        for (IAvailableModel model : availablemodels) {
            if (model.toString().indexOf(objectName) > 0) {
                model.addTreeObjects(service, monitor, parentObject.getServerRoot());
            }
        }
    } catch (MalformedURLException e) {
        log.error(e.getMessage(), e);
    } catch (XtentisException e) {
        log.error(e.getMessage(), e);
    }
}
Also used : IAvailableModel(com.amalto.workbench.availablemodel.IAvailableModel) MalformedURLException(java.net.MalformedURLException) TMDMService(com.amalto.workbench.webservices.TMDMService) URL(java.net.URL) XtentisException(com.amalto.workbench.utils.XtentisException)

Example 15 with XtentisException

use of com.amalto.workbench.utils.XtentisException in project tmdm-studio-se by Talend.

the class TransformerMainPage method execute.

public void execute() {
    try {
        service = getService();
        if (service == null) {
            return;
        }
        java.util.List<WSTransformerContextPipelinePipelineItem> items = new ArrayList<WSTransformerContextPipelinePipelineItem>();
        for (Line line : cacheList) {
            String variableName = line.keyValues.get(0).value;
            String contentType = line.keyValues.get(1).value;
            String value = line.keyValues.get(2).value;
            items.add(new WSTransformerContextPipelinePipelineItem(variableName, new WSTypedContent(contentType, null, // $NON-NLS-1$
            new WSByteArray(value.getBytes("utf-8")))));
        }
        final WSBackgroundJobPK jobPK = service.executeTransformerV2AsJob(new WSExecuteTransformerV2AsJob(new WSTransformerContext(new WSTransformerContextPipeline(items), null, new WSTransformerV2PK(transformer.getName()))));
        IRunnableWithProgress progress = new IRunnableWithProgress() {

            WSBackgroundJob job = null;

            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                /**
                 ****************************************
                 * Watch the Background Job
                 *****************************************
                 */
                try {
                    boolean firstTime = true;
                    do {
                        if (firstTime) {
                            Thread.sleep(1500L);
                            firstTime = false;
                        } else {
                            Thread.sleep(5000L);
                        }
                        if (monitor.isCanceled()) {
                            throw new InterruptedException(Messages.TransformerMainPage_UserCancel);
                        }
                        job = service.getBackgroundJob(new WSGetBackgroundJob(jobPK.getPk()));
                        monitor.subTask(job.getMessage());
                    } while (job.getStatus().equals(BackgroundJobStatusType.RUNNING) || job.getStatus().equals(BackgroundJobStatusType.SCHEDULED));
                    if (job.getStatus().equals(BackgroundJobStatusType.STOPPED)) {
                        getSite().getShell().getDisplay().syncExec(new Runnable() {

                            public void run() {
                                MessageDialog.openError(TransformerMainPage.this.getEditor().getSite().getShell(), Messages.bind(Messages.TransformerMainPage_ErrorMsg, transformer.getName()), job.getMessage());
                            }
                        });
                        throw new XtentisException(Messages.bind(Messages.TransformerMainPage_JobWasStoped, job.getMessage()));
                    }
                    monitor.worked(1);
                    monitor.done();
                    /**
                     ****************************************
                     * Build the result console
                     *****************************************
                     */
                    // Auto sorts the entries
                    final TreeMap pipeline = new TreeMap<String, WSExtractedContent>();
                    WSPipeline wsPipeline = job.getPipeline();
                    java.util.List<WSPipelineTypedContentEntry> entries = wsPipeline.getTypedContentEntry();
                    for (WSPipelineTypedContentEntry entry : entries) {
                        pipeline.put(entry.getOutput(), entry.getWsExtractedContent());
                    }
                    getSite().getShell().getDisplay().asyncExec(new Runnable() {

                        public void run() {
                            try {
                                /*
                                     * ProcessResultsPage page = new ProcessResultsPage(editor,pipeline);
                                     * parent.editor.addPage(page); parent.editor.setActivePage(page.getId());
                                     * 
                                     * parent.editor.getEditorSite().getShell()
                                     */
                                // Shell shell = new Shell(SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
                                ProcessResultsDialog dialog = new ProcessResultsDialog(getSite().getShell(), Messages.bind(Messages.TransformerMainPage_DailogTitle, sdf.format(new Date(System.currentTimeMillis()))), pipeline);
                                dialog.setBlockOnOpen(false);
                                dialog.open();
                            } catch (Exception e) {
                                log.error(e.getMessage(), e);
                                throw new RuntimeException(e);
                            }
                        }
                    });
                } catch (Exception e1) {
                    log.error(e1.getMessage(), e1);
                }
            }
        };
        // fork
        new ProgressMonitorDialog(TransformerMainPage.this.getSite().getWorkbenchWindow().getShell()).run(// fork
        true, true, progress);
    } catch (Exception e1) {
        log.error(e1.getMessage(), e1);
    }
}
Also used : ArrayList(java.util.ArrayList) WSBackgroundJob(com.amalto.workbench.webservices.WSBackgroundJob) WSExecuteTransformerV2AsJob(com.amalto.workbench.webservices.WSExecuteTransformerV2AsJob) WSPipeline(com.amalto.workbench.webservices.WSPipeline) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) WSGetBackgroundJob(com.amalto.workbench.webservices.WSGetBackgroundJob) WSBackgroundJobPK(com.amalto.workbench.webservices.WSBackgroundJobPK) ProcessResultsDialog(com.amalto.workbench.dialogs.ProcessResultsDialog) WSTransformerContextPipelinePipelineItem(com.amalto.workbench.webservices.WSTransformerContextPipelinePipelineItem) WSByteArray(com.amalto.workbench.webservices.WSByteArray) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) WSTypedContent(com.amalto.workbench.webservices.WSTypedContent) WSPipelineTypedContentEntry(com.amalto.workbench.webservices.WSPipelineTypedContentEntry) TreeMap(java.util.TreeMap) WSTransformerContext(com.amalto.workbench.webservices.WSTransformerContext) Date(java.util.Date) PartInitException(org.eclipse.ui.PartInitException) InvocationTargetException(java.lang.reflect.InvocationTargetException) XtentisException(com.amalto.workbench.utils.XtentisException) Line(com.amalto.workbench.models.Line) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) WSTransformerV2PK(com.amalto.workbench.webservices.WSTransformerV2PK) WSTransformerContextPipeline(com.amalto.workbench.webservices.WSTransformerContextPipeline) XtentisException(com.amalto.workbench.utils.XtentisException)

Aggregations

XtentisException (com.amalto.workbench.utils.XtentisException)22 TMDMService (com.amalto.workbench.webservices.TMDMService)10 WebServiceException (javax.xml.ws.WebServiceException)8 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 MDMServerDef (org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)4 WSPing (com.amalto.workbench.webservices.WSPing)3 ArrayList (java.util.ArrayList)3 SelectServerDefDialog (org.talend.mdm.workbench.serverexplorer.ui.dialogs.SelectServerDefDialog)3 Line (com.amalto.workbench.models.Line)2 TreeObject (com.amalto.workbench.models.TreeObject)2 WSConceptKey (com.amalto.workbench.webservices.WSConceptKey)2 WSDataModelPK (com.amalto.workbench.webservices.WSDataModelPK)2 WSDigest (com.amalto.workbench.webservices.WSDigest)2 WSDigestKey (com.amalto.workbench.webservices.WSDigestKey)2 File (java.io.File)2 MalformedURLException (java.net.MalformedURLException)2 URL (java.net.URL)2 HashMap (java.util.HashMap)2 LinkedList (java.util.LinkedList)2