Search in sources :

Example 21 with XtentisException

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

the class XSDDeleteParticleAction method doAction.

public IStatus doAction() {
    try {
        // xsdPartle is to support the multiple delete action on key press,
        // which each delete action on particle must be explicit passed a xsd particle to
        // delete
        XSDParticle particle = (XSDParticle) xsdPartle;
        if (particle == null) {
            ISelection selection = page.getTreeViewer().getSelection();
            particle = (XSDParticle) ((IStructuredSelection) selection).getFirstElement();
        }
        XSDTerm term = particle.getTerm();
        XSDElementDeclaration decl = null;
        if (term instanceof XSDElementDeclaration) {
            decl = (XSDElementDeclaration) particle.getTerm();
        }
        if (particle.getContainer() == null) {
            return Status.CANCEL_STATUS;
        }
        XSDIdentityConstraintDefinition identify = null;
        XSDXPathDefinition keyPath = null;
        List<Object> keyInfo = Util.getKeyInfo(decl);
        if (keyInfo != null && keyInfo.size() > 0) {
            identify = (XSDIdentityConstraintDefinition) keyInfo.get(0);
            keyPath = (XSDXPathDefinition) keyInfo.get(1);
            identify.getFields().remove(keyPath);
            if (identify.getFields().size() == 0) {
                XSDElementDeclaration top = (XSDElementDeclaration) Util.getParent(decl);
                top.getIdentityConstraintDefinitions().remove(identify);
            }
        }
        if (!(particle.getContainer() instanceof XSDModelGroup))
            throw new XtentisException(Messages.bind(Messages.XSDDeleteParticleAction_ExceptionInfo, particle.getContainer().getClass().getName()));
        XSDModelGroup group = (XSDModelGroup) particle.getContainer();
        group.getContents().remove(particle);
        // if (term instanceof XSDElementDeclaration) {
        // //remove type definition is no more used and type is not built in
        // XSDTypeDefinition typeDef = decl.getTypeDefinition();
        // if ( (typeDef.getName()!=null) && //anonymous type
        // (!typeDef.getSchema().getSchemaForSchemaNamespace().equals(typeDef.getTargetNamespace()))
        // ){
        // if (Util.findElementsUsingType(group.getSchema(),typeDef.getTargetNamespace(),
        // typeDef.getName()).size()==0)
        // group.getSchema().getContents().remove(typeDef);
        // }
        // }
        group.updateElement();
        xsdPartle = null;
        page.refresh();
        page.markDirty();
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(page.getSite().getShell(), Messages._Error, Messages.bind(Messages.XSDDeleteParticleAction_ErrorMsg, e.getLocalizedMessage()));
        return Status.CANCEL_STATUS;
    }
    return Status.OK_STATUS;
}
Also used : XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) ISelection(org.eclipse.jface.viewers.ISelection) XSDTerm(org.eclipse.xsd.XSDTerm) XSDIdentityConstraintDefinition(org.eclipse.xsd.XSDIdentityConstraintDefinition) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) XSDXPathDefinition(org.eclipse.xsd.XSDXPathDefinition) XSDParticle(org.eclipse.xsd.XSDParticle) XtentisException(com.amalto.workbench.utils.XtentisException) XtentisException(com.amalto.workbench.utils.XtentisException)

Example 22 with XtentisException

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

the class ServerDefService method checkMDMConnection.

public static void checkMDMConnection(String endpointaddress, String username, String password) throws MalformedURLException, XtentisException {
    try {
        TMDMService port = Util.getMDMService(new URL(endpointaddress), username, password);
        // $NON-NLS-1$
        port.ping(new WSPing("ServerExplorer"));
    } catch (javax.xml.ws.WebServiceException e) {
        XtentisException xtentisException = Util.convertWebServiceException(e);
        if (xtentisException != null) {
            throw xtentisException;
        }
        log.error(e.getMessage(), e);
    }
}
Also used : WSPing(com.amalto.workbench.webservices.WSPing) TMDMService(com.amalto.workbench.webservices.TMDMService) URL(java.net.URL) 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