<commit_before>/*
 * This code is subject to the HIEOS License, Version 1.0
 *
 * Copyright(c) 2008-2009 Vangent, Inc.  All rights reserved.
 *
 * 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 com.vangent.hieos.services.xca.gateway.serviceimpl;

import com.vangent.hieos.xutil.metadata.structure.Metadata;
import com.vangent.hieos.xutil.metadata.structure.MetadataSupport;
import com.vangent.hieos.xutil.services.framework.XAbstractService;
import com.vangent.hieos.services.xca.gateway.transactions.XCARetrieveDocumentSet;
import com.vangent.hieos.services.xca.gateway.transactions.XCAAdhocQueryRequest;
import com.vangent.hieos.services.xca.gateway.transactions.XCAAbstractTransaction;
import com.vangent.hieos.xutil.exception.XdsValidationException;
import com.vangent.hieos.xutil.response.Response;

import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMNamespace;
import org.apache.log4j.Logger;

// Axis2 LifeCycle support.
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.description.AxisService;

// XATNA
import com.vangent.hieos.xutil.atna.XATNALogger;

/**
 *
 * @author <NAME>
 */
public class XCAGateway extends XAbstractService {
    private final static Logger logger = Logger.getLogger(XCAGateway.class);

    /**
     * 
     * @param ahqr
     * @return
     */
    public OMElement AdhocQueryRequest(OMElement ahqr) {
        try {
            OMElement startup_error = beginTransaction(getQueryTransactionName(), ahqr, XAbstractService.registry_actor);
            if (startup_error != null) {
                return startup_error;
            }
            log_message.setTestMessage(getQueryTransactionName());
            OMElement ahq = MetadataSupport.firstChildWithLocalName(ahqr, "AdhocQuery");
            if (ahq == null) {
                endTransaction(false);
                return this.start_up_error(ahqr, null, XAbstractService.registry_actor, "XCA" + " only accepts Stored Query - AdhocQuery element not found");
            }
            validateWS();
            validateNoMTOM();
            validateQueryTransaction(ahqr);

            // Delegate all the hard work to the XCAAdhocQueryRequest class (follows same NIST patterns).
            XCAAdhocQueryRequest transaction =
                    new XCAAdhocQueryRequest(this.getGatewayType(),
                    log_message, getMessageContext());

            // Now, do some work!
            OMElement result = transaction.run(ahqr);
            endTransaction(transaction.getStatus());
            return result;
        } catch (Exception e) {
            return endTransaction(ahqr, e, XAbstractService.registry_actor, "");
        }
    }

    /**
     *
     * @param rdsr
     * @return
     */
    public OMElement RetrieveDocumentSetRequest(OMElement rdsr) {
        try {
            OMElement startup_error = beginTransaction(getRetTransactionName(), rdsr, XAbstractService.repository_actor);
            if (startup_error != null) {
                return startup_error;
            }
            log_message.setTestMessage(getRetTransactionName());

            // Do some preliminary validation.
            validateWS();
            validateMTOM();
            validateRetrieveTransaction(rdsr);

            // Delegate all the hard work to the XCARetrieveDocumentSet class (follows same NIST patterns).
            XCARetrieveDocumentSet transaction =
                    new XCARetrieveDocumentSet(
                    this.getGatewayType(),
                    log_message, getMessageContext());

            // Now, do the work.
            OMElement result = transaction.run(rdsr);
            endTransaction(transaction.getStatus());
            return result;
        } catch (Exception e) {
            return endTransaction(rdsr, e, XAbstractService.repository_actor, "");
        }
    }

    /**
     *
     * @return
     */
    private XCAAbstractTransaction.GatewayType getGatewayType() {
        XCAAbstractTransaction.GatewayType gatewayType = XCAAbstractTransaction.GatewayType.InitiatingGateway;
        String actorName = (String) this.getMessageContext().getParameter("ActorName").getValue();
        if (actorName.equals("RespondingGateway")) {
            gatewayType = XCAAbstractTransaction.GatewayType.RespondingGateway;
        }
        return gatewayType;
    }

    /**
     * 
     * @return
     */
    protected String getQueryTransactionName() {
        XCAAbstractTransaction.GatewayType gatewayType = this.getGatewayType();
        String transactionName = "SQ (XCA)";
        if (gatewayType == XCAAbstractTransaction.GatewayType.RespondingGateway) {
            transactionName = "XGQ (XCA)";
        }
        return transactionName;
    }
<commit_msg>Added XUA support.<commit_after>/*
 * This code is subject to the HIEOS License, Version 1.0
 *
 * Copyright(c) 2008-2009 Vangent, Inc.  All rights reserved.
 *
 * 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 com.vangent.hieos.services.xca.gateway.serviceimpl;

import com.vangent.hieos.xutil.metadata.structure.MetadataSupport;
import com.vangent.hieos.xutil.services.framework.XAbstractService;
import com.vangent.hieos.services.xca.gateway.transactions.XCARetrieveDocumentSet;
import com.vangent.hieos.services.xca.gateway.transactions.XCAAdhocQueryRequest;
import com.vangent.hieos.services.xca.gateway.transactions.XCAAbstractTransaction;
import com.vangent.hieos.xutil.exception.XdsValidationException;

import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMNamespace;
import org.apache.log4j.Logger;

// Axis2 LifeCycle support.
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.description.AxisService;

// XATNA
import com.vangent.hieos.xutil.atna.XATNALogger;

/**
 *
 * @author <NAME>
 */
public class XCAGateway extends XAbstractService {
    private final static Logger logger = Logger.getLogger(XCAGateway.class);

    /**
     * 
     * @param ahqr
     * @return
     */
    public OMElement AdhocQueryRequest(OMElement ahqr) {
        try {
            OMElement startup_error = beginTransaction(getQueryTransactionName(), ahqr, XAbstractService.ActorType.REGISTRY);
            if (startup_error != null) {
                return startup_error;
            }
            OMElement ahq = MetadataSupport.firstChildWithLocalName(ahqr, "AdhocQuery");
            if (ahq == null) {
                endTransaction(false);
                return this.start_up_error(ahqr, null, XAbstractService.ActorType.REGISTRY, "XCA" + " only accepts Stored Query - AdhocQuery element not found");
            }
            validateWS();
            validateNoMTOM();
            validateQueryTransaction(ahqr);

            // Delegate all the hard work to the XCAAdhocQueryRequest class (follows same NIST patterns).
            XCAAdhocQueryRequest transaction =
                    new XCAAdhocQueryRequest(this.getGatewayType(),
                    log_message, getMessageContext());

            // Now, do some work!
            OMElement result = transaction.run(ahqr);
            endTransaction(transaction.getStatus());
            return result;
        } catch (Exception e) {
            return endTransaction(ahqr, e, XAbstractService.ActorType.REGISTRY, "");
        }
    }

    /**
     *
     * @param rdsr
     * @return
     */
    public OMElement RetrieveDocumentSetRequest(OMElement rdsr) {
        try {
            OMElement startup_error = beginTransaction(getRetTransactionName(), rdsr, XAbstractService.ActorType.REPOSITORY);
            if (startup_error != null) {
                return startup_error;
            }
            // Do some preliminary validation.
            validateWS();
            validateMTOM();
            validateRetrieveTransaction(rdsr);

            // Delegate all the hard work to the XCARetrieveDocumentSet class (follows same NIST patterns).
            XCARetrieveDocumentSet transaction =
                    new XCARetrieveDocumentSet(
                    this.getGatewayType(),
                    log_message, getMessageContext());

            // Now, do the work.
            OMElement result = transaction.run(rdsr);
            endTransaction(transaction.getStatus());
            return result;
        } catch (Exception e) {
            return endTransaction(rdsr, e, XAbstractService.ActorType.REPOSITORY, "");
        }
    }

    /**
     *
     * @return
     */
    private XCAAbstractTransaction.GatewayType getGatewayType() {
        XCAAbstractTransaction.GatewayType gatewayType = XCAAbstractTransaction.GatewayType.InitiatingGateway;
        String actorName = (String) this.getMessageContext().getParameter("ActorName").getValue();
        if (actorName.equals("RespondingGateway")) {
            gatewayType = XCAAbstractTransaction.GatewayType.RespondingGateway;
        }
        return gatewayType;
    }

    /**
     * 
     * @return
     */
    protected String getQueryTransactionName() {
        XCAAbstractTransaction.GatewayType gatewayType = this.getGatewayType();
        String transactionName = "SQ (XCA)";
        if (gatewayType == XCAAbstractTransaction.GatewayType.RespondingGateway) {
            transactionName = "XGQ (XCA)";
        }
        return transactionName;
    }

{'fraction_non_alphanumeric': 0.08990247866720845, 'fraction_numerical': 0.0028443722064201544, 'mean_word_length': 2.607548552583364, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '20074', 'n_tokens_mistral': 2805, 'n_tokens_neox': 2704, 'n_words': 576}