Example #1
0
            /// <param name="request">the object from which this servlet reads the url contents</param>
            /// <param name="response">the object into which this servlet writes the url contents
            ///     </param>
            /// <exception cref="System.IO.IOException">if the request is bad</exception>
            public GetImageParams(HttpServletRequest request, HttpServletResponse response)
            {
                IDictionary <string, string[]> pmap = request.GetParameterMap();

                isGetImage = isGetEdit = fetchLatest = false;
                foreach (KeyValuePair <string, string[]> entry in pmap)
                {
                    string   key = entry.Key;
                    string[] val = entry.Value;
                    if (key.Equals("getimage"))
                    {
                        isGetImage = true;
                        try
                        {
                            txId = ServletUtil.ParseLongParam(request, TxidParam);
                            string imageType = ServletUtil.GetParameter(request, ImageFileType);
                            nnf = imageType == null ? NNStorage.NameNodeFile.Image : NNStorage.NameNodeFile.ValueOf
                                      (imageType);
                        }
                        catch (FormatException nfe)
                        {
                            if (request.GetParameter(TxidParam).Equals(LatestFsimageValue))
                            {
                                fetchLatest = true;
                            }
                            else
                            {
                                throw;
                            }
                        }
                    }
                    else
                    {
                        if (key.Equals("getedit"))
                        {
                            isGetEdit = true;
                            startTxId = ServletUtil.ParseLongParam(request, StartTxidParam);
                            endTxId   = ServletUtil.ParseLongParam(request, EndTxidParam);
                        }
                        else
                        {
                            if (key.Equals(StorageinfoParam))
                            {
                                storageInfoString = val[0];
                            }
                        }
                    }
                }
                int numGets = (isGetImage ? 1 : 0) + (isGetEdit ? 1 : 0);

                if ((numGets > 1) || (numGets == 0))
                {
                    throw new IOException("Illegal parameters to TransferFsImage");
                }
            }
Example #2
0
            /// <exception cref="System.IO.IOException"/>
            public PutImageParams(HttpServletRequest request, HttpServletResponse response, Configuration
                                  conf)
            {
                /*
                 * Params required to handle put image request
                 */
                txId = ServletUtil.ParseLongParam(request, TxidParam);
                storageInfoString = ServletUtil.GetParameter(request, StorageinfoParam);
                fileSize          = ServletUtil.ParseLongParam(request, TransferFsImage.FileLength);
                string imageType = ServletUtil.GetParameter(request, ImageFileType);

                nnf = imageType == null ? NNStorage.NameNodeFile.Image : NNStorage.NameNodeFile.ValueOf
                          (imageType);
                if (fileSize == 0 || txId == -1 || storageInfoString == null || storageInfoString
                    .IsEmpty())
                {
                    throw new IOException("Illegal parameters to TransferFsImage");
                }
            }
Example #3
0
            /// <exception cref="Javax.Servlet.ServletException"/>
            /// <exception cref="System.IO.IOException"/>
            protected override void DoGet(HttpServletRequest request, HttpServletResponse response
                                          )
            {
                // Do the authorization
                if (!HttpServer2.HasAdministratorAccess(GetServletContext(), request, response))
                {
                    return;
                }
                PrintWriter @out    = ServletUtil.InitHTML(response, "Log Level");
                string      logName = ServletUtil.GetParameter(request, "log");
                string      level   = ServletUtil.GetParameter(request, "level");

                if (logName != null)
                {
                    @out.WriteLine("<br /><hr /><h3>Results</h3>");
                    @out.WriteLine(Marker + "Submitted Log Name: <b>" + logName + "</b><br />");
                    Org.Apache.Commons.Logging.Log log = LogFactory.GetLog(logName);
                    @out.WriteLine(Marker + "Log Class: <b>" + log.GetType().FullName + "</b><br />");
                    if (level != null)
                    {
                        @out.WriteLine(Marker + "Submitted Level: <b>" + level + "</b><br />");
                    }
                    if (log is Log4JLogger)
                    {
                        Process(((Log4JLogger)log).GetLogger(), level, @out);
                    }
                    else
                    {
                        if (log is Jdk14Logger)
                        {
                            Process(((Jdk14Logger)log).GetLogger(), level, @out);
                        }
                        else
                        {
                            @out.WriteLine("Sorry, " + log.GetType() + " not supported.<br />");
                        }
                    }
                }
                @out.WriteLine(Forms);
                @out.WriteLine(ServletUtil.HtmlTail);
            }