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 extended
040     * request that was forwarded to a backend server but did not complete
041     * successfully.
042     */
043    @NotMutable()
044    @ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
045    public final class ExtendedForwardFailedAccessLogMessage
046           extends ExtendedRequestAccessLogMessage
047    {
048      /**
049       * The serial version UID for this serializable class.
050       */
051      private static final long serialVersionUID = 397038373176791392L;
052    
053    
054    
055      // The numeric result code for the failure.
056      private final Integer resultCode;
057    
058      // The port of the backend server to which the request has been forwarded.
059      private final Integer targetPort;
060    
061      // The diagnostic message for the failure.
062      private final String message;
063    
064      // The address of the backend server to which the request has been forwarded.
065      private final String targetHost;
066    
067      // The protocol used to forward the request to the backend server.
068      private final String targetProtocol;
069    
070    
071    
072      /**
073       * Creates a new extended forward failed access log message from the provided
074       * message string.
075       *
076       * @param  s  The string to be parsed as an extended forward failed access log
077       *            message.
078       *
079       * @throws  LogException  If the provided string cannot be parsed as a valid
080       *                        log message.
081       */
082      public ExtendedForwardFailedAccessLogMessage(final String s)
083             throws LogException
084      {
085        this(new LogMessage(s));
086      }
087    
088    
089    
090      /**
091       * Creates a new extended forward failed access log message from the provided
092       * log message.
093       *
094       * @param  m  The log message to be parsed as an extended forward failed
095       *            access log message.
096       */
097      public ExtendedForwardFailedAccessLogMessage(final LogMessage m)
098      {
099        super(m);
100    
101        targetHost     = getNamedValue("targetHost");
102        targetPort     = getNamedValueAsInteger("targetPort");
103        targetProtocol = getNamedValue("targetProtocol");
104        resultCode     = getNamedValueAsInteger("resultCode");
105        message        = getNamedValue("message");
106      }
107    
108    
109    
110      /**
111       * Retrieves the address of the backend server to which the request has been
112       * forwarded.
113       *
114       * @return  The address of the backend server to which the request has been
115       *          forwarded, or {@code null} if it is not included in the log
116       *          message.
117       */
118      public String getTargetHost()
119      {
120        return targetHost;
121      }
122    
123    
124    
125      /**
126       * Retrieves the port of the backend server to which the request has been
127       * forwarded.
128       *
129       * @return  The port of the backend server to which the request has been
130       *          forwarded, or {@code null} if it is not included in the log
131       *          message.
132       */
133      public Integer getTargetPort()
134      {
135        return targetPort;
136      }
137    
138    
139    
140      /**
141       * Retrieves the protocol used to forward the request to the backend server.
142       *
143       * @return  The protocol used to forward the request to the backend server, or
144       *          {@code null} if it is not included in the log message.
145       */
146      public String getTargetProtocol()
147      {
148        return targetProtocol;
149      }
150    
151    
152    
153      /**
154       * Retrieves the result code received for the forwarded operation.
155       *
156       * @return  The result code received for the forwarded operation, or
157       *          {@code null} if it is not included in the log message.
158       */
159      public Integer getResultCode()
160      {
161        return resultCode;
162      }
163    
164    
165    
166      /**
167       * Retrieves the diagnostic message received for the forwarded operation.
168       *
169       * @return  The diagnostic message received for the forwarded operation, or
170       *          {@code null} if it is not included in the log message.
171       */
172      public String getDiagnosticMessage()
173      {
174        return message;
175      }
176    
177    
178    
179      /**
180       * {@inheritDoc}
181       */
182      @Override()
183      public AccessLogMessageType getMessageType()
184      {
185        return AccessLogMessageType.FORWARD_FAILED;
186      }
187    }