List of usage examples for javax.xml.bind JAXBException toString
public String toString()
From source file:org.kalypso.model.km.internal.ui.kmupdate.KMUpdateWizardPage.java
private void loadAs(final String path) { try {// w w w . j a v a 2 s .c o m final File file = new File(path); if (!file.exists()) return; final KalininMiljukovGroupType kmGroup = KMBindingUtils.load(file); applyKMGroup(kmGroup); } catch (final JAXBException ex) { final IStatus status = new Status(IStatus.ERROR, KMPlugin.getID(), Messages.getString("org.kalypso.ui.rrm.kmupdate.KMUpdateWizardPage.12", ex.toString()), ex);//$NON-NLS-1$ KMPlugin.getDefault().getLog().log(status); final StatusDialog statusDialog = new StatusDialog(getShell(), status, getWizard().getWindowTitle()); statusDialog.open(); } }
From source file:org.kalypso.model.km.internal.ui.kmupdate.KMUpdateWizardPage.java
private boolean saveAs(final String path) { try {/* w w w . j a v a2 s. c o m*/ final KalininMiljukovGroupType groupType = KMBindingUtils.OF.createKalininMiljukovGroupType(); final List<KalininMiljukovType> kmTypes = groupType.getKalininMiljukov(); final KMChannelElement[] elements = getInput(); for (final KMChannelElement element : elements) kmTypes.add(element.getKMType()); KMBindingUtils.save(groupType, new File(path)); return true; } catch (final JAXBException ex) { final IStatus status = new Status(IStatus.ERROR, KMPlugin.getID(), Messages.getString("org.kalypso.ui.rrm.kmupdate.KMUpdateWizardPage.16", ex.toString()), ex);//$NON-NLS-1$ KMPlugin.getDefault().getLog().log(status); final StatusDialog statusDialog = new StatusDialog(getShell(), status, getWizard().getWindowTitle()); statusDialog.open(); return false; } }
From source file:org.lsc.configuration.JaxbXmlConfigurationHelper.java
/** * Dump the object to an XML file (by overriding if necessary) * //from ww w. j a v a 2 s . c om * @param filename * filename to write to * @param lscConf * configuration object * @throws FileNotFoundException * thrown if the file can not be accessed (either because of a * misconfiguration or due to a rights issue) */ public void saveConfiguration(String filename, Lsc lscConf) throws IOException { File existing = new File(filename); if (existing.exists()) { File backup = new File(existing + ".bak"); if (backup.exists()) { backup.delete(); } FileUtils.copyFile(existing, backup); } try { Marshaller marshaller = jaxbc.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); marshaller.marshal(lscConf, new File(filename)); } catch (JAXBException e) { LOGGER.error("Cannot save configuration file: " + e.toString(), e); } }
From source file:org.netbeans.jbpmn.modeler.specification.bpmn.model.conversation.util.BPMNConversationUtil.java
@Override public void loadModelerFile(ModelerFile file) { try {// w w w . j a v a 2 s .c o m IModelerScene scene = file.getModelerScene(); File savedFile = file.getFile(); if (bpmnConversationContext == null) { bpmnConversationContext = JAXBContext .newInstance(new Class<?>[] { ShapeDesign.class, TDefinitions.class }); } if (bpmnConversationUnmarshaller == null) { bpmnConversationUnmarshaller = bpmnConversationContext.createUnmarshaller(); } bpmnConversationUnmarshaller.setEventHandler(new ValidateJAXB()); TDefinitions definition_Load = bpmnConversationUnmarshaller .unmarshal(new StreamSource(savedFile), TDefinitions.class).getValue(); // TDefinitions definition_Load = (TDefinitions) JAXBIntrospector.getValue(bpmnConversationUnmarshaller.unmarshal(savedFile)); TCollaboration collaboration = new TCollaboration(); for (TRootElement element : new CopyOnWriteArrayList<TRootElement>(definition_Load.getRootElement())) { if (element instanceof TCollaboration) { TCollaboration collaboration_Tmp = ((TCollaboration) element); String name = collaboration_Tmp.getName(); if (name != null && !name.trim().isEmpty()) { collaboration.setName(name); } String id = collaboration_Tmp.getId(); if (id != null && !id.trim().isEmpty()) { collaboration.setId(id); } collaboration.getConversationLink().addAll(collaboration_Tmp.getConversationLink()); collaboration.getMessageFlow().addAll(collaboration_Tmp.getMessageFlow()); collaboration.getConversationNode().addAll(collaboration_Tmp.getConversationNode()); collaboration.getParticipant().addAll(collaboration_Tmp.getParticipant()); collaboration.getArtifact().addAll(collaboration_Tmp.getArtifact()); definition_Load.getRootElement().remove(collaboration_Tmp); } else if (element instanceof TProcess) { TProcess process_Tmp = (TProcess) element; collaboration.getArtifact().addAll(process_Tmp.getArtifact()); definition_Load.getRootElement().remove(process_Tmp); } } definition_Load.getRootElement().add(collaboration); scene.setRootElementSpec(collaboration); BPMNDiagram diagram = new BPMNDiagram(); diagram.setId(NBModelerUtil.getAutoGeneratedStringId()); BPMNPlane plane = new BPMNPlane(); plane.setId(NBModelerUtil.getAutoGeneratedStringId()); diagram.setBPMNPlane(plane); for (BPMNDiagram diagram_Tmp : definition_Load.getBPMNDiagram()) { if (diagram_Tmp instanceof BPMNDiagram) { BPMNPlane tmpPlane = diagram_Tmp.getBPMNPlane(); for (DiagramElement element : tmpPlane.getDiagramElement()) { plane.getDiagramElement().add(element); } } } definition_Load.getBPMNDiagram().removeAll(definition_Load.getBPMNDiagram()); definition_Load.getBPMNDiagram().add(diagram); file.getModelerDiagramModel().setDefinitionElement(definition_Load); file.getModelerDiagramModel().setRootElement(collaboration); file.getModelerDiagramModel().setDiagramElement(diagram); //ELEMENT_UPGRADE for (IFlowNode flowNode : new CopyOnWriteArrayList<IFlowNode>(collaboration.getConversationNode())) { loadNode(scene, (Widget) scene, flowNode); } for (IFlowNode flowNode : new CopyOnWriteArrayList<IFlowNode>(collaboration.getParticipant())) { loadNode(scene, (Widget) scene, flowNode); } for (IFlowEdge flowEdge : new CopyOnWriteArrayList<IFlowEdge>(collaboration.getConversationLink())) { loadEdge(scene, flowEdge); } for (IFlowEdge flowEdge : new CopyOnWriteArrayList<IFlowEdge>(collaboration.getMessageFlow())) { loadEdge(scene, flowEdge); } for (IArtifact artifact_Load : new CopyOnWriteArrayList<IArtifact>(collaboration.getArtifact())) { loadArtifact(scene, artifact_Load); } for (DiagramElement diagramElement_Tmp : diagram.getBPMNPlane().getDiagramElement()) { loadDiagram(scene, diagram, diagramElement_Tmp); } } catch (JAXBException e) { io.getOut().println("Exception: " + e.toString()); e.printStackTrace(); // Exceptions.printStackTrace(e); System.out.println("Document XML Not Exist"); } }
From source file:org.netbeans.jbpmn.modeler.specification.bpmn.model.process.util.BPMNProcessUtil.java
@Override public void loadModelerFile(ModelerFile file) { try {/*from w w w .ja v a 2s . com*/ IModelerScene scene = file.getModelerScene(); File savedFile = file.getFile(); // savedFile.getTotalSpace() if (bpmnProcessContext == null) { bpmnProcessContext = JAXBContext .newInstance(new Class<?>[] { ShapeDesign.class, TDefinitions.class }); } if (bpmnProcessUnmarshaller == null) { bpmnProcessUnmarshaller = bpmnProcessContext.createUnmarshaller(); } bpmnProcessUnmarshaller.setEventHandler(new ValidateJAXB()); TDefinitions definition_Load = bpmnProcessUnmarshaller .unmarshal(new StreamSource(savedFile), TDefinitions.class).getValue(); Set<String> noneTypeProcess = new HashSet<String>(); Set<String> allProcess = new HashSet<String>(); Set<String> mainProcess; for (TRootElement element : definition_Load.getRootElement()) { if (element instanceof TCollaboration) { TCollaboration collaboration = ((TCollaboration) element); for (TParticipant participant : collaboration.getParticipant()) { noneTypeProcess.add(participant.getProcessRef()); } } if (element instanceof TProcess) { TProcess process_Load = (TProcess) element; allProcess.add(process_Load.getId()); } } mainProcess = new HashSet<String>(allProcess); mainProcess.removeAll(noneTypeProcess); TProcess process = new TProcess(); for (String processId : mainProcess) { TProcess tmpProcess = definition_Load.getProcess(processId); if (tmpProcess != null) { String name = tmpProcess.getName(); if (name != null && !name.trim().isEmpty()) { process.setName(name); } String id = tmpProcess.getId(); if (id != null && !id.trim().isEmpty()) { process.setId(id); } process.getProperty().addAll(tmpProcess.getProperty()); process.getFlowElement().addAll(tmpProcess.getFlowElement()); process.getArtifact().addAll(tmpProcess.getArtifact()); definition_Load.getRootElement().remove(tmpProcess); } } definition_Load.getRootElement().add(process); scene.setRootElementSpec(process); BPMNDiagram diagram = new BPMNDiagram(); diagram.setId(NBModelerUtil.getAutoGeneratedStringId()); BPMNPlane plane = new BPMNPlane(); plane.setId(NBModelerUtil.getAutoGeneratedStringId()); diagram.setBPMNPlane(plane); // plane.setBpmnElement(process.getId()); for (BPMNDiagram diagram_Tmp : definition_Load.getBPMNDiagram()) { if (diagram_Tmp instanceof BPMNDiagram) { BPMNPlane tmpPlane = diagram_Tmp.getBPMNPlane(); for (DiagramElement element : tmpPlane.getDiagramElement()) { plane.getDiagramElement().add(element); } } } definition_Load.getBPMNDiagram().removeAll(definition_Load.getBPMNDiagram()); definition_Load.getBPMNDiagram().add(diagram); file.getModelerDiagramModel().setDefinitionElement(definition_Load); file.getModelerDiagramModel().setRootElement(process); file.getModelerDiagramModel().setDiagramElement(diagram); //ELEMENT_UPGRADE for (IFlowElement flowElement_Load : new CopyOnWriteArrayList<IFlowElement>(process.getFlowElement())) { loadFlowNode(scene, (Widget) scene, flowElement_Load); } for (IFlowElement flowElement_Load : new CopyOnWriteArrayList<IFlowElement>(process.getFlowElement())) { loadBoundaryEvent(scene, flowElement_Load); } for (IFlowElement flowElement_Load : new CopyOnWriteArrayList<IFlowElement>(process.getFlowElement())) { loadEdge(scene, flowElement_Load); } for (IArtifact artifact_Load : new CopyOnWriteArrayList<IArtifact>(process.getArtifact())) { loadArtifact(scene, artifact_Load); } for (DiagramElement diagramElement_Tmp : diagram.getBPMNPlane().getDiagramElement()) { loadDiagram(scene, diagram, diagramElement_Tmp); } } catch (JAXBException e) { io.getOut().println("Exception: " + e.toString()); e.printStackTrace(); // Exceptions.printStackTrace(e); System.out.println("Document XML Not Exist"); } }
From source file:org.talend.components.marketo.runtime.client.MarketoSOAPClient.java
public MarketoSyncResult listOperation(ListOperationType operationType, ListOperationParameters parameters) { LOG.debug("listOperation : {}", parameters); ParamsListOperation paramsListOperation = new ParamsListOperation(); paramsListOperation.setListOperation(operationType); paramsListOperation.setStrict(objectFactory.createParamsListOperationStrict(parameters.getStrict())); ListKey listKey = new ListKey(); listKey.setKeyValue(parameters.getListKeyValue()); listKey.setKeyType(ListKeyType.valueOf(parameters.getListKeyType())); paramsListOperation.setListKey(listKey); ArrayOfLeadKey leadKeys = new ArrayOfLeadKey(); for (String lkv : parameters.getLeadKeyValues()) { LeadKey lk = new LeadKey(); lk.setKeyType(valueOf(parameters.getLeadKeyType())); lk.setKeyValue(lkv);//from w w w .j a v a 2 s . c o m leadKeys.getLeadKeies().add(lk); } paramsListOperation.setListMemberList(leadKeys); MarketoSyncResult mkto = new MarketoSyncResult(); mkto.setRequestId(SOAP + "::" + operationType.name()); try { SuccessListOperation result = getPort().listOperation(paramsListOperation, header); if (LOG.isDebugEnabled()) { try { JAXBContext context = JAXBContext.newInstance(SuccessListOperation.class); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); m.marshal(result, System.out); } catch (JAXBException e) { LOG.error(e.getMessage()); } } mkto.setSuccess(true); if (!result.getResult().getStatusList().isNil()) { mkto.setRecordCount(result.getResult().getStatusList().getValue().getLeadStatuses().size()); List<LeadStatus> statuses = result.getResult().getStatusList().getValue().getLeadStatuses(); List<SyncStatus> resultStatus = new ArrayList<>(); for (LeadStatus status : statuses) { SyncStatus sts = new SyncStatus(Integer.parseInt(status.getLeadKey().getKeyValue()), String.valueOf(status.isStatus())); if (!status.isStatus() && !ISMEMBEROFLIST.equals(operationType)) { Map<String, String> reason = new HashMap<>(); reason.put("code", "20103"); reason.put("message", "Lead Not Found"); sts.setReasons(Collections.singletonList(reason)); } resultStatus.add(sts); } mkto.setRecords(resultStatus); } else { LOG.debug("No detail about successed operation, building one..."); String success = String.valueOf(result.getResult().isSuccess()); mkto.setRecordCount(parameters.getLeadKeyValue().size()); for (String leadk : parameters.getLeadKeyValue()) { SyncStatus status = new SyncStatus(Integer.parseInt(leadk), success); mkto.getRecords().add(status); } } } catch (Exception e) { LOG.error("[{}] error: {}", operationType.name(), e.getMessage()); mkto.setSuccess(false); mkto.setErrors(Collections.singletonList(new MarketoError(SOAP, e.toString()))); } return mkto; }
From source file:org.talend.components.marketo.runtime.client.MarketoSOAPClient.java
/** * Request<br/>/*from ww w .j av a 2 s .c o m*/ * * Field Name <br/> * <code>leadRecord->Id</code> Required Only when Email or foreignSysPersonId is not present The Marketo Id of the * lead record<br/> * <code>leadRecord->Email</code> Required Only when Id or foreignSysPersonId is not present The email address * associated with the lead record<br/> * <code>leadRecord->foreignSysPersonId</code> Required Only when Id or Email is not present The foreign system id * associated with the lead record<br/> * <code>leadRecord->foreignSysType</code> Optional Only required when foreignSysPersonId is present The type of * foreign system. Possible values: CUSTOM, SFDC, NETSUITE<br/> * <code>leadRecord->leadAttributeList->attribute->attrName</code> Required The name of the lead attribute you want to * update the value of.<br/> * <code>leadRecord->leadAttributeList->attribute->attrValue</code> Required The value you want to set to the lead * attribute specificed in attrName. returnLead Required When true will return the complete updated lead record upon * update.<br/> * <code>marketoCookie</code> Optional The Munchkin javascript cookie<br/> */ @Override public MarketoSyncResult syncLead(TMarketoOutputProperties parameters, IndexedRecord lead) { MarketoSyncResult mkto = new MarketoSyncResult(); try { ParamsSyncLead request = new ParamsSyncLead(); request.setReturnLead(false); // request.setLeadRecord(convertToLeadRecord(lead, parameters.mappingInput.getNameMappingsForMarketo())); MktowsContextHeader headerContext = new MktowsContextHeader(); headerContext.setTargetWorkspace("default"); SuccessSyncLead result = getPort().syncLead(request, header, headerContext); // if (LOG.isDebugEnabled()) { try { JAXBContext context = JAXBContext.newInstance(SuccessSyncLead.class); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); m.marshal(result, System.out); } catch (JAXBException e) { LOG.error(e.getMessage()); } } // com.marketo.mktows.SyncStatus status = result.getResult().getSyncStatus(); mkto.setSuccess(status.getError().isNil()); if (mkto.isSuccess()) { mkto.setRecordCount(1); SyncStatus resultStatus = new SyncStatus(status.getLeadId(), status.getStatus().value()); mkto.setRecords(Collections.singletonList(resultStatus)); } else { mkto.setErrors(Collections.singletonList(new MarketoError(SOAP, status.getError().getValue()))); } } catch (Exception e) { LOG.error(e.toString()); mkto.setSuccess(false); mkto.setErrors(Collections.singletonList(new MarketoError(SOAP, e.getMessage()))); } return mkto; }
From source file:org.talend.components.marketo.runtime.client.MarketoSOAPClient.java
@Override public MarketoSyncResult syncMultipleLeads(TMarketoOutputProperties parameters, List<IndexedRecord> leads) { MarketoSyncResult mkto = new MarketoSyncResult(); try {/*from w ww . j av a 2 s . co m*/ ParamsSyncMultipleLeads request = new ParamsSyncMultipleLeads(); ArrayOfLeadRecord leadRecords = new ArrayOfLeadRecord(); for (IndexedRecord r : leads) { leadRecords.getLeadRecords() .add(convertToLeadRecord(r, parameters.mappingInput.getNameMappingsForMarketo())); } JAXBElement<Boolean> dedup = objectFactory .createParamsSyncMultipleLeadsDedupEnabled(parameters.deDupeEnabled.getValue()); request.setDedupEnabled(dedup); request.setLeadRecordList(leadRecords); SuccessSyncMultipleLeads result = getPort().syncMultipleLeads(request, header); // if (LOG.isDebugEnabled()) { try { JAXBContext context = JAXBContext.newInstance(SuccessSyncLead.class); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); m.marshal(result, System.out); } catch (JAXBException e) { LOG.error(e.getMessage()); } } // List<SyncStatus> records = new ArrayList<>(); for (com.marketo.mktows.SyncStatus status : result.getResult().getSyncStatusList().getSyncStatuses()) { SyncStatus s = new SyncStatus(status.getLeadId(), status.getStatus().value()); s.setErrorMessage(status.getError().getValue()); records.add(s); } mkto.setSuccess(result.getResult().getSyncStatusList() != null); mkto.setRecords(records); } catch (Exception e) { LOG.error(e.toString()); mkto.setSuccess(false); mkto.setErrors(Collections.singletonList(new MarketoError(SOAP, e.getMessage()))); } return mkto; }