<commit_before>package com.cosylab.cdb;

/*******************************************************************************
 *    ALMA - Atacama Large Millimiter Array
 *    (c) European Southern Observatory, 2006
 *    Copyright by ESO (in the framework of the ALMA collaboration)
 *    and Cosylab 2002, All rights reserved
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License as published by the Free Software Foundation; either
 *    version 2.1 of the License, or (at your option) any later version.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
 *
 * @author cparedes
 */
import java.io.StringReader;
import java.net.InetAddress;
import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.omg.CORBA.ORB;
import org.xml.sax.InputSource;

import com.cosylab.CDB.WDAL;
import com.cosylab.CDB.WDALHelper;
import com.cosylab.CDB.WDAO;
import com.cosylab.CDB.XMLerror;
import com.cosylab.cdb.jdal.XMLHandler;
import com.cosylab.cdb.jdal.XMLTreeNode;

import alma.acs.util.ACSPorts;


/**
 * Allow switching the default component of a given IDL type. 
 * This is useful if there is only one component instance per type, but the CDB contains two entries, 
 * one for the real component, and one for a simulator. 
 * The client (test code or real component in the system) is then not affected by this switching, 
 * because it always uses the IDL type to retrieve the component.
 * 
 * Sets Default=true the given component and sets Default=false the other components with the same
 * type.
 * Assumes the curl of the components = "MACI/Components"
 * 
 * @author cparedes
 */
public class CDBDefault {
	static String strIOR;
	static String curl;
	static String curl_allComponents;
	static ORB orb;
	private static Logger m_logger;
	
	public static void main(String args[]) {
		try {
			if (args.length != 2) {
				System.out.println("Usage: cmd idl_type instance_name ");
				return;
			}
			// we can't use ClientLogManager from acsjlog because that module compiles after the cdb module
			m_logger = Logger.getLogger("CDBDefault");
			String in_type = args[0];
			String in_name = args[1];
		
			curl_allComponents = "MACI/Components";
			curl = curl_allComponents + "/" + in_name;

			strIOR = "corbaloc::" + InetAddress.getLocalHost().getHostName() + ":" +
					ACSPorts.getCDBPort() + "/CDB";

			// create and initialize the ORB<commit_msg>Adding the option -d equals to -k<commit_after>package com.cosylab.cdb;

/*******************************************************************************
 *    ALMA - Atacama Large Millimiter Array
 *    (c) European Southern Observatory, 2006
 *    Copyright by ESO (in the framework of the ALMA collaboration)
 *    and Cosylab 2002, All rights reserved
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License as published by the Free Software Foundation; either
 *    version 2.1 of the License, or (at your option) any later version.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
 *
 * @author cparedes
 */
import java.io.StringReader;
import java.net.InetAddress;
import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.omg.CORBA.ORB;
import org.xml.sax.InputSource;

import com.cosylab.CDB.WDAL;
import com.cosylab.CDB.WDALHelper;
import com.cosylab.CDB.WDAO;
import com.cosylab.CDB.XMLerror;
import com.cosylab.cdb.jdal.XMLHandler;
import com.cosylab.cdb.jdal.XMLTreeNode;

import alma.acs.util.ACSPorts;


/**
 * Allow switching the default component of a given IDL type. 
 * This is useful if there is only one component instance per type, but the CDB contains two entries, 
 * one for the real component, and one for a simulator. 
 * The client (test code or real component in the system) is then not affected by this switching, 
 * because it always uses the IDL type to retrieve the component.
 * 
 * Sets Default=true the given component and sets Default=false the other components with the same
 * type.
 * Assumes the curl of the components = "MACI/Components"
 * 
 * @author cparedes
 */
public class CDBDefault {
	static String strIOR;
	static String curl;
	static String curl_allComponents;
	static ORB orb;
	private static Logger m_logger;
	
	public static void main(String args[]) {
		try {
			strIOR=null;
			if (args.length < 2) {
				System.out.println("Usage: cmd <idl_type> <instance_name> [-d|-k ior -h]");
				return;
			}
			
			m_logger = Logger.getLogger("CDBDefault");
			String in_type = args[0];
			String in_name = args[1];
		
			curl_allComponents = "MACI/Components";
			curl = curl_allComponents + "/" + in_name;

			for (int i = 0; i < args.length; i++) {
				if (args[i].equals("-k") || args[i].equals("-d")) {
					if (i < args.length - 1) {
						strIOR = args[++i];
					}
				}
				if (args[i].equals("-h")){
					System.out.println("Usage: cmd idl_type instance_name [-d|-k -h]");
					return;
				}
			}
			if (strIOR == null) {
				strIOR = "corbaloc::" + InetAddress.getLocalHost().getHostName() + ":" + ACSPorts.getCDBPort() + "/CDB";
			}
			// create and initialize the ORB
{'fraction_non_alphanumeric': 0.114951641033772, 'fraction_numerical': 0.008879023307436182, 'mean_word_length': 3.6212454212454213, 'pattern_counts': {'":': 2, '<': 8, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '5106013', 'n_tokens_mistral': 2061, 'n_tokens_neox': 1872, 'n_words': 699}