<commit_before>/*
 * Copyright 2011 The Kuali Foundation.
 * 
 * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
 * 
 * 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.kuali.kfs.module.external.kc.service;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;

import javax.xml.namespace.QName;
import javax.xml.ws.Service;

import org.apache.log4j.Logger;
import org.kuali.kfs.sys.KFSConstants;
import org.kuali.kfs.sys.context.SpringContext;
import org.kuali.rice.core.api.config.property.ConfigurationService;

public abstract class KfsService extends Service {
    protected static final Logger LOG = Logger.getLogger(KfsService.class);
    
    protected KfsService(URL wsdlDocumentLocation, QName serviceName) {
        super(wsdlDocumentLocation, serviceName);
    }
 
    public static String getWebServiceServerName() {
       return  SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(KFSConstants.KC_APPLICATION_URL_KEY);
    }
    
    protected static URL getWsdl(QName qname) throws MalformedURLException {
        URL url = null;
        String webServiceServer =  getWebServiceServerName();

        //FIXME KC needs to get the services exposed and working on the KSB for this to work
        //RICE20 needs service exposed
        if (webServiceServer == null) {
            // look for service on the KSB registry
            ServiceRegistry serviceRegistry = SpringContext.getBean(ServiceRegistry.class);
            List<ServiceInfo> wsdlServices = serviceRegistry.fetchActiveByName(qname);
            if (wsdlServices.size() > 0 ) {
                ServiceInfo serviceInfo = wsdlServices.get(0);
                String wsdlName = serviceInfo.getActualEndpointUrl() + "?wsdl";
                url = new URL(wsdlName);
            }
        } else {
            url  = new URL(webServiceServer + "/remoting/" +  qname.getLocalPart() + "?wsdl");
        }  <commit_msg>KFSMI-7177 Rice 2.0 conversions<commit_after>/*
 * Copyright 2011 The Kuali Foundation.
 * 
 * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
 * 
 * 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.kuali.kfs.module.external.kc.service;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;

import javax.xml.namespace.QName;
import javax.xml.ws.Service;

import org.apache.log4j.Logger;
import org.kuali.kfs.sys.KFSConstants;
import org.kuali.kfs.sys.context.SpringContext;
import org.kuali.rice.core.api.config.property.ConfigurationService;
import org.kuali.rice.ksb.api.registry.ServiceInfo;
import org.kuali.rice.ksb.api.registry.ServiceRegistry;

public abstract class KfsService extends Service {
    protected static final Logger LOG = Logger.getLogger(KfsService.class);
    
    protected KfsService(URL wsdlDocumentLocation, QName serviceName) {
        super(wsdlDocumentLocation, serviceName);
    }
 
    public static String getWebServiceServerName() {
       return  SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(KFSConstants.KC_APPLICATION_URL_KEY);
    }
    
    protected static URL getWsdl(QName qname) throws MalformedURLException {
        URL url = null;
        String webServiceServer =  getWebServiceServerName();

        if (webServiceServer == null) {
            // look for service on the KSB registry
            ServiceRegistry serviceRegistry = SpringContext.getBean(ServiceRegistry.class);
            List<ServiceInfo> wsdlServices = serviceRegistry.getOnlineServicesByName(qname);
            if (wsdlServices.size() > 0 ) {
                ServiceInfo serviceInfo = wsdlServices.get(0);
                String wsdlName = serviceInfo.getEndpointUrl() + "?wsdl";
                url = new URL(wsdlName);
            }
        } else {
            url  = new URL(webServiceServer + "/remoting/" +  qname.getLocalPart() + "?wsdl");
        }  
{'fraction_non_alphanumeric': 0.0847808105872622, 'fraction_numerical': 0.005789909015715467, 'mean_word_length': 3.322609472743521, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 4}, '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': '3140123', 'n_tokens_mistral': 1372, 'n_tokens_neox': 1310, 'n_words': 386}