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