8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The contents of this file are subject to the terms
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * of the Common Development and Distribution License
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * (the License). You may not use this file except in
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * compliance with the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * You can obtain a copy of the License at
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * https://opensso.dev.java.net/public/CDDLv1.0.html or
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * See the License for the specific language governing
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * permission and limitations under the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * When distributing Covered Code, include this CDDL
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Header Notice in each file and include the License file
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * If applicable, add the following below the CDDL Header,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * with the fields enclosed by brackets [] replaced by
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * your own identifying information:
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * "Portions Copyrighted [year] [name of copyright owner]"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * $Id: LogMessageID.java,v 1.6 2008/08/27 22:08:38 veiming Exp $
73db2ddb960cafd7ffb6daf89eb697910d36c56dJames Phillpotts * Portions Copyrighted 2011-2015 ForgeRock AS.
73db2ddb960cafd7ffb6daf89eb697910d36c56dJames Phillpottsimport static com.sun.identity.log.messageid.LogMessageConstants.XML_DATAINFO_TAG_NAME;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Log Message ID is a unique identifier for each log message.
73db2ddb960cafd7ffb6daf89eb697910d36c56dJames Phillpotts private final List<String> dataInfoColumns;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static Map mapLogLevel = new HashMap();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Constructs a log message ID instance.
73db2ddb960cafd7ffb6daf89eb697910d36c56dJames Phillpotts * @param logLevel Log level.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param prefix Prefix of this log.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param id Unique Identification number.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param name Unique name.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param description Description of this log.
73db2ddb960cafd7ffb6daf89eb697910d36c56dJames Phillpotts * @param dataInfoColumns Information on the data logged.
73db2ddb960cafd7ffb6daf89eb697910d36c56dJames Phillpotts this.dataInfoSize = dataInfoColumns.size();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns log level.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return log level.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns prefix.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return prefix.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns name.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return name.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns id.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return name.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns description.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return description.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns number of entries in the data column.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return number of entries in the data column.
73db2ddb960cafd7ffb6daf89eb697910d36c56dJames Phillpotts * Get the names of the data columns for the log message.
73db2ddb960cafd7ffb6daf89eb697910d36c56dJames Phillpotts * @return The column names.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster static LogMessageID createInstance(String prefix, Node node) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if ((node != null) && (node.getNodeType() == Node.ELEMENT_NODE)) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (nodeName.equals(LogMessageConstants.XML_LOG_MESSAGE_TAG_NAME)){
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster LogMessageConstants.XML_ATTRNAME_LOG_MESSAGE_NAME);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster LogMessageConstants.XML_ATTRNAME_LOG_MESSAGE_ID);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String logLevel = ((Element)node).getAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String description = ((Element)node).getAttribute(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster LogMessageConstants.XML_ATTRNAME_LOG_MESSAGE_DESCRIPTION);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if ((name.length() > 0) && (id.length() > 0)) {
73db2ddb960cafd7ffb6daf89eb697910d36c56dJames Phillpotts Node datainfo = getNodeOfName(node, XML_DATAINFO_TAG_NAME);
73db2ddb960cafd7ffb6daf89eb697910d36c56dJames Phillpotts List<String> dataColumns = new ArrayList<>();
73db2ddb960cafd7ffb6daf89eb697910d36c56dJames Phillpotts NodeList dataInfoItems = ((Element)datainfo).getElementsByTagName("item");
73db2ddb960cafd7ffb6daf89eb697910d36c56dJames Phillpotts for (int i = 0; i < dataInfoItems.getLength(); i++) {
73db2ddb960cafd7ffb6daf89eb697910d36c56dJames Phillpotts dataColumns.add(dataInfoItems.item(i).getTextContent().trim());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster "unable to create log message ID because its name is missing");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static int getArrayCount(Node node, String tagName) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static Node getNodeOfName(Node node, String tagName) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster for (int i = 0; (i < sz) && (target == null); i++) {