001    /*
002     * Copyright 2009-2015 UnboundID Corp.
003     * All Rights Reserved.
004     */
005    /*
006     * Copyright (C) 2015 UnboundID Corp.
007     *
008     * This program is free software; you can redistribute it and/or modify
009     * it under the terms of the GNU General Public License (GPLv2 only)
010     * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
011     * as published by the Free Software Foundation.
012     *
013     * This program is distributed in the hope that it will be useful,
014     * but WITHOUT ANY WARRANTY; without even the implied warranty of
015     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016     * GNU General Public License for more details.
017     *
018     * You should have received a copy of the GNU General Public License
019     * along with this program; if not, see <http://www.gnu.org/licenses>.
020     */
021    package com.unboundid.ldap.sdk.unboundidds.logs;
022    
023    
024    
025    import com.unboundid.util.NotMutable;
026    import com.unboundid.util.ThreadSafety;
027    import com.unboundid.util.ThreadSafetyLevel;
028    
029    
030    
031    /**
032     * <BLOCKQUOTE>
033     *   <B>NOTE:</B>  This class is part of the Commercial Edition of the UnboundID
034     *   LDAP SDK for Java.  It is not available for use in applications that
035     *   include only the Standard Edition of the LDAP SDK, and is not supported for
036     *   use in conjunction with non-UnboundID products.
037     * </BLOCKQUOTE>
038     * This class provides a data structure that holds information about a log
039     * message that may appear in the Directory Server access log about a search
040     * request forwarded to a backend server.
041     */
042    @NotMutable()
043    @ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
044    public final class SearchForwardAccessLogMessage
045           extends SearchRequestAccessLogMessage
046    {
047      /**
048       * The serial version UID for this serializable class.
049       */
050      private static final long serialVersionUID = -6502359332150338323L;
051    
052    
053    
054      // The port of the backend server to which the request has been forwarded.
055      private final Integer targetPort;
056    
057      // The address of the backend server to which the request has been forwarded.
058      private final String targetHost;
059    
060      // The protocol used to forward the request to the backend server.
061      private final String targetProtocol;
062    
063    
064    
065      /**
066       * Creates a new search forward access log message from the provided message
067       * string.
068       *
069       * @param  s  The string to be parsed as a search forward access log message.
070       *
071       * @throws  LogException  If the provided string cannot be parsed as a valid
072       *                        log message.
073       */
074      public SearchForwardAccessLogMessage(final String s)
075             throws LogException
076      {
077        this(new LogMessage(s));
078      }
079    
080    
081    
082      /**
083       * Creates a new search forward access log message from the provided log
084       * message.
085       *
086       * @param  m  The log message to be parsed as a search forward access log
087       *            message.
088       */
089      public SearchForwardAccessLogMessage(final LogMessage m)
090      {
091        super(m);
092    
093        targetHost     = getNamedValue("targetHost");
094        targetPort     = getNamedValueAsInteger("targetPort");
095        targetProtocol = getNamedValue("targetProtocol");
096      }
097    
098    
099    
100      /**
101       * Retrieves the address of the backend server to which the request has been
102       * forwarded.
103       *
104       * @return  The address of the backend server to which the request has been
105       *          forwarded, or {@code null} if it is not included in the log
106       *          message.
107       */
108      public String getTargetHost()
109      {
110        return targetHost;
111      }
112    
113    
114    
115      /**
116       * Retrieves the port of the backend server to which the request has been
117       * forwarded.
118       *
119       * @return  The port of the backend server to which the request has been
120       *          forwarded, or {@code null} if it is not included in the log
121       *          message.
122       */
123      public Integer getTargetPort()
124      {
125        return targetPort;
126      }
127    
128    
129    
130      /**
131       * Retrieves the protocol used to forward the request to the backend server.
132       *
133       * @return  The protocol used to forward the request to the backend server, or
134       *          {@code null} if it is not included in the log message.
135       */
136      public String getTargetProtocol()
137      {
138        return targetProtocol;
139      }
140    
141    
142    
143      /**
144       * {@inheritDoc}
145       */
146      @Override()
147      public AccessLogMessageType getMessageType()
148      {
149        return AccessLogMessageType.FORWARD;
150      }
151    }