use of org.ovirt.engine.sdk4.Error in project kie-wb-common by kiegroup.
the class EventPropertyWriterTest method testAddError.
@Test
public void testAddError() {
final ArgumentCaptor<RootElement> captor = ArgumentCaptor.forClass(RootElement.class);
ErrorRef errorRef = new ErrorRef();
errorRef.setValue(ERROR_CODE);
propertyWriter.addError(errorRef);
ErrorEventDefinition definition = getErrorDefinition();
assertEquals(ERROR_CODE, definition.getErrorRef().getErrorCode());
assertFalse(definition.getErrorRef().getId().isEmpty());
verify(propertyWriter).addRootElement(captor.capture());
Error error = (Error) captor.getValue();
assertEquals(ERROR_CODE, error.getErrorCode());
assertFalse(error.getId().isEmpty());
}
use of org.ovirt.engine.sdk4.Error in project kie-wb-common by kiegroup.
the class EventPropertyWriterTest method testAddEmptyError.
@Test
public void testAddEmptyError() {
final ArgumentCaptor<RootElement> captor = ArgumentCaptor.forClass(RootElement.class);
ErrorRef errorRef = new ErrorRef();
propertyWriter.addError(errorRef);
ErrorEventDefinition definition = getErrorDefinition();
assertNull(definition.getErrorRef().getErrorCode());
assertFalse(definition.getErrorRef().getId().isEmpty());
verify(propertyWriter).addRootElement(captor.capture());
Error error = (Error) captor.getValue();
assertNull(error.getErrorCode());
assertFalse(error.getId().isEmpty());
}
use of org.ovirt.engine.sdk4.Error in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method setThrowEventsInfo.
public void setThrowEventsInfo(FlowElementsContainer container, Definitions def, List<RootElement> rootElements, List<Signal> toAddSignals, Set<Error> toAddErrors, Set<Escalation> toAddEscalations, Set<Message> toAddMessages, Set<ItemDefinition> toAddItemDefinitions) {
List<FlowElement> flowElements = container.getFlowElements();
for (FlowElement fe : flowElements) {
if (fe instanceof ThrowEvent) {
if (((ThrowEvent) fe).getEventDefinitions().size() > 0) {
EventDefinition ed = ((ThrowEvent) fe).getEventDefinitions().get(0);
if (ed instanceof SignalEventDefinition) {
SignalEventDefinition sed = (SignalEventDefinition) ed;
if (sed.getSignalRef() != null && sed.getSignalRef().length() > 0) {
String signalRef = sed.getSignalRef();
boolean shouldAddSignal = true;
for (RootElement re : rootElements) {
if (re instanceof Signal) {
if (((Signal) re).getName().equals(signalRef)) {
shouldAddSignal = false;
break;
}
}
}
if (toAddSignals != null) {
for (Signal s : toAddSignals) {
if (s.getName().equals(signalRef)) {
shouldAddSignal = false;
break;
}
}
}
if (shouldAddSignal) {
Signal signal = Bpmn2Factory.eINSTANCE.createSignal();
signal.setName(signalRef);
toAddSignals.add(signal);
}
}
} else if (ed instanceof ErrorEventDefinition) {
String errorCode = null;
String errorId = null;
Iterator<FeatureMap.Entry> iter = ed.getAnyAttribute().iterator();
while (iter.hasNext()) {
FeatureMap.Entry entry = iter.next();
if (entry.getEStructuralFeature().getName().equals("erefname")) {
errorId = (String) entry.getValue();
errorCode = (String) entry.getValue();
}
}
Error err = this._errors.get(errorCode);
if (err == null) {
err = Bpmn2Factory.eINSTANCE.createError();
err.setId(errorId);
err.setErrorCode(errorCode);
this._errors.put(errorCode, err);
}
toAddErrors.add(err);
((ErrorEventDefinition) ed).setErrorRef(err);
} else if (ed instanceof EscalationEventDefinition) {
String escalationCode = null;
Iterator<FeatureMap.Entry> iter = ed.getAnyAttribute().iterator();
while (iter.hasNext()) {
FeatureMap.Entry entry = iter.next();
if (entry.getEStructuralFeature().getName().equals("esccode")) {
escalationCode = (String) entry.getValue();
break;
}
}
Escalation escalation = this._escalations.get(escalationCode);
if (escalation == null) {
escalation = Bpmn2Factory.eINSTANCE.createEscalation();
escalation.setEscalationCode(escalationCode);
this._escalations.put(escalationCode, escalation);
}
toAddEscalations.add(escalation);
((EscalationEventDefinition) ed).setEscalationRef(escalation);
} else if (ed instanceof MessageEventDefinition) {
((MessageEventDefinition) ed).setMessageRef(extractMessage(ed, toAddMessages, toAddItemDefinitions));
} else if (ed instanceof CompensateEventDefinition) {
Iterator<FeatureMap.Entry> iter = ed.getAnyAttribute().iterator();
while (iter.hasNext()) {
FeatureMap.Entry entry = iter.next();
if (entry.getEStructuralFeature().getName().equals("actrefname")) {
String activityNameRef = (String) entry.getValue();
// we have to iterate again through all flow
// elements
// in order to find our activity name
List<RootElement> re = def.getRootElements();
for (RootElement r : re) {
if (r instanceof Process) {
Process p = (Process) r;
List<FlowElement> fes = p.getFlowElements();
for (FlowElement f : fes) {
if (f instanceof Activity && ((Activity) f).getName().equals(activityNameRef)) {
((CompensateEventDefinition) ed).setActivityRef((Activity) f);
((Activity) f).setIsForCompensation(true);
}
}
}
}
}
}
}
}
} else if (fe instanceof FlowElementsContainer) {
setThrowEventsInfo((FlowElementsContainer) fe, def, rootElements, toAddSignals, toAddErrors, toAddEscalations, toAddMessages, toAddItemDefinitions);
}
}
}
use of org.ovirt.engine.sdk4.Error in project javacv by bytedeco.
the class FlyCapture2FrameGrabber method getDeviceDescriptions.
public static String[] getDeviceDescriptions() throws FrameGrabber.Exception {
tryLoad();
BusManager busMgr = new BusManager();
int[] numCameras = new int[1];
busMgr.GetNumOfCameras(numCameras);
String[] descriptions = new String[numCameras[0]];
for (int i = 0; i < numCameras[0]; i++) {
PGRGuid guid = new PGRGuid();
Error error = busMgr.GetCameraFromIndex(i, guid);
if (error.notEquals(PGRERROR_OK)) {
PrintError(error);
System.exit(-1);
}
Camera cam = new Camera();
// Connect to a camera
error = cam.Connect(guid);
if (error.notEquals(PGRERROR_OK)) {
PrintError(error);
}
// Get the camera information
CameraInfo camInfo = new CameraInfo();
error = cam.GetCameraInfo(camInfo);
if (error.notEquals(PGRERROR_OK)) {
PrintError(error);
}
descriptions[i] = CameraInfo(camInfo);
}
return descriptions;
}
use of org.ovirt.engine.sdk4.Error in project ovirt-engine-sdk-java by oVirt.
the class ConnectionBuilder method build.
/**
* Checks the values of the parameters given so far, checks that they are valid, and builds a connection using
* them.
*
* @return the new connection
*/
public Connection build() {
try {
// Check the parameters:
if (url == null) {
throw new IllegalArgumentException("The 'url' parameter is mandatory");
}
if (trustStoreFile != null && !new File(trustStoreFile).exists()) {
throw new IllegalArgumentException(String.format("The truststore file '%s' doesn't exist'", trustStoreFile));
}
urlobj = new URL(url);
// If all the checks pass, then create the connection:
HttpConnection connection = new HttpConnection();
connection.setClient(createHttpClient());
connection.setUrl(url);
connection.setUser(user);
connection.setPassword(password);
connection.setSsoToken(token);
connection.setKerberos(kerberos);
connection.setSsoUrl(ssoUrl);
connection.setSsoTokenName(ssoTokenName);
connection.setSsoRevokeUrl(ssoRevokeUrl);
connection.setHeaders(headers);
return connection;
} catch (Exception e) {
throw new Error("Failed to build connection", e);
}
}
Aggregations