Search in sources :

Example 16 with XtentisException

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

the class ViewMainPage method doSave.

@Override
public void doSave(IProgressMonitor monitor) {
    super.doSave(monitor);
    if (this.viewName != null && this.viewName.length() > 0) {
        if (viewName.matches("Browse_items.*")) {
            // $NON-NLS-1$
            // lastDataModelName=XpathSelectDialog.getDataModelName();
            // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
            String concept = viewName.replaceAll("Browse_items_", "").replaceAll("#.*", "");
            java.util.List<String> avaiList = getAvailableDataModel();
            if (avaiList.size() > 0) {
                lastDataModelName = avaiList.get(0);
            }
            if (concept != null && concept.length() > 0 && lastDataModelName != null && lastDataModelName.length() > 0) {
                // if(concept!=null&&concept.length()>0&&lastDataModelName!=null&&lastDataModelName.length()>0){
                // keys validate
                java.util.List<String> toAddViewableList = new ArrayList<String>();
                WSGetBusinessConceptKey wsGetBusinessConceptKey = new WSGetBusinessConceptKey(concept, new WSDataModelPK(lastDataModelName));
                WSConceptKey wsConceptKey = null;
                try {
                    wsConceptKey = getBusinessConceptKey(wsGetBusinessConceptKey);
                } catch (XtentisException e) {
                    log.error(e.getMessage(), e);
                }
                if (wsConceptKey != null) {
                    java.util.List<String> viewableList = new ArrayList<String>();
                    java.util.List<Line> vlines = (java.util.List<Line>) viewableViewer.getViewer().getInput();
                    for (int j = 0; j < vlines.size(); j++) {
                        Line item = vlines.get(j);
                        viewableList.add(item.keyValues.get(0).value);
                    }
                    java.util.List<String> keys = wsConceptKey.getFields();
                    for (int i = 0; i < keys.size(); i++) {
                        if (".".equals(wsConceptKey.getSelector())) {
                            // $NON-NLS-1$//$NON-NLS-2$
                            keys.set(i, "/" + concept + "/" + keys.get(i));
                        } else {
                            keys.set(i, wsConceptKey.getSelector() + keys.get(i));
                        }
                    }
                    java.util.List<String> ids = wsConceptKey.getFields();
                    for (String id : ids) {
                        // need to care about more case
                        if (id.startsWith("/")) {
                            // $NON-NLS-1$
                            id = id.substring(1);
                        } else if (id.startsWith("//")) {
                            // $NON-NLS-1$
                            id = id.substring(2);
                        }
                        if (!viewableList.contains(id)) {
                            toAddViewableList.add(0, id);
                        }
                    }
                }
                // show verify report
                if (toAddViewableList.size() > 0) {
                    String msg = Messages.ViewMainPage_Msg;
                    for (Object element : toAddViewableList) {
                        String toAddItem = (String) element;
                        // $NON-NLS-1$
                        msg += (toAddItem + "\n");
                    }
                    msg += Messages.ViewMainPage_Addtions;
                    MessageDialog.openInformation(this.getSite().getShell(), Messages.ViewMainPage_VerifyReport, msg);
                }
                // auto fix
                IRunnableWithProgress autoFixProcess = new AutoFixProgress(toAddViewableList, viewableViewer, this.getSite().getShell());
                try {
                    new ProgressMonitorDialog(this.getSite().getShell()).run(false, true, autoFixProcess);
                } catch (InvocationTargetException e) {
                    log.error(e.getMessage(), e);
                } catch (InterruptedException e) {
                    log.error(e.getMessage(), e);
                }
            }
        }
    }
}
Also used : ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) ArrayList(java.util.ArrayList) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) Line(com.amalto.workbench.models.Line) WSGetBusinessConceptKey(com.amalto.workbench.webservices.WSGetBusinessConceptKey) List(org.eclipse.swt.widgets.List) ArrayList(java.util.ArrayList) TreeObject(com.amalto.workbench.models.TreeObject) WSConceptKey(com.amalto.workbench.webservices.WSConceptKey) WSDataModelPK(com.amalto.workbench.webservices.WSDataModelPK) XtentisException(com.amalto.workbench.utils.XtentisException)

Example 17 with XtentisException

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

the class RoutingEngineV2BrowserMainPage method updateButtons.

protected void updateButtons() {
    try {
        WSRoutingEngineV2Status status = getServerRoutingStatus();
        startButton.setEnabled(status != WSRoutingEngineV2Status.RUNNING);
        suspendButton.setEnabled(status != WSRoutingEngineV2Status.SUSPENDED);
        stopButton.setEnabled(status != WSRoutingEngineV2Status.STOPPED);
        statusLabel.setText(status.value());
    } catch (XtentisException e) {
        startButton.setEnabled(true);
        suspendButton.setEnabled(false);
        stopButton.setEnabled(false);
        // $NON-NLS-1$
        statusLabel.setText("FAILED");
        log.debug(e.getMessage(), e);
    }
}
Also used : WSRoutingEngineV2Status(com.amalto.workbench.webservices.WSRoutingEngineV2Status) XtentisException(com.amalto.workbench.utils.XtentisException)

Example 18 with XtentisException

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

the class RepositoryViewObjectCheckedWidget method getConsistencyData.

private synchronized ConsistencyData getConsistencyData(MDMServerDef serverDef, IRepositoryViewObject viewObj) {
    if (!isServerOk) {
        return null;
    }
    ConsistencyData consistencyData = consistencyMap.get(viewObj);
    if (consistencyData != null) {
        return consistencyData;
    }
    try {
        ConsistencyService consistencyService = ConsistencyService.getInstance();
        consistencyData = new ConsistencyData();
        ERepositoryObjectType viewType = viewObj.getRepositoryObjectType();
        if (viewType == null) {
            return null;
        }
        if (viewType == IServerObjectRepositoryType.TYPE_RESOURCE || viewType == IServerObjectRepositoryType.TYPE_JOB || viewType == IServerObjectRepositoryType.TYPE_WORKFLOW) {
            consistencyData.setCompareResult(CompareResultEnum.NOT_SUPPORT);
        } else {
            List<IRepositoryViewObject> viewObjs = new ArrayList<IRepositoryViewObject>();
            viewObjs.add(viewObj);
            Map<IRepositoryViewObject, WSDigest> digestValueResult = consistencyService.queryServerDigestValue(serverDef, viewObjs);
            WSDigest serverDigestTime = digestValueResult.get(viewObj);
            consistencyData.setServerDigestTime(serverDigestTime);
            consistencyService.updateCurrentDigestValue(viewObj);
            Item item = viewObj.getProperty().getItem();
            String ld = consistencyService.getLocalDigestValue(item);
            String cd = consistencyService.getCurrentDigestValue(item);
            long localTimestamp = consistencyService.getLocalTimestamp(item);
            // key
            String type = viewObj.getRepositoryObjectType().getKey();
            String objectName = viewObj.getLabel();
            WSDigestKey key = new WSDigestKey(objectName, type);
            consistencyData.setLocalDigestTime(new WSDigest(ld, localTimestamp, key));
            // init compare result;
            CompareResultEnum result;
            if (serverDigestTime == null || serverDigestTime.getDigestValue() == null) {
                result = CompareResultEnum.NOT_EXIST_IN_SERVER;
            } else {
                String rd = serverDigestTime.getDigestValue();
                result = consistencyService.getCompareResult(cd, ld, rd);
            }
            consistencyData.setCompareResult(result);
        }
        consistencyMap.put(viewObj, consistencyData);
    } catch (WebServiceException e) {
        log.error(e.getMessage(), e);
    } catch (XtentisException e) {
        log.error(e.getMessage(), e);
    }
    return consistencyData;
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) ArrayList(java.util.ArrayList) WSDigestKey(com.amalto.workbench.webservices.WSDigestKey) WSDigest(com.amalto.workbench.webservices.WSDigest) ConsistencyService(org.talend.mdm.repository.core.service.ConsistencyService) Item(org.talend.core.model.properties.Item) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) TreeItem(org.eclipse.swt.widgets.TreeItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) CompareResultEnum(org.talend.mdm.repository.core.service.ConsistencyService.CompareResultEnum) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) ConsistencyData(org.talend.mdm.repository.core.service.ConsistencyService.ConsistencyData) XtentisException(com.amalto.workbench.utils.XtentisException)

Example 19 with XtentisException

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

the class DeployAllAction method runWithType.

public void runWithType(ERepositoryObjectType type) {
    DeployAllDialog dialog = new DeployAllDialog(getShell(), type);
    if (dialog.open() == IDialogConstants.OK_ID) {
        List<AbstractDeployCommand> selectededCommands = dialog.getSelectedCommands();
        if (selectededCommands.size() >= 0) {
            DeployService deployService = DeployService.getInstance();
            deployViewObject = deployService.getDeployViewObject(selectededCommands);
            // validate object
            IModelValidateResult validateResult = deployService.validateModel(deployViewObject);
            int selectedButton = validateResult.getSelectedButton();
            if (selectedButton == IModelValidationService.BUTTON_CANCEL) {
                return;
            }
            List<IRepositoryViewObject> validObjects = validateResult.getValidObjects(selectedButton);
            List<IRepositoryViewObject> invalidObjects = validateResult.getInvalidObjects(selectedButton);
            // 
            MDMServerDef serverDef = dialog.getServerDef();
            try {
                // consistency check
                ConsistencyCheckResult consistencyCheckResult = deployService.checkConsistency(serverDef, validObjects, selectededCommands);
                if (consistencyCheckResult.isCanceled()) {
                    return;
                } else {
                    validObjects = consistencyCheckResult.getToDeployObjects();
                }
                deployService.removeInvalidCommands(invalidObjects, selectededCommands);
                deployService.removeInvalidCommands(consistencyCheckResult.getToSkipObjects(), selectededCommands);
                // save editors
                LockedDirtyObjectDialog lockDirtyDialog = new LockedDirtyObjectDialog(getShell(), Messages.AbstractDeployAction_promptToSaveEditors, validObjects);
                if (lockDirtyDialog.needShowDialog() && lockDirtyDialog.open() == IDialogConstants.CANCEL_ID) {
                    return;
                }
                lockDirtyDialog.saveDirtyObjects();
                // insert impact dialog
                List<AbstractDeployCommand> canceledCommandAfterImpactAnalysis = new LinkedList<AbstractDeployCommand>(selectededCommands);
                try {
                    Map<IRepositoryViewObject, ImpactOperation> analyzeModelImpact = ModelImpactAnalyseService.analyzeCommandImpact(serverDef, selectededCommands);
                    Map<IRepositoryViewObject, ICommandParameter> paramMap = null;
                    if (analyzeModelImpact != null) {
                        ModelImpactAnalyseService.shrinkDeployCommands(analyzeModelImpact, selectededCommands);
                        paramMap = ModelImpactAnalyseService.convertToParameters(analyzeModelImpact);
                        CommandManager.getInstance().attachParameterToCommand(selectededCommands, paramMap);
                    }
                    canceledCommandAfterImpactAnalysis.removeAll(selectededCommands);
                } catch (InterruptedException ex) {
                    return;
                }
                IStatus status = deployService.runCommands(selectededCommands, serverDef);
                // update consistency value
                try {
                    deployService.updateServerConsistencyStatus(serverDef, status);
                } catch (XtentisException e) {
                    log.error(e.getMessage(), e);
                } catch (WebServiceException e) {
                    log.error(e.getMessage(), e);
                }
                // add canceled object to status
                deployService.generateValidationFailedDeployStatus(status, invalidObjects);
                deployService.generateConsistencyCancelDeployStatus(status, consistencyCheckResult.getToSkipObjects().toArray(new IRepositoryViewObject[0]));
                for (AbstractDeployCommand cmd : canceledCommandAfterImpactAnalysis) {
                    deployService.generateConsistencyCancelDeployStatus(status, cmd.getViewObject());
                }
                // 
                updateChangedStatus(status);
                if (status.isMultiStatus()) {
                    showDeployStatus(status);
                }
                updateLastServer(status, new NullProgressMonitor());
            } catch (Exception e) {
                String url = // $NON-NLS-1$
                serverDef.getProtocol() + serverDef.getHost() + ":" + serverDef.getPort() + serverDef.getPath();
                String title = Messages.bind(Messages.Server_cannot_connected, url);
                MessageDialog.openError(getShell(), title, Messages.AbstractDataClusterAction_ConnectFailed);
            }
        }
    }
}
Also used : IModelValidateResult(org.talend.mdm.repository.core.service.IModelValidationService.IModelValidateResult) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) WebServiceException(javax.xml.ws.WebServiceException) ImpactOperation(org.talend.mdm.repository.core.service.ModelImpactAnalyseService.ImpactOperation) ICommandParameter(org.talend.mdm.repository.core.command.param.ICommandParameter) DeployService(org.talend.mdm.repository.core.service.DeployService) DeployAllDialog(org.talend.mdm.repository.ui.dialogs.deploy.DeployAllDialog) LinkedList(java.util.LinkedList) XtentisException(com.amalto.workbench.utils.XtentisException) WebServiceException(javax.xml.ws.WebServiceException) LockedDirtyObjectDialog(org.talend.mdm.repository.ui.dialogs.lock.LockedDirtyObjectDialog) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ConsistencyCheckResult(org.talend.mdm.repository.core.service.ConsistencyService.ConsistencyCheckResult) AbstractDeployCommand(org.talend.mdm.repository.core.command.deploy.AbstractDeployCommand) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef) XtentisException(com.amalto.workbench.utils.XtentisException)

Example 20 with XtentisException

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

the class DeployService method deploy.

public IStatus deploy(MDMServerDef serverDef, List<IRepositoryViewObject> viewObjs, int defaultCmdType, boolean removeLocked) {
    if (removeLocked) {
        removeLockedViewObj(viewObjs);
    }
    IModelValidateResult validateResult = validateModel(viewObjs);
    int selectedButton = validateResult.getSelectedButton();
    if (selectedButton == IModelValidationService.BUTTON_CANCEL) {
        return Status.CANCEL_STATUS;
    }
    List<IRepositoryViewObject> validObjects = validateResult.getValidObjects(selectedButton);
    List<IRepositoryViewObject> invalidObjects = validateResult.getInvalidObjects(selectedButton);
    try {
        // consistency check
        ConsistencyCheckResult consistencyCheckResult = ConsistencyService.getInstance().checkConsistency(serverDef, validObjects);
        if (consistencyCheckResult == null || consistencyCheckResult.isCanceled()) {
            return Status.CANCEL_STATUS;
        }
        validObjects = consistencyCheckResult.getToDeployObjects();
        // 
        CommandManager manager = CommandManager.getInstance();
        List<AbstractDeployCommand> commands = manager.getDeployCommands(validObjects, defaultCmdType);
        // insert impact dialog
        List<AbstractDeployCommand> canceledCommandAfterImpactAnalysis = new LinkedList<AbstractDeployCommand>(commands);
        if (UIUtil.isWorkInUI()) {
            try {
                Map<IRepositoryViewObject, ImpactOperation> analyzeModelImpact = ModelImpactAnalyseService.analyzeCommandImpact(serverDef, commands);
                Map<IRepositoryViewObject, ICommandParameter> paramMap = null;
                if (analyzeModelImpact != null) {
                    ModelImpactAnalyseService.shrinkDeployCommands(analyzeModelImpact, commands);
                    paramMap = ModelImpactAnalyseService.convertToParameters(analyzeModelImpact);
                    manager.attachParameterToCommand(commands, paramMap);
                }
                canceledCommandAfterImpactAnalysis.removeAll(commands);
            } catch (InterruptedException ex) {
                return Status.CANCEL_STATUS;
            }
        }
        IStatus mainStatus = runCommands(commands, serverDef);
        // update consistency value
        try {
            updateServerConsistencyStatus(serverDef, mainStatus);
        } catch (XtentisException e) {
            log.error(e.getMessage(), e);
        } catch (WebServiceException e) {
            log.error(e.getMessage(), e);
        }
        // 
        generateValidationFailedDeployStatus(mainStatus, invalidObjects);
        if (UIUtil.isWorkInUI()) {
            generateConsistencyCancelDeployStatus(mainStatus, consistencyCheckResult.getToSkipObjects().toArray(new IRepositoryViewObject[0]));
            for (AbstractDeployCommand cmd : canceledCommandAfterImpactAnalysis) {
                generateConsistencyCancelDeployStatus(mainStatus, cmd.getViewObject());
            }
        }
        return mainStatus;
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        String url = // $NON-NLS-1$
        serverDef.getProtocol() + serverDef.getHost() + ":" + serverDef.getPort() + serverDef.getPath();
        String title = Messages.bind(Messages.Server_cannot_connected, url);
        MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title, Messages.AbstractDataClusterAction_ConnectFailed);
        return Status.CANCEL_STATUS;
    }
}
Also used : IModelValidateResult(org.talend.mdm.repository.core.service.IModelValidationService.IModelValidateResult) IStatus(org.eclipse.core.runtime.IStatus) WebServiceException(javax.xml.ws.WebServiceException) ImpactOperation(org.talend.mdm.repository.core.service.ModelImpactAnalyseService.ImpactOperation) ICommandParameter(org.talend.mdm.repository.core.command.param.ICommandParameter) LinkedList(java.util.LinkedList) XtentisException(com.amalto.workbench.utils.XtentisException) InvocationTargetException(java.lang.reflect.InvocationTargetException) WebServiceException(javax.xml.ws.WebServiceException) CommandManager(org.talend.mdm.repository.core.command.CommandManager) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ConsistencyCheckResult(org.talend.mdm.repository.core.service.ConsistencyService.ConsistencyCheckResult) AbstractDeployCommand(org.talend.mdm.repository.core.command.deploy.AbstractDeployCommand) 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