<commit_before>/**
 * Copyright 2014 Red Hat, Inc.
 * 
 * Red Hat licenses this file to you under the Apache License, version
 * 2.0 (the "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 * implied.  See the License for the specific language governing
 * permissions and limitations under the License.
 * 
 */
package org.fusesource.camel.component.sap;

import java.util.Map;

import org.apache.camel.Endpoint;
import org.apache.camel.impl.UriEndpointComponent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Represents the component that manages {@link SapTransactionalIDocDestinationEndpoint}.
 * 
 * @author <NAME> <<EMAIL>>
 * 
 */
public class SapQueuedIDocDestinationComponent extends UriEndpointComponent {

	private static final Logger LOG = LoggerFactory.getLogger(SapQueuedIDocDestinationComponent.class);

	public SapQueuedIDocDestinationComponent() {
		super(SapQueuedIDocDestinationEndpoint.class);
	}

	@Override
	protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
		if (!uri.startsWith("sap-qidoc-destination:")) { 
			throw new IllegalArgumentException("The URI '" +  uri + "' has invalid scheme; should be 'sap-qidoc-destination:'");			
		}
		// Parse URI
		String[] uriComponents = remaining.split(":");

		if (uriComponents.length < 3) {
			throw new IllegalArgumentException("URI must be of the form: sap-qidoc-destination:<destinationName>:<queueName>:<idocType>[<idocTypeExtension>[<systemRelease>[<applicationRelease>]]]");
		}

		// Extract URI components
		parameters.put("destinationName", uriComponents[0]);
		parameters.put("queueName", uriComponents[1]);
		parameters.put("idocType", uriComponents[2]);
		if(uriComponents.length > 3) {
			parameters.put("idocTypeExtension", uriComponents[3]);
		}
		if(uriComponents.length > 4) {
			parameters.put("systemRelease", uriComponents[4]);
		}
		if(uriComponents.length > 5) {
			parameters.put("applicationRelease", uriComponents[5]);
		}
		Endpoint endpoint = new SapQueuedIDocDestinationEndpoint(uri, this);

		// Configure Endpoint
		setProperties(endpoint, parameters);
		LOG.debug("Created endpoint '" + uri + "'");
		return endpoint;
	}

	@Override
    protected void doStart() throws Exception {
    	super.doStart();<commit_msg>[ENTESB-2582] Fixed unmarshalling issue.<commit_after>/**
 * Copyright 2014 Red Hat, Inc.
 * 
 * Red Hat licenses this file to you under the Apache License, version
 * 2.0 (the "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 * implied.  See the License for the specific language governing
 * permissions and limitations under the License.
 * 
 */
package org.fusesource.camel.component.sap;

import java.util.Map;

import org.apache.camel.Endpoint;
import org.apache.camel.impl.UriEndpointComponent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Represents the component that manages {@link SapTransactionalIDocDestinationEndpoint}.
 * 
 * @author <NAME> <<EMAIL>>
 * 
 */
public class SapQueuedIDocDestinationComponent extends UriEndpointComponent {

	private static final Logger LOG = LoggerFactory.getLogger(SapQueuedIDocDestinationComponent.class);

	public SapQueuedIDocDestinationComponent() {
		super(SapQueuedIDocDestinationEndpoint.class);
	}

	@Override
	protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
		if (!uri.startsWith("sap-qidoc-destination:")) { 
			throw new IllegalArgumentException("The URI '" +  uri + "' has invalid scheme; should be 'sap-qidoc-destination:'");			
		}
		// Parse URI
		String[] uriComponents = remaining.split(":");

		if (uriComponents.length < 3) {
			throw new IllegalArgumentException("URI must be of the form: sap-qidoc-destination:<destinationName>:<queueName>:<idocType>[<idocTypeExtension>[<systemRelease>[<applicationRelease>]]]");
		}

		// Extract URI components
		parameters.put("destinationName", uriComponents[0]);
		parameters.put("queueName", uriComponents[1]);
		parameters.put("idocType", uriComponents[2]);
		if(uriComponents.length > 3) {
			parameters.put("idocTypeExtension", uriComponents[3]);
		}
		if(uriComponents.length > 4) {
			parameters.put("systemRelease", uriComponents[4]);
		}
		if(uriComponents.length > 5) {
			parameters.put("applicationRelease", uriComponents[5]);
		}
		SapQueuedIDocDestinationEndpoint endpoint = new SapQueuedIDocDestinationEndpoint(uri, this);

		// Configure Endpoint
		setProperties(endpoint, parameters);
		LOG.debug("Created endpoint '" + uri + "'");

		// Create a document to ensure that the data layer's package registry is
		// loaded with the schema of this endpoint's IDoc type.
		endpoint.createDocument();
		
		return endpoint;
	}

	@Override
    protected void doStart() throws Exception {
    	super.doStart();
{'fraction_non_alphanumeric': 0.11188173024274503, 'fraction_numerical': 0.008030662529658696, 'mean_word_length': 4.792811839323467, 'pattern_counts': {'":': 2, '<': 25, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3027400', 'n_tokens_mistral': 1653, 'n_tokens_neox': 1541, 'n_words': 444}