protected Object unwrap(Object data) { if (data instanceof Wrapped) { return ((Wrapped) data).unwrap(); } return data; }
protected Object unwrap(Object data) { if (data instanceof Wrapped) { return ((Wrapped) data).unwrap(); } return data; }
@Override public List<?> unwrap() { List<Object> unwrapped = new ArrayList<Object>(); if (items != null) { for (Object o : items) { Object item = o; if (o instanceof Wrapped) { item = ((Wrapped) o).unwrap(); } unwrapped.add(item); } } return unwrapped; } }
@Override public Map<String, Object> unwrap() { if (entries == null || entries.isEmpty()) { return Collections.emptyMap(); } for (Map.Entry<String, Object> entry : entries.entrySet()) { if (entry.getValue() instanceof Wrapped) { entry.setValue(((Wrapped) entry.getValue()).unwrap()); } } return entries; } }
public <T> T unmarshal(String data, String marshallingFormat, Class<T> unmarshalType) { if (data == null || data.isEmpty()) { return null; } MarshallingFormat format = getFormat(marshallingFormat); Marshaller marshaller = serverMarshallers.get(format); if (marshaller == null) { marshaller = MarshallerFactory.getMarshaller(getExtraClasses(registry), format, this.getClass().getClassLoader()); serverMarshallers.put(format, marshaller); } Object instance = marshaller.unmarshall(data, unmarshalType); if (instance instanceof Wrapped) { return (T) ((Wrapped) instance).unwrap(); } return (T) instance; }
protected void unwrapParameters() { if (parameters == null) { return; } for (QueryParam param : parameters) { if (param.getValue() != null) { List<Object> items = new ArrayList<>(); param.getValue().forEach(item -> { Object toAdd = item; if (item instanceof Wrapped) { toAdd = ((Wrapped) item).unwrap(); } items.add(toAdd); }); param.setValue(items); } } } }
public static <T> T unmarshal(String data, String marshallingFormat, Class<T> unmarshalType) { if (data == null || data.isEmpty()) { return null; } MarshallingFormat format = getFormat(marshallingFormat); Marshaller marshaller = null; switch (format) { case JAXB: { marshaller = jaxbMarshaller; break; } case JSON: { marshaller = jsonMarshaller; break; } default: { marshaller = jsonMarshaller; break; } } Object instance = marshaller.unmarshall(data, unmarshalType); if (instance instanceof Wrapped) { return (T) ((Wrapped) instance).unwrap(); } return (T) instance; }
public <T> T unmarshal(String containerId, String data, String marshallingFormat, Class<T> unmarshalType, ContainerLocator locator) { if (data == null || data.isEmpty()) { return null; } MarshallingFormat format = getFormat(marshallingFormat); KieContainerInstance containerInstance = registry.getContainer(containerId, locator); if (containerInstance == null || format == null) { throw new IllegalArgumentException("No container found for id " + containerId + " or unknown marshalling format " + marshallingFormat); } Marshaller marshaller = containerInstance.getMarshaller(format); if (marshaller == null) { throw new IllegalArgumentException("No marshaller found for format " + format); } Object instance = marshaller.unmarshall(data, unmarshalType); if (instance instanceof Wrapped) { return (T) ((Wrapped) instance).unwrap(); } return (T) instance; }
logger.debug("Before :: Argument with type {} and value {}", arg.getClass(), arg); if (arg instanceof Wrapped) { arg = ((Wrapped) arg).unwrap();
LOG.debug("Before :: Argument with type {} and value {}", arg.getClass(), arg); if (arg instanceof Wrapped) { arg = ((Wrapped) arg).unwrap();
arg); if (arg instanceof Wrapped) { arg = ((Wrapped) arg).unwrap();
result = ((Wrapped)result).unwrap();
logger.debug("Before :: Argument with type {} and value {}", arg.getClass(), arg); if (arg instanceof Wrapped) { arg = ((Wrapped) arg).unwrap();
logger.debug("Before :: Argument with type {} and value {}", arg.getClass(), arg); if (arg instanceof Wrapped) { arg = ((Wrapped<?>) arg).unwrap();
@Override public Object getCaseInstanceData(String containerId, String caseId, String name) { Object result = null; if( config.isRest() ) { Map<String, Object> valuesMap = new HashMap<String, Object>(); valuesMap.put(CONTAINER_ID, containerId); valuesMap.put(CASE_ID, caseId); valuesMap.put(CASE_FILE_ITEM, name); result = makeHttpGetRequestAndCreateCustomResponse( build(loadBalancer.getUrl(), CASE_URI + "/" + CASE_FILE_BY_NAME_GET_URI, valuesMap), Object.class); } else { CommandScript script = new CommandScript( Collections.singletonList( (KieServerCommand) new DescriptorCommand("CaseService", "getCaseFileDataByName", marshaller.getFormat().getType(), new Object[]{containerId, caseId, name})) ); ServiceResponse<String> response = (ServiceResponse<String>) executeJmsCommand( script, DescriptorCommand.class.getName(), KieServerConstants.CAPABILITY_CASE ).getResponses().get(0); if (shouldReturnWithNullResponse(response)) { return null; } result = deserialize(response.getResult(), Object.class); } if (result instanceof Wrapped) { return ((Wrapped) result).unwrap(); } return result; }
@Override public Long notifyWhenNotCompleted(String containerId, Long taskId, String expiresAt, EmailNotification emailNotification) { Object result = null; if( config.isRest() ) { Map<String, Object> valuesMap = new HashMap<String, Object>(); valuesMap.put(CONTAINER_ID, containerId); valuesMap.put(TASK_INSTANCE_ID, taskId); Map<String, String> headers = new HashMap<String, String>(); String queryString = "?expiresAt=" + expiresAt+"&whenNotCompleted=true"; result = makeHttpPostRequestAndCreateCustomResponse( build(loadBalancer.getUrl(), ADMIN_TASK_URI + "/" + TASK_INSTANCE_NOTIFICATIONS_URI, valuesMap) + queryString, emailNotification, Object.class, headers); } else { CommandScript script = new CommandScript( Collections.singletonList( (KieServerCommand) new DescriptorCommand("UserTaskAdminService", "notifyWhenNotCompleted", serialize(emailNotification), marshaller.getFormat().getType(), new Object[]{containerId, taskId, expiresAt}))); ServiceResponse<String> response = (ServiceResponse<String>) executeJmsCommand( script, DescriptorCommand.class.getName(), "BPM", containerId ).getResponses().get(0); throwExceptionOnFailure(response); if (shouldReturnWithNullResponse(response)) { return null; } result = deserialize(response.getResult(), Object.class); } if (result instanceof Wrapped) { return (Long) ((Wrapped) result).unwrap(); } return ((Number) result).longValue(); }
@Override public Long reassignWhenNotCompleted(String containerId, Long taskId, String expiresAt, OrgEntities orgEntities) { Object result = null; if( config.isRest() ) { Map<String, Object> valuesMap = new HashMap<String, Object>(); valuesMap.put(CONTAINER_ID, containerId); valuesMap.put(TASK_INSTANCE_ID, taskId); Map<String, String> headers = new HashMap<String, String>(); String queryString = "?expiresAt=" + expiresAt+"&whenNotCompleted=true"; result = makeHttpPostRequestAndCreateCustomResponse( build(loadBalancer.getUrl(), ADMIN_TASK_URI + "/" + TASK_INSTANCE_REASSIGNMENTS_URI, valuesMap) + queryString, orgEntities, Object.class, headers); } else { CommandScript script = new CommandScript( Collections.singletonList( (KieServerCommand) new DescriptorCommand("UserTaskAdminService", "reassignWhenNotCompleted", serialize(orgEntities), marshaller.getFormat().getType(), new Object[]{containerId, taskId, expiresAt}))); ServiceResponse<String> response = (ServiceResponse<String>) executeJmsCommand( script, DescriptorCommand.class.getName(), "BPM", containerId ).getResponses().get(0); throwExceptionOnFailure(response); if (shouldReturnWithNullResponse(response)) { return null; } result = deserialize(response.getResult(), Object.class); } if (result instanceof Wrapped) { return (Long) ((Wrapped) result).unwrap(); } return ((Number) result).longValue(); }
@Override public Long reassignWhenNotStarted(String containerId, Long taskId, String expiresAt, OrgEntities orgEntities) { Object result = null; if( config.isRest() ) { Map<String, Object> valuesMap = new HashMap<String, Object>(); valuesMap.put(CONTAINER_ID, containerId); valuesMap.put(TASK_INSTANCE_ID, taskId); Map<String, String> headers = new HashMap<String, String>(); String queryString = "?expiresAt=" + expiresAt+"&whenNotStarted=true"; result = makeHttpPostRequestAndCreateCustomResponse( build(loadBalancer.getUrl(), ADMIN_TASK_URI + "/" + TASK_INSTANCE_REASSIGNMENTS_URI, valuesMap) + queryString, orgEntities, Object.class, headers); } else { CommandScript script = new CommandScript( Collections.singletonList( (KieServerCommand) new DescriptorCommand("UserTaskAdminService", "reassignWhenNotStarted", serialize(orgEntities), marshaller.getFormat().getType(), new Object[]{containerId, taskId, expiresAt}))); ServiceResponse<String> response = (ServiceResponse<String>) executeJmsCommand( script, DescriptorCommand.class.getName(), "BPM", containerId ).getResponses().get(0); throwExceptionOnFailure(response); if (shouldReturnWithNullResponse(response)) { return null; } result = deserialize(response.getResult(), Object.class); } if (result instanceof Wrapped) { return (Long) ((Wrapped) result).unwrap(); } return ((Number) result).longValue(); }
@Override public Long notifyWhenNotStarted(String containerId, Long taskId, String expiresAt, EmailNotification emailNotification) { Object result = null; if( config.isRest() ) { Map<String, Object> valuesMap = new HashMap<String, Object>(); valuesMap.put(CONTAINER_ID, containerId); valuesMap.put(TASK_INSTANCE_ID, taskId); Map<String, String> headers = new HashMap<String, String>(); String queryString = "?expiresAt=" + expiresAt+"&whenNotStarted=true"; result = makeHttpPostRequestAndCreateCustomResponse( build(loadBalancer.getUrl(), ADMIN_TASK_URI + "/" + TASK_INSTANCE_NOTIFICATIONS_URI, valuesMap) + queryString, emailNotification, Object.class, headers); } else { CommandScript script = new CommandScript( Collections.singletonList( (KieServerCommand) new DescriptorCommand("UserTaskAdminService", "notifyWhenNotStarted", serialize(emailNotification), marshaller.getFormat().getType(), new Object[]{containerId, taskId, expiresAt}))); ServiceResponse<String> response = (ServiceResponse<String>) executeJmsCommand( script, DescriptorCommand.class.getName(), "BPM", containerId ).getResponses().get(0); throwExceptionOnFailure(response); if (shouldReturnWithNullResponse(response)) { return null; } result = deserialize(response.getResult(), Object.class); } if (result instanceof Wrapped) { return (Long) ((Wrapped) result).unwrap(); } return ((Number) result).longValue(); }
@Override public <T> T getProcessInstanceVariable(String containerId, Long processInstanceId, String variableName, Class<T> type) { Object result = null; if( config.isRest() ) { Map<String, Object> valuesMap = new HashMap<String, Object>(); valuesMap.put(CONTAINER_ID, containerId); valuesMap.put(PROCESS_INST_ID, processInstanceId); valuesMap.put(VAR_NAME, variableName); result = makeHttpGetRequestAndCreateCustomResponse( build(loadBalancer.getUrl(), PROCESS_URI + "/" + PROCESS_INSTANCE_VAR_GET_URI, valuesMap), type); } else { CommandScript script = new CommandScript( Collections.singletonList( (KieServerCommand) new DescriptorCommand( "ProcessService", "getProcessInstanceVariable", marshaller.getFormat().getType(), new Object[]{containerId, processInstanceId, variableName}) ) ); ServiceResponse<String> response = (ServiceResponse<String>) executeJmsCommand( script, DescriptorCommand.class.getName(), "BPM", containerId ).getResponses().get(0); throwExceptionOnFailure(response); if (shouldReturnWithNullResponse(response)) { return null; } result = deserialize(response.getResult(), type); } if (result instanceof Wrapped) { return (T) ((Wrapped) result).unwrap(); } return (T) result; }