当前位置: 首页>>代码示例>>Java>>正文


Java ParamUtils类代码示例

本文整理汇总了Java中org.jivesoftware.util.ParamUtils的典型用法代码示例。如果您正苦于以下问题:Java ParamUtils类的具体用法?Java ParamUtils怎么用?Java ParamUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ParamUtils类属于org.jivesoftware.util包,在下文中一共展示了ParamUtils类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doGet

import org.jivesoftware.util.ParamUtils; //导入依赖的package包/类
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    String canonicalName = ParamUtils.getParameter(request, "plugin");
    PluginManager pluginManager = XMPPServer.getInstance().getPluginManager();
    PluginMetadata metadata = pluginManager.getMetadata( canonicalName );
    if (metadata != null) {
        final URL icon = metadata.getIcon();
        if ( icon != null ) {
            // Clear any empty lines added by the JSP declaration. This is required to show
            // the image in resin!
            response.reset();
            if ( icon.toExternalForm().toLowerCase().endsWith( ".png" )) {
                response.setContentType("image/png");
            }
            else if (icon.toExternalForm().toLowerCase().endsWith( ".png" )) {
                response.setContentType("image/gif");
            }
            try (InputStream in = icon.openStream()) {
                try (OutputStream ost = response.getOutputStream()) {
                    byte[] buf = new byte[1024];
                    int len;
                    while ((len = in.read(buf)) >= 0) {
                        ost.write(buf, 0, len);
                    }
                    ost.flush();
                }
            } catch (IOException ioe) {
                throw new ServletException(ioe);
            }
        }
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:33,代码来源:PluginIconServlet.java

示例2: doGet

import org.jivesoftware.util.ParamUtils; //导入依赖的package包/类
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    long conversationID = ParamUtils.getLongParameter(request, "conversationID", -1);
    if (conversationID == -1) {
        return;
    }

    MonitoringPlugin plugin = (MonitoringPlugin)XMPPServer.getInstance().getPluginManager().getPlugin(
            MonitoringConstants.NAME);
    ConversationManager conversationManager = (ConversationManager)plugin.getModule(ConversationManager.class);
    Conversation conversation;
    if (conversationID > -1) {
        try {
            conversation = new Conversation(conversationManager, conversationID);

            ByteArrayOutputStream stream = new ConversationUtils().getConversationPDF(conversation);

            // setting some response headers
            response.setHeader("Expires", "0");
            response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
            response.setHeader("Pragma", "public");
            // setting the content type
            response.setContentType("application/pdf");
            // the content length is needed for MSIE!!!
            response.setContentLength(stream.size());
            // write ByteArrayOutputStream to the ServletOutputStream
            ServletOutputStream out = response.getOutputStream();
            stream.writeTo(out);
            out.flush();
        }
        catch (NotFoundException nfe) {
            Log.error(nfe.getMessage(), nfe);
        }
    }

}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:37,代码来源:ConversationPDFServlet.java

示例3: doGet

import org.jivesoftware.util.ParamUtils; //导入依赖的package包/类
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       long conversationID = ParamUtils.getLongParameter(request, "conversationID", -1);
       if (conversationID == -1) {
           return;
       }

       MonitoringPlugin plugin = (MonitoringPlugin)XMPPServer.getInstance().getPluginManager().getPlugin(
           "monitoring");
       ConversationManager conversationManager = (ConversationManager)plugin.getModule(ConversationManager.class);
       Conversation conversation;
       if (conversationID > -1) {
           try {
               conversation = new Conversation(conversationManager, conversationID);

               ByteArrayOutputStream stream = new ConversationUtils().getConversationPDF(conversation);

               // setting some response headers
               response.setHeader("Expires", "0");
               response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
               response.setHeader("Pragma", "public");
               // setting the content type
               response.setContentType("application/pdf");
               // the content length is needed for MSIE!!!
               response.setContentLength(stream.size());
               // write ByteArrayOutputStream to the ServletOutputStream
               ServletOutputStream out = response.getOutputStream();
               stream.writeTo(out);
               out.flush();
           }
           catch (NotFoundException nfe) {
               Log.error(nfe.getMessage(), nfe);
           }
       }

   }
 
开发者ID:coodeer,项目名称:g3server,代码行数:37,代码来源:ConversationPDFServlet.java

示例4: doGet

import org.jivesoftware.util.ParamUtils; //导入依赖的package包/类
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       long conversationID = ParamUtils.getLongParameter(request, "conversationID", -1);
       if (conversationID == -1) {
           return;
       }

       MonitoringPlugin plugin = (MonitoringPlugin)XMPPServer.getInstance().getPluginManager().getPlugin(
       		MonitoringConstants.NAME);
       ConversationManager conversationManager = (ConversationManager)plugin.getModule(ConversationManager.class);
       Conversation conversation;
       if (conversationID > -1) {
           try {
               conversation = new Conversation(conversationManager, conversationID);

               ByteArrayOutputStream stream = new ConversationUtils().getConversationPDF(conversation);

               // setting some response headers
               response.setHeader("Expires", "0");
               response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
               response.setHeader("Pragma", "public");
               // setting the content type
               response.setContentType("application/pdf");
               // the content length is needed for MSIE!!!
               response.setContentLength(stream.size());
               // write ByteArrayOutputStream to the ServletOutputStream
               ServletOutputStream out = response.getOutputStream();
               stream.writeTo(out);
               out.flush();
           }
           catch (NotFoundException nfe) {
               Log.error(nfe.getMessage(), nfe);
           }
       }

   }
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:37,代码来源:ConversationPDFServlet.java

示例5: validateAdditions

import org.jivesoftware.util.ParamUtils; //导入依赖的package包/类
public void validateAdditions(DataForm form, HttpServletRequest request, Map<String, listType> listTypes,
        Map<String, String> errors) {

    for (FormField field : form.getFields()) {
        if (listTypes.containsKey(field.getVariable())) {
            switch (listTypes.get(field.getVariable())) {
            case group:
                if (ParamUtils.getParameter(request, field.getVariable() + "-Add") != null) {
                    String groupName = ParamUtils.getParameter(request, field.getVariable() + "-Additional");
                    if (isValidGroup(groupName)) {

                        if (!field.getValues().contains(groupName)) {
                            field.addValue(groupName);
                        } else {
                            // Group already in list
                            errors.put(field.getVariable(), LocaleUtils.getLocalizedString(
                                    "pubsub.form.already_in_list",
                                    Arrays.asList(LocaleUtils.getLocalizedString("pubsub.form.group"), groupName)));
                        }
                    } else {
                        // Not a valid group
                        errors.put(field.getVariable(), LocaleUtils.getLocalizedString("pubsub.form.not_valid",
                                Arrays.asList(groupName, LocaleUtils.getLocalizedString("pubsub.form.group"))));
                    }
                }

                break;
            case user:
                if (ParamUtils.getParameter(request, field.getVariable() + "-Add") != null) {
                    String username = ParamUtils.getParameter(request, field.getVariable() + "-Additional");
                    JID newUser = getValidJID(username);
                    if (newUser != null) {

                        if (!field.getValues().contains(newUser.toBareJID())) {
                            field.addValue(newUser.toBareJID());
                        } else {
                            // User already in list
                            errors.put(field.getVariable(), LocaleUtils.getLocalizedString(
                                    "pubsub.form.already_in_list",
                                    Arrays.asList(LocaleUtils.getLocalizedString("pubsub.form.user"), username)));
                        }
                    } else {
                        // Not a valid username
                        errors.put(field.getVariable(), LocaleUtils.getLocalizedString("pubsub.form.not_valid",
                                Arrays.asList(username, LocaleUtils.getLocalizedString("pubsub.form.user"))));
                    }
                }
                break;
            default:
                break;
            }
        }
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:55,代码来源:PubSubServiceInfo.java

示例6: service

import org.jivesoftware.util.ParamUtils; //导入依赖的package包/类
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // retrieve parameters
    String statisticKey = request.getParameter("stat");
    String timePeriod = request.getParameter("timeperiod");
    String graphcolor = request.getParameter("color");
    boolean sparkLines = request.getParameter("sparkline") != null;
    boolean pdfFormat = request.getParameter("pdf") != null;
    long[] dateRange = GraphEngine.parseTimePeriod(timePeriod);
    int width;
    int height;

    if (pdfFormat) {
        // PDF A4 page = 595 wide - (50px * 2 margins) = 495
        width = ParamUtils.getIntParameter(request, "width", 495);
        height = ParamUtils.getIntParameter(request, "height", 252);
        JFreeChart[] charts;
        Statistic[] stats;
        if (request.getParameter("pdf").equalsIgnoreCase("all")) {
            String[] statKeys = statsViewer.getAllHighLevelStatKeys();
            List<String> statList = Arrays.asList(statKeys);
            Collections.sort(statList, new Comparator<String>() {
                public int compare(String stat1, String stat2) {
                    String statName1 = statsViewer.getStatistic(stat1)[0].getName();
                    String statName2 = statsViewer.getStatistic(stat2)[0].getName();
                    return statName1.toLowerCase().compareTo(statName2.toLowerCase());
                }
            });
            charts = new JFreeChart[statList.size()];
            stats = new Statistic[statList.size()];
            int index = 0;
            for (String statName : statList) {
                stats[index] = statsViewer.getStatistic(statName)[0];
                charts[index] = graphEngine.generateChart(statName, width, height, graphcolor, dateRange[0], dateRange[1], (int)dateRange[2]);
                index++;
            }
        } else {
            charts = new JFreeChart[] {graphEngine.generateChart(statisticKey, width, height, graphcolor, dateRange[0], dateRange[1], (int)dateRange[2])};
            stats = new Statistic[] {statsViewer.getStatistic(statisticKey)[0]};
        }
        writePDFContent(request, response, charts, stats, dateRange[0], dateRange[1], width, height);
    } else {
        byte[] chart;
        if (sparkLines) {
            width = ParamUtils.getIntParameter(request, "width", 200);
            height = ParamUtils.getIntParameter(request, "height", 50);
            chart = graphEngine.generateSparklinesGraph(statisticKey, width, height, graphcolor, dateRange[0], dateRange[1], (int)dateRange[2]);
        }
        else {
            width = ParamUtils.getIntParameter(request, "width", 590);
            height = ParamUtils.getIntParameter(request, "height", 300);
            chart = graphEngine.generateGraph(statisticKey, width, height, graphcolor, dateRange[0], dateRange[1], (int)dateRange[2]);
        }

        writeImageContent(response, chart, "image/png");
    }


}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:60,代码来源:GraphServlet.java

示例7: service

import org.jivesoftware.util.ParamUtils; //导入依赖的package包/类
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       // retrieve parameters
       String statisticKey = request.getParameter("stat");
       String timePeriod = request.getParameter("timeperiod");
       String graphcolor = request.getParameter("color");
       boolean sparkLines = request.getParameter("sparkline") != null;
       boolean pdfFormat = request.getParameter("pdf") != null;
       long[] dateRange = GraphEngine.parseTimePeriod(timePeriod);
       int width;
       int height;

       if (pdfFormat) {
           // PDF A4 page = 595 wide - (50px * 2 margins) = 495
           width = ParamUtils.getIntParameter(request, "width", 495);
           height = ParamUtils.getIntParameter(request, "height", 252);
           JFreeChart[] charts;
           Statistic[] stats;
           if (request.getParameter("pdf").equalsIgnoreCase("all")) {
               String[] statKeys = statsViewer.getAllHighLevelStatKeys();
               List<String> statList = Arrays.asList(statKeys);
               Collections.sort(statList, new Comparator<String>() {
                   public int compare(String stat1, String stat2) {
                       String statName1 = statsViewer.getStatistic(stat1)[0].getName();
                       String statName2 = statsViewer.getStatistic(stat2)[0].getName();
                       return statName1.toLowerCase().compareTo(statName2.toLowerCase());
                   }
               });
               charts = new JFreeChart[statList.size()];
               stats = new Statistic[statList.size()];
               int index = 0;
               for (String statName : statList) {
                   stats[index] = statsViewer.getStatistic(statName)[0];
                   charts[index] = graphEngine.generateChart(statName, width, height, graphcolor, dateRange[0], dateRange[1], (int)dateRange[2]);
                   index++;
               }
           } else {
               charts = new JFreeChart[] {graphEngine.generateChart(statisticKey, width, height, graphcolor, dateRange[0], dateRange[1], (int)dateRange[2])};
               stats = new Statistic[] {statsViewer.getStatistic(statisticKey)[0]};
           }
           writePDFContent(request, response, charts, stats, dateRange[0], dateRange[1], width, height);
       } else {
           byte[] chart;
           if (sparkLines) {
               width = ParamUtils.getIntParameter(request, "width", 200);
               height = ParamUtils.getIntParameter(request, "height", 50);
               chart = graphEngine.generateSparklinesGraph(statisticKey, width, height, graphcolor, dateRange[0], dateRange[1], (int)dateRange[2]);
           }
           else {
               width = ParamUtils.getIntParameter(request, "width", 590);
               height = ParamUtils.getIntParameter(request, "height", 300);
               chart = graphEngine.generateGraph(statisticKey, width, height, graphcolor, dateRange[0], dateRange[1], (int)dateRange[2]);
           }

           writeImageContent(response, chart, "image/png");
       }


   }
 
开发者ID:coodeer,项目名称:g3server,代码行数:60,代码来源:GraphServlet.java


注:本文中的org.jivesoftware.util.ParamUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。