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 an add
040     * request forwarded to a backend server.
041     */
042    @NotMutable()
043    @ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
044    public final class AddForwardAccessLogMessage
045           extends AddRequestAccessLogMessage
046    {
047      /**
048       * The serial version UID for this serializable class.
049       */
050      private static final long serialVersionUID = 5311495513879603972L;
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 add forward access log message from the provided message
067       * string.
068       *
069       * @param  s  The string to be parsed as an add forward access log message.
070       *
071       * @throws  LogException  If the provided string cannot be parsed as a valid
072       *                        log message.
073       */
074      public AddForwardAccessLogMessage(final String s)
075             throws LogException
076      {
077        this(new LogMessage(s));
078      }
079    
080    
081    
082      /**
083       * Creates a new add forward access log message from the provided log message.
084       *
085       * @param  m  The log message to be parsed as an add forward access log
086       *            message.
087       */
088      public AddForwardAccessLogMessage(final LogMessage m)
089      {
090        super(m);
091    
092        targetHost     = getNamedValue("targetHost");
093        targetPort     = getNamedValueAsInteger("targetPort");
094        targetProtocol = getNamedValue("targetProtocol");
095      }
096    
097    
098    
099      /**
100       * Retrieves the address of the backend server to which the request has been
101       * forwarded.
102       *
103       * @return  The address of the backend server to which the request has been
104       *          forwarded, or {@code null} if it is not included in the log
105       *          message.
106       */
107      public String getTargetHost()
108      {
109        return targetHost;
110      }
111    
112    
113    
114      /**
115       * Retrieves the port of the backend server to which the request has been
116       * forwarded.
117       *
118       * @return  The port of the backend server to which the request has been
119       *          forwarded, or {@code null} if it is not included in the log
120       *          message.
121       */
122      public Integer getTargetPort()
123      {
124        return targetPort;
125      }
126    
127    
128    
129      /**
130       * Retrieves the protocol used to forward the request to the backend server.
131       *
132       * @return  The protocol used to forward the request to the backend server, or
133       *          {@code null} if it is not included in the log message.
134       */
135      public String getTargetProtocol()
136      {
137        return targetProtocol;
138      }
139    
140    
141    
142      /**
143       * {@inheritDoc}
144       */
145      @Override()
146      public AccessLogMessageType getMessageType()
147      {
148        return AccessLogMessageType.FORWARD;
149      }
150    }