Java Code Examples for org.apache.camel.Message#setHeader()

The following examples show how to use org.apache.camel.Message#setHeader() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ManagementBusDeploymentPluginRemote.java    From container with Apache License 2.0 6 votes vote down vote up
@Override
public Exchange invokeImplementationArtifactUndeployment(final Exchange exchange) {
    LOG.debug("Trying to undeploy IA on remote OpenTOSCA Container.");
    final Message message = exchange.getIn();

    // create empty request message (only headers needed)
    final CollaborationMessage requestBody = new CollaborationMessage(new KeyValueMap(), null);
    // perform remote undeployment
    final Exchange response = requestSender.sendRequestToRemoteContainer(message, RemoteOperations.INVOKE_IA_UNDEPLOYMENT, requestBody,
        0);

    // extract the undeployment state from the response
    final boolean state = response.getIn().getHeader(MBHeader.OPERATIONSTATE_BOOLEAN.toString(), boolean.class);
    LOG.debug("Result of remote undeployment: Success: {}", state);

    // add the header to the incoming exchange and return result
    message.setHeader(MBHeader.OPERATIONSTATE_BOOLEAN.toString(), state);
    return exchange;
}
 
Example 2
Source File: SourceOverride.java    From smsrouter with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void process(Exchange exchange) throws Exception {
	Message message = exchange.getIn();
	
	if(!message.getHeaders().containsKey(countryHeader)) {
		logger.debug("country header {} not present", countryHeader);
		return;
	}
	
	String destCountry = message.getHeader(countryHeader, String.class)
			.toUpperCase();
	String override = overrideSources.get(destCountry);
	if(override != null) {
		logger.debug("Overriding with source number {}", override);
		message.setHeader(sourceHeader, override);
	}
}
 
Example 3
Source File: CamelHelperTest.java    From vertx-camel-bridge with Apache License 2.0 6 votes vote down vote up
@Test
public void testTheCopyOfHeaders() {
  Message msg = new DefaultMessage(new DefaultCamelContext());
  msg.setHeader("CamelRedelivered", false);
  msg.setHeader("CamelRedeliveryCounter", 0);
  msg.setHeader("JMSCorrelationID", "");
  msg.setHeader("JMSDestination", "queue://dev.msy.queue.log.fwd");
  msg.setHeader("JMSReplyTo", null);

  DeliveryOptions options = CamelHelper.getDeliveryOptions(msg, true);

  assertThat(options.getHeaders().get("CamelRedelivered")).isEqualToIgnoringCase("false");
  assertThat(options.getHeaders().get("CamelRedeliveryCounter")).isEqualToIgnoringCase("0");
  assertThat(options.getHeaders().get("JMSCorrelationID")).isEqualToIgnoringCase("");
  assertThat(options.getHeaders().get("JMSDestination")).isEqualToIgnoringCase("queue://dev.msy.queue.log.fwd");
  assertThat(options.getHeaders().get("JMSReplyTo")).isNull();

}
 
Example 4
Source File: ThrottlerDynamicSpringTest.java    From camel-cookbook-examples with Apache License 2.0 6 votes vote down vote up
@Test
public void testThrottleDynamic() throws Exception {
    final int throttleRate = 3;
    final int messageCount = throttleRate + 2;

    getMockEndpoint("mock:unthrottled").expectedMessageCount(messageCount);
    getMockEndpoint("mock:throttled").expectedMessageCount(throttleRate);
    getMockEndpoint("mock:after").expectedMessageCount(throttleRate);

    for (int i = 0; i < messageCount; i++) {
        Exchange exchange = getMandatoryEndpoint("direct:start").createExchange();
        {
            Message in = exchange.getIn();
            in.setHeader("throttleRate", throttleRate);
            in.setBody("Camel Rocks");
        }
        template.asyncSend("direct:start", exchange);
    }

    // the test will stop once all of the conditions have been met
    // the only way this set of conditions can happen is if 2
    // messages are currently suspended for throttling
    assertMockEndpointsSatisfied();
}
 
Example 5
Source File: ActivityTrackingInterceptStrategy.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Override
public boolean process(final Exchange exchange, final AsyncCallback callback) {
    final String trackerId = KeyGenerator.createKey();
    final long createdAt = System.nanoTime();
    final Message in = exchange.getIn();
    in.setHeader(IntegrationLoggingConstants.STEP_TRACKER_ID, trackerId);

    return super.process(exchange, doneSync -> {
        final String activityId =  ActivityTracker.getActivityId(exchange);

        if (activityId != null) {
            tracker.track(
                "exchange", activityId,
                "step", stepId,
                "id", trackerId,
                "duration", System.nanoTime() - createdAt,
                "failure", failure(exchange)
            );
        }

        callback.done(doneSync);
    });
}
 
Example 6
Source File: OpenstackIntegrationTest.java    From wildfly-camel with Apache License 2.0 6 votes vote down vote up
@Test
public void createSwiftContainer() throws Exception {
    ExtendedCamelContext camelContext = Mockito.mock(ExtendedCamelContext.class);
    when(camelContext.getHeadersMapFactory()).thenReturn(new DefaultHeadersMapFactory());

    Message msg = new DefaultMessage(camelContext);
    Exchange exchange = Mockito.mock(Exchange.class);
    when(exchange.getIn()).thenReturn(msg);

    when(containerService.create(anyString(), nullable(CreateUpdateContainerOptions.class))).thenReturn(actionResponse);
    when(actionResponse.isSuccess()).thenReturn(true);

    SwiftEndpoint endpoint = Mockito.mock(SwiftEndpoint.class);
    Producer producer = new ContainerProducer(endpoint, client);
    msg.setHeader(OpenstackConstants.OPERATION, OpenstackConstants.CREATE);
    msg.setHeader(SwiftConstants.CONTAINER_NAME, CONTAINER_NAME);

    producer.process(exchange);

    ArgumentCaptor<String> containerNameCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<CreateUpdateContainerOptions> optionsCaptor = ArgumentCaptor.forClass(CreateUpdateContainerOptions.class);

    verify(containerService).create(containerNameCaptor.capture(), optionsCaptor.capture());
    assertEquals(CONTAINER_NAME, containerNameCaptor.getValue());
    assertNull(optionsCaptor.getValue());
}
 
Example 7
Source File: GmailSendEmailCustomizer.java    From syndesis with Apache License 2.0 6 votes vote down vote up
private void beforeProducer(Exchange exchange) throws MessagingException, IOException {

        final Message in = exchange.getIn();
        final GmailMessageModel mail = exchange.getIn().getBody(GmailMessageModel.class);
        if (mail != null) {
            if (ObjectHelper.isNotEmpty(mail.getText())) {
                text = mail.getText();
            }
            if (ObjectHelper.isNotEmpty(mail.getSubject())) {
                subject = mail.getSubject();
            }
            if (ObjectHelper.isNotEmpty(mail.getTo())) {
                to = mail.getTo();
            }
            if (ObjectHelper.isNotEmpty(mail.getCc())) {
                cc = mail.getCc();
            }
            if (ObjectHelper.isNotEmpty(mail.getBcc())) {
                bcc = mail.getBcc();
            }
        }
        com.google.api.services.gmail.model.Message message = createMessage(to, userId, subject, text, cc, bcc);

        in.setHeader("CamelGoogleMail.content", message);
        in.setHeader("CamelGoogleMail.userId", userId);
    }
 
Example 8
Source File: EMailSendCustomizer.java    From syndesis with Apache License 2.0 6 votes vote down vote up
private void beforeProducer(Exchange exchange) throws MessagingException, IOException {
    final Message in = exchange.getIn();
    final EMailMessageModel mail = in.getBody(EMailMessageModel.class);
    if (mail == null) {
        return;
    }

    in.setHeader(MAIL_FROM, updateMail(from, mail.getFrom()));
    in.setHeader(MAIL_TO, updateMail(to, mail.getTo()));
    in.setHeader(MAIL_CC, updateMail(cc, mail.getCc()));
    in.setHeader(MAIL_BCC, updateMail(bcc, mail.getBcc()));
    in.setHeader(MAIL_SUBJECT, updateMail(subject, mail.getSubject()));

    Object content = updateMail(text, mail.getContent());
    in.setBody(content);
    setContentType(content, in);
}
 
Example 9
Source File: SecuritySubjectLoader.java    From camel-cookbook-examples with Apache License 2.0 5 votes vote down vote up
@Override
public void process(Exchange exchange) throws Exception {
    Message in = exchange.getIn();
    String username = in.getHeader("username", String.class);
    String password = in.getHeader("password", String.class);

    Authentication authenticationToken =
        new UsernamePasswordAuthenticationToken(username, password);
    Subject subject = new Subject();
    subject.getPrincipals().add(authenticationToken);
    in.setHeader(Exchange.AUTHENTICATION, subject);
}
 
Example 10
Source File: OAuthRefreshTokenProcessor.java    From syndesis with Apache License 2.0 5 votes vote down vote up
@Override
public void process(final Exchange exchange) throws Exception {
    if (state.getRefreshToken() != null && (isFirstTime.get() || state.getAccessTokenExpiresAt() - AHEAD_OF_TIME_REFRESH_MILIS <= now())) {
        tryToRefreshAccessToken();
    }

    final Message in = exchange.getIn();
    in.setHeader("Authorization", "Bearer " + state.getAccessToken());

    SyndesisHeaderStrategy.whitelist(exchange, "Authorization");
}
 
Example 11
Source File: ODataReadToCustomizer.java    From syndesis with Apache License 2.0 5 votes vote down vote up
@Override
protected void beforeProducer(Exchange exchange) throws IOException {
    Message in = exchange.getIn();

    String body = in.getBody(String.class);
    JsonNode node = OBJECT_MAPPER.readTree(body);
    JsonNode keyPredicateNode = node.get(KEY_PREDICATE);

    if (! ObjectHelper.isEmpty(keyPredicateNode)) {
        String keyPredicate = keyPredicateNode.asText();

        //
        // Change the resource path instead as there is a bug in using the
        // keyPredicate header (adds brackets around regardless of a subpredicate
        // being present). When that's fixed we can revert back to using keyPredicate
        // header instead.
        //
        in.setHeader(OLINGO4_PROPERTY_PREFIX + RESOURCE_PATH,
                     resourcePath + ODataUtil.formatKeyPredicate(keyPredicate, true));
    } else {
        //
        // Necessary to have a key predicate. Otherwise, read will try returning
        // all results which could very be painful for the running integration.
        //
        throw new RuntimeCamelException("Key Predicate value was empty");
    }

    in.setBody(EMPTY_STRING);
}
 
Example 12
Source File: ForUpdateCustomizer.java    From syndesis with Apache License 2.0 5 votes vote down vote up
public void beforeProducer(final Exchange exchange) throws IOException {
    // parse input json and extract Id field
    final Message in = exchange.getIn();
    final String body = in.getBody(String.class);

    if (body == null) {
        return;
    }

    final ObjectNode node = (ObjectNode) JsonUtils.reader().readTree(body);

    final JsonNode idProperty = node.remove(idPropertyName);
    if (idProperty == null) {
        exchange.setException(
            new SalesforceException("Missing option value for Id or " + SalesforceEndpointConfig.SOBJECT_EXT_ID_NAME, 404));

        return;
    }

    final String idValue = idProperty.textValue();
    if ("Id".equals(idPropertyName)) {
        in.setHeader(SalesforceEndpointConfig.SOBJECT_ID, idValue);
    } else {
        in.setHeader(SalesforceEndpointConfig.SOBJECT_EXT_ID_VALUE, idValue);
    }

    // base fields are not allowed to be updated
    clearBaseFields(node);

    // update input json
    in.setBody(JsonUtils.writer().writeValueAsString(node));
}
 
Example 13
Source File: OpenstackIntegrationTest.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@Test
public void testNovaKeypair() throws Exception {
    when(osTestKeypair.getName()).thenReturn(KEYPAIR_NAME);
    when(osTestKeypair.getPublicKey()).thenReturn(dummyKeypair.getPublicKey());
    when(osTestKeypair.getFingerprint()).thenReturn("fp");
    when(osTestKeypair.getPrivateKey()).thenReturn("prk");

    ExtendedCamelContext camelContext = Mockito.mock(ExtendedCamelContext.class);
    when(camelContext.getHeadersMapFactory()).thenReturn(new DefaultHeadersMapFactory());

    Message msg = new DefaultMessage(camelContext);
    msg.setHeader(OpenstackConstants.OPERATION, OpenstackConstants.CREATE);
    msg.setHeader(OpenstackConstants.NAME, KEYPAIR_NAME);

    Exchange exchange = Mockito.mock(Exchange.class);
    when(exchange.getIn()).thenReturn(msg);

    NovaEndpoint endpoint = Mockito.mock(NovaEndpoint.class);
    Producer producer = new KeypairProducer(endpoint, client);
    producer.process(exchange);

    ArgumentCaptor<String> nameCaptor = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<String> keypairCaptor = ArgumentCaptor.forClass(String.class);
    verify(keypairService).create(nameCaptor.capture(), keypairCaptor.capture());

    assertEquals(KEYPAIR_NAME, nameCaptor.getValue());
    assertNull(keypairCaptor.getValue());

    Keypair result = msg.getBody(Keypair.class);
    assertEquals("fp", result.getFingerprint());
    assertEquals("prk", result.getPrivateKey());
    assertEquals(dummyKeypair.getName(), result.getName());
    assertEquals(dummyKeypair.getPublicKey(), result.getPublicKey());
}
 
Example 14
Source File: AWSSNSMessageCustomizer.java    From syndesis with Apache License 2.0 5 votes vote down vote up
public void beforeProducer(final Exchange exchange) throws IOException {
    final Message in = exchange.getIn();
    final SNSMessage message = in.getBody(SNSMessage.class);

    if (message != null) {
        in.setBody(message.getMessage());
    }
    if (message != null && ObjectHelper.isNotEmpty(message.getSubject())) {
        in.setHeader(SnsConstants.SUBJECT, message.getSubject());
    }
}
 
Example 15
Source File: AWSS3CopyObjectCustomizer.java    From syndesis with Apache License 2.0 5 votes vote down vote up
public void beforeProducer(final Exchange exchange) throws IOException {
    final Message in = exchange.getIn();

    if (filenameKey != null) {
        in.setHeader(S3Constants.KEY, filenameKey);
    }
}
 
Example 16
Source File: FhirCreateUpdateBaseCustomizer.java    From syndesis with Apache License 2.0 4 votes vote down vote up
public void beforeProducer(Exchange exchange) {
    final Message in = exchange.getIn();
    String resource = in.getBody(String.class);
    in.setHeader("CamelFhir.resourceAsString", resource);
}
 
Example 17
Source File: GoogleSheetsCreateSpreadsheetCustomizer.java    From syndesis with Apache License 2.0 4 votes vote down vote up
private void beforeProducer(Exchange exchange) {
    final Message in = exchange.getIn();
    final GoogleSpreadsheet model = exchange.getIn().getBody(GoogleSpreadsheet.class);

    if (model != null) {
        if (ObjectHelper.isNotEmpty(model.getTitle())) {
            title = model.getTitle();
        }
        if (ObjectHelper.isNotEmpty(model.getTimeZone())) {
            timeZone = model.getTimeZone();
        }
        if (ObjectHelper.isNotEmpty(model.getLocale())) {
            locale = model.getLocale();
        }
    }

    Spreadsheet spreadsheet = new Spreadsheet();
    SpreadsheetProperties spreadsheetProperties = new SpreadsheetProperties();

    spreadsheetProperties.setTitle(title);
    spreadsheetProperties.setTimeZone(timeZone);
    spreadsheetProperties.setLocale(locale);

    spreadsheet.setProperties(spreadsheetProperties);

    if (model != null && ObjectHelper.isNotEmpty(model.getSheets())) {
        List<Sheet> sheets = new ArrayList<>();
        for (GoogleSheet sheetModel : model.getSheets()) {
            Sheet sheet = new Sheet();
            SheetProperties sheetProperties = new SheetProperties();
            sheetProperties.setSheetId(sheetModel.getSheetId());
            sheetProperties.setIndex(sheetModel.getIndex());
            sheetProperties.setTitle(sheetModel.getTitle());
            sheet.setProperties(sheetProperties);
            sheets.add(sheet);
        }
        spreadsheet.setSheets(sheets);
    }

    in.setHeader(GoogleSheetsConstants.PROPERTY_PREFIX + "content", spreadsheet);
}
 
Example 18
Source File: SynchXmlDocumentTranslator.java    From aliada-tool with GNU General Public License v3.0 4 votes vote down vote up
@Override
public final void process(final Exchange exchange) throws Exception {
	final Message in = exchange.getIn();

	final String format = in.getHeader(Constants.FORMAT_ATTRIBUTE_NAME, String.class);
	final Integer jobId = in.getHeader(Constants.JOB_ID_ATTRIBUTE_NAME, Integer.class);
	final JobInstance configuration = cache.getJobInstance(jobId);
	if (configuration == null) {
		log.error(MessageCatalog._00038_UNKNOWN_JOB_ID, jobId);
		throw new IllegalArgumentException(String.valueOf(jobId));
	}

	// Sanity check: if previous processor didn't put a valid data object in the body
	// the conversion chain for this record must stop here
	if (in.getBody() instanceof NullObject) {
		incrementJobStatsAndElapsed(jobId, null, 0);
		return;
	}
	
	VelocityContext velocityContext = null;
	String triples = null;
	
	long elapsed = 0;
	
	try {
		final Template template = velocityEngine.getTemplate(templateName(format));	 
		if (template == null) {
			log.error(MessageCatalog._00040_TEMPLATE_NOT_FOUND, format);
			return;
		}
		
		velocityContext = contexts.get();
		velocityContext.put(Constants.JOB_CONFIGURATION_ATTRIBUTE_NAME, configuration);
		
		populateVelocityContext(velocityContext, in, configuration);
		
		final long begin = System.currentTimeMillis();
		
		final Writer sw = new StringWriter();
		final Writer w = new BufferedWriter(sw);
		template.merge(velocityContext, w);
		w.flush();
		
		elapsed = System.currentTimeMillis() - begin;
		triples = sw.toString();
					
		in.setBody(triples);
		in.setHeader(Constants.GRAPH_ATTRIBUTE_NAME, graphName(configuration));
		
	} catch (final ResourceNotFoundException exception) {
		log.error(MessageCatalog._00040_TEMPLATE_NOT_FOUND, exception, format);
	} finally {
		incrementJobStatsAndElapsed(jobId, triples, elapsed);

		if (velocityContext != null) {
			velocityContext.remove(Constants.MAIN_SUBJECT_ATTRIBUTE_NAME);
			velocityContext.remove(Constants.ROOT_ELEMENT_ATTRIBUTE_NAME);
			velocityContext.remove(Constants.JOB_CONFIGURATION_ATTRIBUTE_NAME);
			velocityContext.remove(Constants.FRBR_DATA_ATTRIBUTE_NAME);
		}
	} 
}
 
Example 19
Source File: ManagementBusDeploymentPluginTomcat.java    From container with Apache License 2.0 4 votes vote down vote up
@Override
public Exchange invokeImplementationArtifactDeployment(final Exchange exchange) {

    LOG.debug("Trying to deploy IA on Tomcat.");
    final Message message = exchange.getIn();
    @SuppressWarnings("unchecked") final List<String> artifactReferences =
        message.getHeader(MBHeader.ARTIFACTREFERENCES_LISTSTRING.toString(), List.class);

    // get URL of the WAR-File that has to be deployed
    final URL warURL = getWARFileReference(artifactReferences);
    if (warURL == null) {
        LOG.error("Deployment failed: no referenced WAR-File found");
        message.setHeader(MBHeader.ENDPOINT_URI.toString(), null);
        return exchange;
    }

    // get the WAR artifact as file
    final File warFile = getWarFile(warURL);
    if (warFile == null) {
        LOG.error("Deployment failed: unable to retrieve WAR-File from URL");
        message.setHeader(MBHeader.ENDPOINT_URI.toString(), null);
        return exchange;
    }

    // get file name of the WAR-File
    final String fileName = FilenameUtils.getBaseName(warURL.getPath());
    // retrieve ServiceEndpoint property from exchange headers
    final String endpointSuffix =
        message.getHeader(MBHeader.ARTIFACTSERVICEENDPOINT_STRING.toString(), "", String.class);

    if (endpointSuffix.equals("")) {
        LOG.info("No endpoint suffix defined.");
    } else {
        LOG.info("Endpoint suffix from header: {}", endpointSuffix);
    }

    // if placeholder is defined the deployment is done in the topology
    final String placeholderBegin = "/PLACEHOLDER_";
    final String placeholderEnd = "_PLACEHOLDER/";
    String endpoint = null;
    if (endpointSuffix.toString().contains(placeholderBegin)
        && endpointSuffix.toString().contains(placeholderEnd)) {

        // just return a created endpoint and do not perform deployment
        final String placeholder =
            endpointSuffix.substring(endpointSuffix.indexOf(placeholderBegin),
                endpointSuffix.indexOf(placeholderEnd) + placeholderEnd.length());

        LOG.info("Placeholder defined: {}. Deployment is done as part of the topology and not on the management infrastructure. ",
            placeholder);

        final String endpointBegin = endpointSuffix.substring(0, endpointSuffix.indexOf(placeholderBegin));
        final String endpointEnd =
            endpointSuffix.substring(endpointSuffix.lastIndexOf(placeholderEnd) + placeholderEnd.length());

        // We assume that the WAR-File in the topology is deployed at the default port
        // 8080 and only with the file name as path. Find a better solution which looks
        // into the topology and determines the correct endpoint.
        endpoint = endpointBegin + placeholder + ":8080/" + fileName + "/" + endpointEnd;
    } else {

        // check if Tomcat is running to continue deployment
        if (!isRunning()) {
            LOG.error("Deployment failed: Tomcat is not running or canĀ“t be accessed");
            message.setHeader(MBHeader.ENDPOINT_URI.toString(), null);
            return exchange;
        }
        LOG.info("Tomcat is running and can be accessed.");

        final QName typeImplementation =
            message.getHeader(MBHeader.TYPEIMPLEMENTATIONID_QNAME.toString(), QName.class);

        final String triggeringContainer =
            message.getHeader(MBHeader.TRIGGERINGCONTAINER_STRING.toString(), String.class);

        // perform deployment on management infrastructure
        endpoint = deployWAROnTomcat(warFile, triggeringContainer, typeImplementation, fileName);

        if (endpoint != null) {
            // add endpoint suffix to endpoint of deployed WAR
            endpoint = endpoint.concat(endpointSuffix);
            LOG.info("Complete endpoint of IA {}: {}", fileName, endpoint);
        }
    }

    // delete the temporary file
    // it's not terrible if we don't get to clean this up, it will be deleted once the JVM terminates or we overwrite it
    warFile.delete();

    // set endpoint and pass camel exchange back to caller
    message.setHeader(MBHeader.ENDPOINT_URI.toString(), getURI(endpoint));
    return exchange;
}
 
Example 20
Source File: GoogleSheetsUpdateValuesCustomizer.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
private void beforeProducer(Exchange exchange) throws IOException {
    final Message in = exchange.getIn();

    List<String> jsonBeans = null;
    if (in.getBody() instanceof List) {
        jsonBeans = in.getBody(List.class);
    } else if (in.getBody(String.class) != null) {
        String body = in.getBody(String.class);
        if (JsonUtils.isJsonArray(body)) {
            jsonBeans = JsonUtils.arrayToJsonBeans(JsonUtils.reader().readTree(body));
        } else if (JsonUtils.isJson(body)) {
            jsonBeans = Collections.singletonList(body);
        }
    }

    ValueRange valueRange = new ValueRange();
    List<List<Object>> values = new ArrayList<>();

    if (ObjectHelper.isNotEmpty(jsonBeans)) {
        final ObjectSchema spec = getItemSchema(GoogleSheetsMetaDataHelper.createSchema(range, majorDimension, columnNames));

        for (String json : jsonBeans) {
            Map<String, Object> dataShape = JsonUtils.reader().forType(Map.class).readValue(json);

            if (dataShape.containsKey(SPREADSHEET_ID)) {
                spreadsheetId = Optional.ofNullable(dataShape.remove(SPREADSHEET_ID))
                        .map(Object::toString)
                        .orElse(spreadsheetId);
            }

            List<Object> rangeValues = new ArrayList<>();
            spec.getProperties()
                    .entrySet()
                    .stream()
                    .filter(specEntry -> !Objects.equals(SPREADSHEET_ID, specEntry.getKey()))
                    .forEach(specEntry -> rangeValues.add(Optional.ofNullable(dataShape.get(specEntry.getKey()))
                                                                  .orElse("")));

            values.add(rangeValues);
        }
    }

    valueRange.setMajorDimension(majorDimension);
    valueRange.setValues(values);

    in.setHeader(GoogleSheetsStreamConstants.SPREADSHEET_ID, spreadsheetId);
    in.setHeader(GoogleSheetsStreamConstants.RANGE, range);
    in.setHeader(GoogleSheetsStreamConstants.MAJOR_DIMENSION, majorDimension);
    in.setHeader(GoogleSheetsConstants.PROPERTY_PREFIX + "values", valueRange);
    in.setHeader(GoogleSheetsConstants.PROPERTY_PREFIX + "valueInputOption", valueInputOption);
}