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;
}
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);
}
}
Aggregations