Commit 01bbee1daf9b99cb95552c58076689083f960985

Authored by 刘基城
1 parent 273cb05b

11

src/main/java/com/cnlive/mz/live/action/LiveAction.java
... ... @@ -138,419 +138,6 @@ public class LiveAction {
138 138 return new View("live/all_live_management.jsp").data("tLive", tLive);
139 139 }
140 140  
141   - /**
142   - * 1.0 获取直播活动信息接口Server.md
143   - *
144   - * @param params
145   - * @return
146   - */
147   - @Request.Get("/live/epg/getLiveActivityPlayInfo4Server")
148   - public ResultBean getLiveActivityPlayInfo4Server(Params params) {
149   - ResultBean rb = new ResultBean();
150   - String appId = params.getString("appId");
151   - String activityId = params.getString("activityId");
152   - String timestamp = params.getString("timestamp");
153   - if (StringUtils.isEmpty(appId) || StringUtils.isEmpty(activityId)) {
154   - Map<String, Object> map = new HashMap<String, Object>();
155   - map.put("location", "");
156   - rb.setData(map);
157   - rb.setErrorCode("200");
158   - log.error("参数不正确");
159   - rb.setErrorMessage("启动活动失败");
160   - return rb;
161   - } else {
162   - TLive tLive = tLiveService.selectByParams(appId, activityId);
163   - Map<String, Object> map = new HashMap<String, Object>();
164   - map.put("activityId", activityId);
165   - map.put("location", tLive.getLive_url());
166   - rb.setData(map);
167   - rb.setErrorCode("0");
168   - rb.setErrorMessage("启动活动成功");
169   - return rb;
170   - }
171   - }
172   -
173   - /**
174   - * 1.3 创建直播活动接口.md
175   - *
176   - * @param params
177   - * @return
178   - */
179   - @Request.Post("/live/epg/createActivity")
180   - public ResultBean createActivity(Params params) {
181   - log.info("打印参数开始......");
182   - log.info(params);
183   - log.info("打印参数结束......");
184   - ResultBean rb = new ResultBean();
185   - String appId = params.getString("appId");
186   - String activityId = params.getString("activityId");
187   - int isHorizontalScreen = params.getInt("isHorizontalScreen");
188   - String channelID = params.getString("channelId");
189   - Map<String, Object> map = new HashMap<String, Object>();
190   - if (StringUtils.isNotEmpty(appId) && StringUtils.isNotEmpty(activityId) && StringUtils.isNotEmpty(channelID)
191   - && StringUtils.isNotEmpty("" + isHorizontalScreen)) {
192   - TLive tLive = tLiveService.selectByParams(appId, activityId);
193   - if (tLive != null) {
194   - map.put("location", "");
195   - rb.setData(map);
196   - rb.setErrorCode("500");
197   - rb.setErrorMessage("创建活动失败,活动ID已存在");
198   - log.error("创建活动失败,活动ID已存在");
199   - return rb;
200   - } else {
201   - boolean flag = tLiveService.addAcitvity(params);
202   - TLive tlive = tLiveService.selectByParams(appId, activityId);
203   - if (flag) {
204   - map.put("location", com.cnlive.mz.live.common.Constants.KS_HOST_UP_RTMP + channelID + "?vdoid=" + activityId);
205   - rb.setData(map);
206   - rb.setErrorCode("0");
207   - rb.setErrorMessage("创建活动成功");
208   - log.info("创建活动成功");
209   - // 通知cms直播
210   - boolean success = tLiveService.startLive(tlive);
211   - return rb;
212   - } else {
213   - map.put("location", "");
214   - rb.setData(map);
215   - rb.setErrorCode("500");
216   - rb.setErrorMessage("创建活动失败,保存数据库失败");
217   - log.error("保存数据库失败");
218   - return rb;
219   - }
220   - }
221   - } else {
222   - map.put("location", "");
223   - rb.setData(map);
224   - rb.setErrorCode("500");
225   - rb.setErrorMessage("创建活动失败,参数不正确");
226   - log.error("参数不正确");
227   - return rb;
228   - }
229   - }
230   -
231   - /**
232   - * 1.4 启动直播活动接口.md
233   - *
234   - * @param params
235   - * @return
236   - */
237   - @Request.Get("/live/epg/startActivity")
238   - public ResultBean startActivity(Params params) {
239   - ResultBean rb = new ResultBean();
240   - log.info(params);
241   - String appId = params.getString("appId");
242   - String activityid = params.getString("activityId");
243   - if (StringUtils.isEmpty(appId) || StringUtils.isEmpty(activityid)) {
244   - rb.setErrorCode("500");
245   - rb.setErrorMessage("启动活动失败,参数不正确");
246   - return rb;
247   - } else {
248   - TLive tLive = tLiveService.selectByParams(appId, activityid);
249   - if (tLive == null) {
250   - log.info("tLive为空......");
251   - rb.setErrorCode("500");
252   - rb.setErrorMessage("启动活动失败,活动对象为空");
253   - return rb;
254   - } else {
255   - rb.setErrorCode("0");
256   - rb.setErrorMessage("启动活动成功");
257   - return rb;
258   - }
259   - }
260   - }
261   -
262   - /**
263   - * 1.5 停止直播活动接口.md
264   - *
265   - * @param params
266   - * @return
267   - */
268   - @Request.Get("/live/epg/stopActivity")
269   - public ResultBean stopActivity(Params params) {
270   - log.info(params);
271   - ResultBean rb = new ResultBean();
272   - String appId = params.getString("appId");
273   - String activityid = params.getString("activityId");
274   - TLive tLive = tLiveService.selectByParams(appId, activityid);
275   - Map<String, Object> map = new HashMap<String, Object>();
276   - if (StringUtils.isEmpty(appId) || StringUtils.isEmpty(activityid)) {
277   - map.put("location", "");
278   - rb.setData(map);
279   - rb.setErrorCode("500");
280   - rb.setErrorMessage("停止直播失败,参数不正确");
281   - return rb;
282   - } else {
283   - if (tLive == null) {
284   - map.put("location", "");
285   - rb.setData(map);
286   - rb.setErrorCode("500");
287   - rb.setErrorMessage("停止直播失败,活动对象为空");
288   - return rb;
289   - } else {
290   - String live_url = tLive.getLive_url();
291   - int index = live_url.lastIndexOf("/");
292   - String streamName = live_url.substring(index + 1);
293   - System.out.println("streamName===" + streamName);
294   - // 直播断流。
295   - tCheckService.close(streamName, tLive.getId(), tLive.getUuid());
296   - }
297   - // 直播通知
298   - // tLiveService.notify(video_uuid, -1);
299   - map.put("location", tLive.getLive_url());
300   - rb.setData(map);
301   - rb.setErrorCode("0");
302   - rb.setErrorMessage("停止直播成功");
303   - return rb;
304   - }
305   - }
306   -
307   - /**
308   - * 1.6 获取直播活动列表接口.md
309   - *
310   - * @param params
311   - * @return
312   - */
313   - @Request.Get("/live/epg/getActivity")
314   - public ResultBean getActivities(Params params) {
315   - ResultBean rb = new ResultBean();
316   - String appId = params.getString("appId");
317   - String pageNo = params.getString("pageNo");
318   - String pageSize = params.getString("pageSize");
319   - if (StringUtils.isEmpty(appId) || StringUtils.isEmpty(pageNo) || StringUtils.isEmpty(pageSize)) {
320   - Map<String, Object> map = new HashMap<String, Object>();
321   - map.put("location", "");
322   - rb.setData(map);
323   - rb.setErrorCode("500");
324   - rb.setErrorMessage("获取活动列表失败,参数不正确");
325   - return rb;
326   - } else {
327   - Pager<TLive> tLive = tLiveService.getActivityPager(pageNo, pageSize, appId);
328   - if (tLive == null) {
329   - rb.setData("");
330   - rb.setErrorCode("500");
331   - rb.setErrorMessage("获取活动列表失败,活动对象为空");
332   - return rb;
333   - } else {
334   - rb.setData(tLive);
335   - rb.setErrorCode("0");
336   - rb.setErrorMessage("获取活动列表成功");
337   - return rb;
338   - }
339   - }
340   - }
341   -
342   - /**
343   - * 1.7 获取直播回放接口.md
344   - *
345   - * @param args
346   - */
347   - @Request.Get("/live/epg/getActivityVodInfo")
348   - public ResultBean getActivityVodInfo(Params params) {
349   - ResultBean rb = new ResultBean();
350   - String appId = params.getString("appId");
351   - String activityid = params.getString("activityId");
352   - Map<String, Object> map = new HashMap<String, Object>();
353   - if (StringUtils.isEmpty(appId) || StringUtils.isEmpty(activityid)) {
354   - map.put("location", "");
355   - rb.setData(map);
356   - rb.setErrorCode("500");
357   - rb.setErrorMessage("获取直播回放失败,参数不正确");
358   - return rb;
359   - } else {
360   - TLive tLive = tLiveService.selectByParams(appId, activityid);
361   - if (tLive == null) {
362   - map.put("location", "");
363   - rb.setData(map);
364   - rb.setErrorCode("500");
365   - rb.setErrorMessage("获取直播回放失败,活动对象为空");
366   - return rb;
367   - } else {
368   - map.put("location", tLive.getPlayback_url());
369   - rb.setData(map);
370   - rb.setErrorCode("0");
371   - rb.setErrorMessage("获取直播回放成功");
372   - return rb;
373   - }
374   - }
375   - }
376   -
377   - /**
378   - * 1.7 获取直播回放接口.md
379   - *
380   - * @param args
381   - */
382   - @Request.Get("/live/epg/liveplayByAPP")
383   - public ResultBean liveplayByAPP(Params params) {
384   - log.info(params);
385   - ResultBean rb = new ResultBean();
386   - String appId = params.getString("appId");
387   - String activityid = params.getString("activityId");
388   - Map<String, Object> map = new HashMap<String, Object>();
389   - if (StringUtils.isEmpty(appId) || StringUtils.isEmpty(activityid)) {
390   - map.put("location", "");
391   - rb.setData(map);
392   - rb.setErrorCode("500");
393   - rb.setErrorMessage("获取直播回放失败,参数不正确");
394   - return rb;
395   - } else {
396   - TLive tLive = tLiveService.selectByParams(appId, activityid);
397   - if (tLive == null) {
398   - map.put("location", "");
399   - rb.setData(map);
400   - rb.setErrorCode("500");
401   - rb.setErrorMessage("获取直播回放失败,活动对象为空");
402   - return rb;
403   - } else {
404   - map.put("location", tLive.getPlayback_url());
405   - rb.setData(map);
406   - rb.setErrorCode("0");
407   - rb.setErrorMessage("获取直播回放成功");
408   - return rb;
409   - }
410   - }
411   - }
412   -
413   - /**
414   - * 1.8 获取APP直播URL接口.md
415   - *
416   - * @param params
417   - * @return 302 跳转播放地址
418   - */
419   - @Request.Get("/live/epg/play/app")
420   - public Redirect appURL(Params params) throws IOException {
421   - log.info(params);
422   - Redirect r = new Redirect();
423   - String appId = params.getString("appId");
424   - String activityid = params.getString("activityId");
425   - TLive tLive = tLiveService.selectByParams(appId, activityid);
426   - TChannel tchannel = tLiveService.selectChannel(tLive.getRelation_id());
427   - if (tchannel != null) {
428   - // pgc直播
429   - r.setRedirectUrl("http://ips.cnlive.com/IPS/liveplayByAPP.action?appId=" + appId + "&channelID=" + tLive.getRelation_id());
430   - } else {
431   - // ugc直播
432   - r.setRedirectUrl(tLive.getLive_url());
433   - }
434   - return r;
435   - }
436   -
437   - /**
438   - * 1.9 获取H5直播URL接口.md
439   - *
440   - * @param params
441   - * @return
442   - */
443   - @Request.Get("/live/epg/play/h5")
444   - public ResultBean h5URL(Params params) {
445   - HttpServletResponse response = DataContext.getResponse();
446   - ResultBean rb = new ResultBean();
447   - String appId = params.getString("appId");
448   - String activityid = params.getString("activityId");
449   - Map<String, Object> map = new HashMap<String, Object>();
450   - if (StringUtils.isEmpty(appId) || StringUtils.isEmpty(activityid)) {
451   - map.put("location", "");
452   - rb.setData(map);
453   - rb.setErrorCode("500");
454   - rb.setErrorMessage("启动h5活动失败");
455   - return rb;
456   - } else {
457   - TLive tLive = tLiveService.selectByParams(appId, activityid);
458   - if (tLive == null) {
459   - map.put("location", "");
460   - rb.setData(map);
461   - rb.setErrorCode("500");
462   - rb.setErrorMessage("启动h5活动失败,活动对象为空");
463   - return rb;
464   - } else {
465   - TChannel tchannel = tLiveService.selectChannel(tLive.getRelation_id());
466   - if (tchannel != null) {
467   - // 重定向到h5.......
468   - redirect(response, "http://ips.cnlive.com/IPS/liveplayByH5?appId=" + appId + "&channelID=" + tLive.getRelation_id());
469   - map.put("location", "");
470   - rb.setData(map);
471   - rb.setErrorCode("0");
472   - rb.setErrorMessage("302重定向到h5");
473   - return rb;
474   - } else {
475   - map.put("location", tLive.getLive_url());
476   - rb.setData(map);
477   - rb.setErrorCode("0");
478   - rb.setErrorMessage("启动h5活动成功");
479   - return rb;
480   - }
481   - }
482   - }
483   -
484   - }
485   -
486   - /**
487   - * 2.0 获取SWF直播URL接口.md
488   - *
489   - * @param params
490   - * @return
491   - */
492   - @Request.Get("/live/epg/play/swf")
493   - public ResultBean swfURL(Params params) {
494   - HttpServletResponse response = DataContext.getResponse();
495   - ResultBean rb = new ResultBean();
496   - String appId = params.getString("appId");
497   - String activityid = params.getString("activityId");
498   - Map<String, Object> map = new HashMap<String, Object>();
499   - if (StringUtils.isEmpty(appId) || StringUtils.isEmpty(activityid)) {
500   - map.put("location", "");
501   - rb.setData(map);
502   - rb.setErrorCode("500");
503   - rb.setErrorMessage("启动swf活动失败");
504   - return rb;
505   - } else {
506   - TLive tLive = tLiveService.selectByParams(appId, activityid);
507   - if (tLive == null) {
508   - map.put("location", "");
509   - rb.setData(map);
510   - rb.setErrorCode("500");
511   - rb.setErrorMessage("启动swf活动失败,活动对象为空");
512   - return rb;
513   - } else {
514   - TChannel tchannel = tLiveService.selectChannel(tLive.getRelation_id());
515   - rb.setData(map);
516   - rb.setErrorCode("0");
517   - if (tchannel != null) {
518   - // 302重定向到swf.......
519   - redirect(response, "http://ips.cnlive.com/IPS/liveplayBySWF.action?appId=" + appId + "&channelID=" + tLive.getRelation_id());
520   - map.put("location", "");
521   - rb.setErrorMessage("302重定向到swf");
522   - return rb;
523   - } else {
524   - map.put("location", tLive.getLive_url());
525   - rb.setErrorMessage("启动swf活动成功");
526   - return rb;
527   - }
528   - }
529   - }
530   - }
531   -
532   - @Request.Post("/live/epg/error500")
533   - public ResultBean error(Params params) {
534   - ResultBean rb = new ResultBean();
535   - Map<String, Object> map = new HashMap<String, Object>();
536   - map.put("location", "");
537   - rb.setData(map);
538   - rb.setErrorCode("500");
539   - rb.setErrorMessage("失败");
540   - return rb;
541   - }
542   -
543   - public static void redirect(HttpServletResponse response, String redirectUrl) {
544   - try {
545   - response.setContentType("application/mpegurl");
546   - response.setStatus(302);
547   - response.setHeader("Location", redirectUrl);
548   - response.setHeader("Connection", "close");
549   - } catch (Exception e) {
550   - throw new RuntimeException(e);
551   - }
552   - }
553   -
554 141 public static void main(String[] args) {
555 142  
556 143 /*
... ...
src/main/java/com/cnlive/mz/live/action/UgcLiveAction.java 0 → 100644
  1 +/**
  2 + * Project Name:cnlive_live_web
  3 + * File Name:RoomAction.java
  4 + * Package Name:com.cnlive.mz.live.action
  5 + * Date:2016年4月25日下午1:12:48
  6 + * Copyright (c) 2016, cnlive.com All Rights Reserved.
  7 + *
  8 + */
  9 +
  10 +package com.cnlive.mz.live.action;
  11 +
  12 +import java.io.IOException;
  13 +import java.util.HashMap;
  14 +import java.util.Map;
  15 +
  16 +import javax.servlet.http.HttpServletResponse;
  17 +
  18 +import org.apache.commons.lang.StringUtils;
  19 +import org.apache.log4j.Logger;
  20 +import org.smart4j.framework.dao.bean.Pager;
  21 +import org.smart4j.framework.ioc.annotation.Inject;
  22 +import org.smart4j.framework.mvc.DataContext;
  23 +import org.smart4j.framework.mvc.annotation.Action;
  24 +import org.smart4j.framework.mvc.annotation.Request;
  25 +import org.smart4j.framework.mvc.bean.Params;
  26 +import org.smart4j.framework.mvc.bean.Redirect;
  27 +import org.smart4j.framework.mvc.bean.ResultBean;
  28 +
  29 +import com.cnlive.mz.commons.net.HttpReq;
  30 +import com.cnlive.mz.live.entity.TChannel;
  31 +import com.cnlive.mz.live.entity.TLive;
  32 +import com.cnlive.mz.live.service.TCheckService;
  33 +import com.cnlive.mz.live.service.TRoomService;
  34 +import com.cnlive.mz.live.service.UgcLiveService;
  35 +
  36 +@Action
  37 +public class UgcLiveAction {
  38 +
  39 + private Logger log = Logger.getLogger("UgcLiveAction");
  40 + @Inject
  41 + private UgcLiveService ugcLiveService;
  42 +
  43 +
  44 + /**
  45 + * 1.0 获取直播活动信息接口Server.md
  46 + *
  47 + * @param params
  48 + * @return
  49 + */
  50 + @Request.Get("/live/epg/getLiveActivityPlayInfo4Server")
  51 + public ResultBean getLiveActivityPlayInfo4Server(Params params) {
  52 + ResultBean rb = new ResultBean();
  53 + String appId = params.getString("appId");
  54 + String activityId = params.getString("activityId");
  55 + String timestamp = params.getString("timestamp");
  56 + if (StringUtils.isEmpty(appId) || StringUtils.isEmpty(activityId)) {
  57 + Map<String, Object> map = new HashMap<String, Object>();
  58 + map.put("location", "");
  59 + rb.setData(map);
  60 + rb.setErrorCode("200");
  61 + log.error("参数不正确");
  62 + rb.setErrorMessage("启动活动失败");
  63 + return rb;
  64 + } else {
  65 + TLive tLive = ugcLiveService.getTLiveByActivityId(appId, activityId);
  66 + Map<String, Object> map = new HashMap<String, Object>();
  67 + map.put("activityId", activityId);
  68 + map.put("location", tLive.getLive_url());
  69 + rb.setData(map);
  70 + rb.setErrorCode("0");
  71 + rb.setErrorMessage("启动活动成功");
  72 + return rb;
  73 + }
  74 + }
  75 +
  76 + /**
  77 + * 1.3 创建直播活动接口.md
  78 + *
  79 + * @param params
  80 + * @return
  81 + */
  82 + @Request.Post("/live/epg/createActivity")
  83 + public ResultBean create(Params params) {
  84 + log.info(params);
  85 + ResultBean rb = new ResultBean();
  86 + String appId = params.getString("appId");
  87 + String activityId = params.getString("activityId");
  88 + int isHorizontalScreen = params.getInt("isHorizontalScreen");
  89 + String channelID = params.getString("channelId");
  90 + Map<String, Object> map = new HashMap<String, Object>();
  91 + if (StringUtils.isNotEmpty(appId) && StringUtils.isNotEmpty(activityId) && StringUtils.isNotEmpty(channelID)
  92 + && StringUtils.isNotEmpty("" + isHorizontalScreen)) {
  93 + TLive tLive = ugcLiveService.getTLiveByActivityId(appId, activityId);
  94 + if (tLive != null) {
  95 + map.put("location", "");
  96 + rb.setData(map);
  97 + rb.setErrorCode("500");
  98 + rb.setErrorMessage("创建活动失败,活动ID已存在");
  99 + log.error("创建活动失败,活动ID已存在");
  100 + return rb;
  101 + } else {
  102 + boolean flag = ugcLiveService.create(params);
  103 + if (flag) {
  104 + map.put("location", com.cnlive.mz.live.common.Constants.KS_HOST_UP_RTMP + channelID + "?vdoid=" + activityId);
  105 + rb.setData(map);
  106 + rb.setErrorCode("0");
  107 + rb.setErrorMessage("创建活动成功");
  108 + log.info("创建活动成功");
  109 + return rb;
  110 + } else {
  111 + map.put("location", "");
  112 + rb.setData(map);
  113 + rb.setErrorCode("500");
  114 + rb.setErrorMessage("创建活动失败,保存数据库失败");
  115 + log.error("保存数据库失败");
  116 + return rb;
  117 + }
  118 + }
  119 + } else {
  120 + map.put("location", "");
  121 + rb.setData(map);
  122 + rb.setErrorCode("500");
  123 + rb.setErrorMessage("创建活动失败,参数不正确");
  124 + log.error("参数不正确");
  125 + return rb;
  126 + }
  127 + }
  128 +
  129 + /**
  130 + * 1.4 启动直播活动接口.md
  131 + *
  132 + * @param params
  133 + * @return
  134 + */
  135 + @Request.Get("/live/epg/startActivity")
  136 + public ResultBean start(Params params) {
  137 + ResultBean rb = new ResultBean();
  138 + log.info(params);
  139 + String appId = params.getString("appId");
  140 + String activityid = params.getString("activityId");
  141 + if (StringUtils.isEmpty(appId) || StringUtils.isEmpty(activityid)) {
  142 + rb.setErrorCode("500");
  143 + rb.setErrorMessage("启动活动失败,参数不正确");
  144 + return rb;
  145 + } else {
  146 + TLive tLive = ugcLiveService.getTLiveByActivityId(appId, activityid);
  147 + if (tLive == null) {
  148 + log.info("tLive为空......");
  149 + rb.setErrorCode("500");
  150 + rb.setErrorMessage("启动活动失败,活动对象为空");
  151 + return rb;
  152 + } else {
  153 + rb.setErrorCode("0");
  154 + rb.setErrorMessage("启动活动成功");
  155 + return rb;
  156 + }
  157 + }
  158 + }
  159 +
  160 + /**
  161 + * 1.5 停止直播活动接口.md
  162 + *
  163 + * @param params
  164 + * @return
  165 + */
  166 + @Request.Get("/live/epg/stopActivity")
  167 + public ResultBean stop(Params params) {
  168 + log.info(params);
  169 + ResultBean rb = new ResultBean();
  170 + String appId = params.getString("appId");
  171 + String activityid = params.getString("activityId");
  172 + TLive tLive = ugcLiveService.getTLiveByActivityId(appId, activityid);
  173 + Map<String, Object> map = new HashMap<String, Object>();
  174 + if (StringUtils.isEmpty(appId) || StringUtils.isEmpty(activityid)) {
  175 + map.put("location", "");
  176 + rb.setData(map);
  177 + rb.setErrorCode("500");
  178 + rb.setErrorMessage("停止直播失败,参数不正确");
  179 + return rb;
  180 + } else {
  181 + if (tLive == null) {
  182 + map.put("location", "");
  183 + rb.setData(map);
  184 + rb.setErrorCode("500");
  185 + rb.setErrorMessage("停止直播失败,活动对象为空");
  186 + return rb;
  187 + } else {
  188 + String live_url = tLive.getLive_url();
  189 + int index = live_url.lastIndexOf("/");
  190 + String streamName = live_url.substring(index + 1);
  191 + System.out.println("streamName===" + streamName);
  192 + // 直播断流。
  193 + ugcLiveService.stop(appId,activityid);
  194 + }
  195 + map.put("location", tLive.getLive_url());
  196 + rb.setData(map);
  197 + rb.setErrorCode("0");
  198 + rb.setErrorMessage("停止直播成功");
  199 + return rb;
  200 + }
  201 + }
  202 +
  203 + /**
  204 + * 1.6 获取直播活动列表接口.md
  205 + *
  206 + * @param params
  207 + * @return
  208 + */
  209 + @Request.Get("/live/epg/getActivity")
  210 + public ResultBean getActivities(Params params) {
  211 + ResultBean rb = new ResultBean();
  212 + String appId = params.getString("appId");
  213 + String pageNo = params.getString("pageNo");
  214 + String pageSize = params.getString("pageSize");
  215 + if (StringUtils.isEmpty(appId) || StringUtils.isEmpty(pageNo) || StringUtils.isEmpty(pageSize)) {
  216 + Map<String, Object> map = new HashMap<String, Object>();
  217 + map.put("location", "");
  218 + rb.setData(map);
  219 + rb.setErrorCode("500");
  220 + rb.setErrorMessage("获取活动列表失败,参数不正确");
  221 + return rb;
  222 + } else {
  223 + Pager<TLive> tLive = ugcLiveService.getActivityPager(pageNo, pageSize, appId);
  224 + if (tLive == null) {
  225 + rb.setData("");
  226 + rb.setErrorCode("500");
  227 + rb.setErrorMessage("获取活动列表失败,活动对象为空");
  228 + return rb;
  229 + } else {
  230 + rb.setData(tLive);
  231 + rb.setErrorCode("0");
  232 + rb.setErrorMessage("获取活动列表成功");
  233 + return rb;
  234 + }
  235 + }
  236 + }
  237 +
  238 + /**
  239 + * 1.7 获取直播回放接口.md
  240 + *
  241 + * @param args
  242 + */
  243 + @Request.Get("/live/epg/getActivityVodInfo")
  244 + public ResultBean getActivityVodInfo(Params params) {
  245 + ResultBean rb = new ResultBean();
  246 + String appId = params.getString("appId");
  247 + String activityid = params.getString("activityId");
  248 + Map<String, Object> map = new HashMap<String, Object>();
  249 + if (StringUtils.isEmpty(appId) || StringUtils.isEmpty(activityid)) {
  250 + map.put("location", "");
  251 + rb.setData(map);
  252 + rb.setErrorCode("500");
  253 + rb.setErrorMessage("获取直播回放失败,参数不正确");
  254 + return rb;
  255 + } else {
  256 + TLive tLive = ugcLiveService.getTLiveByActivityId(appId, activityid);
  257 + if (tLive == null) {
  258 + map.put("location", "");
  259 + rb.setData(map);
  260 + rb.setErrorCode("500");
  261 + rb.setErrorMessage("获取直播回放失败,活动对象为空");
  262 + return rb;
  263 + } else {
  264 + map.put("location", tLive.getPlayback_url());
  265 + rb.setData(map);
  266 + rb.setErrorCode("0");
  267 + rb.setErrorMessage("获取直播回放成功");
  268 + return rb;
  269 + }
  270 + }
  271 + }
  272 +
  273 + /**
  274 + * 1.7 获取直播回放接口.md
  275 + *
  276 + * @param args
  277 + */
  278 + @Request.Get("/live/epg/liveplayByAPP")
  279 + public ResultBean liveplayByAPP(Params params) {
  280 + log.info(params);
  281 + ResultBean rb = new ResultBean();
  282 + String appId = params.getString("appId");
  283 + String activityid = params.getString("activityId");
  284 + Map<String, Object> map = new HashMap<String, Object>();
  285 + if (StringUtils.isEmpty(appId) || StringUtils.isEmpty(activityid)) {
  286 + map.put("location", "");
  287 + rb.setData(map);
  288 + rb.setErrorCode("500");
  289 + rb.setErrorMessage("获取直播回放失败,参数不正确");
  290 + return rb;
  291 + } else {
  292 + TLive tLive = ugcLiveService.getTLiveByActivityId(appId, activityid);
  293 + if (tLive == null) {
  294 + map.put("location", "");
  295 + rb.setData(map);
  296 + rb.setErrorCode("500");
  297 + rb.setErrorMessage("获取直播回放失败,活动对象为空");
  298 + return rb;
  299 + } else {
  300 + map.put("location", tLive.getPlayback_url());
  301 + rb.setData(map);
  302 + rb.setErrorCode("0");
  303 + rb.setErrorMessage("获取直播回放成功");
  304 + return rb;
  305 + }
  306 + }
  307 + }
  308 +
  309 + /**
  310 + * 1.8 获取APP直播URL接口.md
  311 + *
  312 + * @param params
  313 + * @return 302 跳转播放地址
  314 + */
  315 + @Request.Get("/live/epg/play/app")
  316 + public Redirect appURL(Params params) throws IOException {
  317 + log.info(params);
  318 + Redirect r = new Redirect();
  319 + String c = "http://wideo03.cnlive.com/video/data1/2016/0821/143844/800/8352b125fc404807851daa21d7e8f417_143844_800.m3u8";
  320 + String appId = params.getString("appId");
  321 + String activityid = params.getString("activityId");
  322 + String isHLS = params.getString("isHLS");
  323 + if (StringUtils.isEmpty(activityid)) {
  324 + // sdk 请求
  325 + if (appId.isEmpty()) {
  326 + appId = params.getString("sp_id");
  327 + }
  328 + String channelID = params.getString("channelID");
  329 + TLive tLive = ugcLiveService.selectByRelationId(channelID);
  330 + TChannel tchannel = ugcLiveService.selectChannel(tLive.getRelation_id());
  331 + if (tchannel != null) {
  332 + // pgc直播
  333 + r.setRedirectUrl("http://ips.cnlive.com/IPS/liveplayByAPP.action?appId=" + appId + "&channelID=" + tLive.getRelation_id());
  334 + } else {
  335 + // ugc直播
  336 + if (StringUtils.isNotEmpty(isHLS) && isHLS.equals("1")) {
  337 + r.setRedirectUrl(tLive.getHls_live_url());
  338 + } else {
  339 + r.setRedirectUrl(tLive.getLive_url());
  340 + }
  341 + // r.setRedirectUrl(c);
  342 + }
  343 + } else {
  344 + TLive tLive = ugcLiveService.getTLiveByActivityId(appId, activityid);
  345 + TChannel tchannel = ugcLiveService.selectChannel(tLive.getRelation_id());
  346 + if (tchannel != null) {
  347 + // pgc直播
  348 + r.setRedirectUrl("http://ips.cnlive.com/IPS/liveplayByAPP.action?appId=" + appId + "&channelID=" + tLive.getRelation_id());
  349 + } else {
  350 + // ugc直播
  351 + if (StringUtils.isNotEmpty(isHLS) && isHLS.equals("1")) {
  352 + r.setRedirectUrl(tLive.getHls_live_url());
  353 + } else {
  354 + r.setRedirectUrl(tLive.getLive_url());
  355 + }
  356 + // r.setRedirectUrl(c);
  357 + }
  358 + }
  359 + return r;
  360 + }
  361 +
  362 + /**
  363 + * 1.9 获取H5直播URL接口.md
  364 + *
  365 + * @param params
  366 + * @return
  367 + */
  368 + @Request.Get("/live/epg/play/h5")
  369 + public ResultBean h5URL(Params params) {
  370 + HttpServletResponse response = DataContext.getResponse();
  371 + ResultBean rb = new ResultBean();
  372 + String appId = params.getString("appId");
  373 + String activityid = params.getString("activityId");
  374 + Map<String, Object> map = new HashMap<String, Object>();
  375 + if (StringUtils.isEmpty(appId) || StringUtils.isEmpty(activityid)) {
  376 + map.put("location", "");
  377 + rb.setData(map);
  378 + rb.setErrorCode("500");
  379 + rb.setErrorMessage("启动h5活动失败");
  380 + return rb;
  381 + } else {
  382 + TLive tLive = ugcLiveService.getTLiveByActivityId(appId, activityid);
  383 + if (tLive == null) {
  384 + map.put("location", "");
  385 + rb.setData(map);
  386 + rb.setErrorCode("500");
  387 + rb.setErrorMessage("启动h5活动失败,活动对象为空");
  388 + return rb;
  389 + } else {
  390 + TChannel tchannel = ugcLiveService.selectChannel(tLive.getRelation_id());
  391 + if (tchannel != null) {
  392 + // 重定向到h5.......
  393 + redirect(response, "http://ips.cnlive.com/IPS/liveplayByH5?appId=" + appId + "&channelID=" + tLive.getRelation_id());
  394 + map.put("location", "");
  395 + rb.setData(map);
  396 + rb.setErrorCode("0");
  397 + rb.setErrorMessage("302重定向到h5");
  398 + return rb;
  399 + } else {
  400 + map.put("location", tLive.getLive_url());
  401 + rb.setData(map);
  402 + rb.setErrorCode("0");
  403 + rb.setErrorMessage("启动h5活动成功");
  404 + return rb;
  405 + }
  406 + }
  407 + }
  408 +
  409 + }
  410 +
  411 + /**
  412 + * 2.0 获取SWF直播URL接口.md
  413 + *
  414 + * @param params
  415 + * @return
  416 + */
  417 + @Request.Get("/live/epg/play/swf")
  418 + public ResultBean swfURL(Params params) {
  419 + HttpServletResponse response = DataContext.getResponse();
  420 + ResultBean rb = new ResultBean();
  421 + String appId = params.getString("appId");
  422 + String activityid = params.getString("activityId");
  423 + Map<String, Object> map = new HashMap<String, Object>();
  424 + if (StringUtils.isEmpty(appId) || StringUtils.isEmpty(activityid)) {
  425 + map.put("location", "");
  426 + rb.setData(map);
  427 + rb.setErrorCode("500");
  428 + rb.setErrorMessage("启动swf活动失败");
  429 + return rb;
  430 + } else {
  431 + TLive tLive = ugcLiveService.getTLiveByActivityId(appId, activityid);
  432 + if (tLive == null) {
  433 + map.put("location", "");
  434 + rb.setData(map);
  435 + rb.setErrorCode("500");
  436 + rb.setErrorMessage("启动swf活动失败,活动对象为空");
  437 + return rb;
  438 + } else {
  439 + TChannel tchannel = ugcLiveService.selectChannel(tLive.getRelation_id());
  440 + rb.setData(map);
  441 + rb.setErrorCode("0");
  442 + if (tchannel != null) {
  443 + // 302重定向到swf.......
  444 + redirect(response, "http://ips.cnlive.com/IPS/liveplayBySWF.action?appId=" + appId + "&channelID=" + tLive.getRelation_id());
  445 + map.put("location", "");
  446 + rb.setErrorMessage("302重定向到swf");
  447 + return rb;
  448 + } else {
  449 + map.put("location", tLive.getLive_url());
  450 + rb.setErrorMessage("启动swf活动成功");
  451 + return rb;
  452 + }
  453 + }
  454 + }
  455 + }
  456 +
  457 + @Request.Post("/live/epg/error500")
  458 + public ResultBean error(Params params) {
  459 + ResultBean rb = new ResultBean();
  460 + Map<String, Object> map = new HashMap<String, Object>();
  461 + map.put("location", "");
  462 + rb.setData(map);
  463 + rb.setErrorCode("500");
  464 + rb.setErrorMessage("失败");
  465 + return rb;
  466 + }
  467 +
  468 + public static void redirect(HttpServletResponse response, String redirectUrl) {
  469 + try {
  470 + response.setContentType("application/mpegurl");
  471 + response.setStatus(302);
  472 + response.setHeader("Location", redirectUrl);
  473 + response.setHeader("Connection", "close");
  474 + } catch (Exception e) {
  475 + throw new RuntimeException(e);
  476 + }
  477 + }
  478 +
  479 + public static void main(String[] args) {
  480 +
  481 + /*
  482 + * NameValuePair[] nvp = new NameValuePair[6]; NameValuePair nv1 = new
  483 + * NameValuePair(); nv1.setName("appId"); nv1.setValue("123"); nvp[0] =
  484 + * nv1; NameValuePair nv2 = new NameValuePair();
  485 + * nv2.setName("activityId"); nv2.setValue("234e"); nvp[1] = nv2;
  486 + * NameValuePair nv3 = new NameValuePair(); nv3.setName("activityName");
  487 + * nv3.setValue("ee"); nvp[2] = nv3; NameValuePair nv4 = new
  488 + * NameValuePair(); nv4.setName("activityStatus"); nv4.setValue("11");
  489 + * nvp[3] = nv4; NameValuePair nv5 = new NameValuePair();
  490 + * nv5.setName("isHorizontalScreen"); nv5.setValue("321"); nvp[4] = nv5;
  491 + * NameValuePair nv6 = new NameValuePair(); nv6.setName("channelId");
  492 + * nv6.setValue("ww"); nvp[5] = nv6; String ss =
  493 + * HttpReq.postRequestWidthResult(
  494 + * "http://bc.cnlive.com/live/epg/createActivity", nvp);
  495 + * System.out.println(ss); <<<<<<< HEAD String aa = HttpReq
  496 + * .getRequestWidthResult(
  497 + * "http://bc.cnlive.com/live/epg/startActivity?appId=123&activityId=234"
  498 + * ); System.out.println(aa);
  499 + */
  500 + String aa = HttpReq.getRequestWidthResult("http://bc.cnlive.com/live/epg/startActivity?appId=123&activityId=234");
  501 + System.out.println(aa);
  502 + }
  503 +}
0 504 \ No newline at end of file
... ...
src/main/java/com/cnlive/socket/Client.java 0 → 100644
  1 +package com.cnlive.socket;
  2 +
  3 +import java.io.BufferedReader;
  4 +import java.io.IOException;
  5 +import java.io.InputStreamReader;
  6 +import java.io.PrintWriter;
  7 +import java.net.Socket;
  8 +import java.net.UnknownHostException;
  9 +
  10 +public class Client {
  11 + Socket client;
  12 + PrintWriter pw;
  13 + public Client() throws UnknownHostException, IOException {
  14 + client=new Socket("bc.cnlive.com",65432);
  15 + pw=new PrintWriter(client.getOutputStream());
  16 + BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
  17 + pw.write(br.readLine());
  18 + pw.close();
  19 + br.close();
  20 + }
  21 + public static void main(String[] args) {
  22 + try {
  23 + new Client();
  24 + } catch (UnknownHostException e) {
  25 + e.printStackTrace();
  26 + } catch (IOException e) {
  27 + e.printStackTrace();
  28 + }
  29 + }
  30 +}
0 31 \ No newline at end of file
... ...
src/main/java/com/cnlive/socket/SocketServer.java
1 1 package com.cnlive.socket;
2 2  
3   -import java.io.BufferedReader;
4 3 import java.io.IOException;
5 4 import java.io.InputStream;
6   -import java.io.InputStreamReader;
7   -import java.io.ObjectInputStream;
8   -import java.io.ObjectOutputStream;
9 5 import java.io.OutputStream;
10 6 import java.net.ServerSocket;
11 7 import java.net.Socket;
... ... @@ -13,141 +9,143 @@ import java.util.concurrent.ConcurrentHashMap;
13 9  
14 10 public class SocketServer {
15 11  
16   - /**
17   - * 要处理客户端发来的对象,并返回一个对象,可实现该接口。
18   - */
19   - public interface ObjectAction{
20   - Object doAction(Object rev);
21   - }
22   -
23   - /*public static final class DefaultObjectAction implements ObjectAction{
24   - public Object doAction(Object rev) {
25   - System.out.println("处理并返回:"+rev);
26   - return rev;
27   - }
28   - } */
29   -
30   - public static void main(String[] args) {
31   - int port = 65432;
32   - SocketServer server = new SocketServer(port);
33   - server.start();
34   - }
35   -
36   - private int port;
37   - private volatile boolean running=false;
38   - private long receiveTimeDelay=7000;
39   - private ConcurrentHashMap<Class, ObjectAction> actionMapping = new ConcurrentHashMap<Class,ObjectAction>();
40   - private Thread connWatchDog;
41   -
42   - public SocketServer(int port) {
43   - this.port = port;
44   - }
45   -
46   - public void start(){
47   - if(running)return;
48   - running=true;
49   - connWatchDog = new Thread(new ConnWatchDog());
50   - connWatchDog.start();
51   - }
52   -
53   - @SuppressWarnings("deprecation")
54   - public void stop(){
55   - if(running)running=false;
56   - if(connWatchDog!=null)connWatchDog.stop();
57   - }
58   -
59   - public void addActionMap(Class<Object> cls,ObjectAction action){
60   - actionMapping.put(cls, action);
61   - }
62   -
63   - class ConnWatchDog implements Runnable{
64   - public void run(){
65   - try {
66   - ServerSocket ss = new ServerSocket(port,5);
67   - while(running){
68   - System.out.println("等待客服端。。。");
69   - Socket s = ss.accept();
70   - new Thread(new SocketAction(s)).start();
71   - }
72   - } catch (IOException e) {
73   - e.printStackTrace();
74   - SocketServer.this.stop();
75   - }
76   -
77   - }
78   - }
79   -
80   - class SocketAction implements Runnable{
81   - Socket s;
82   - boolean run=true;
83   - long lastReceiveTime = System.currentTimeMillis();
84   - public SocketAction(Socket s) {
85   - this.s = s;
86   - }
87   - public void run() {
88   - while(running && run){
89   - try {
  12 + /**
  13 + * 要处理客户端发来的对象,并返回一个对象,可实现该接口。
  14 + */
  15 + public interface ObjectAction {
  16 + Object doAction(Object rev);
  17 + }
  18 +
  19 + /*
  20 + * public static final class DefaultObjectAction implements ObjectAction{
  21 + * public Object doAction(Object rev) { System.out.println("处理并返回:"+rev);
  22 + * return rev; } }
  23 + */
  24 +
  25 + public static void main(String[] args) {
  26 + int port = 65432;
  27 + SocketServer server = new SocketServer(port);
  28 + server.start();
  29 + }
  30 +
  31 + private int port;
  32 + private volatile boolean running = false;
  33 + private long receiveTimeDelay = 7000;
  34 + private ConcurrentHashMap<Class, ObjectAction> actionMapping = new ConcurrentHashMap<Class, ObjectAction>();
  35 + private Thread connWatchDog;
  36 +
  37 + public SocketServer(int port) {
  38 + this.port = port;
  39 + }
  40 +
  41 + public void start() {
  42 + if (running)
  43 + return;
  44 + running = true;
  45 + connWatchDog = new Thread(new ConnWatchDog());
  46 + connWatchDog.start();
  47 + }
  48 +
  49 + @SuppressWarnings("deprecation")
  50 + public void stop() {
  51 + if (running)
  52 + running = false;
  53 + if (connWatchDog != null)
  54 + connWatchDog.stop();
  55 + }
  56 +
  57 + public void addActionMap(Class<Object> cls, ObjectAction action) {
  58 + actionMapping.put(cls, action);
  59 + }
  60 +
  61 + class ConnWatchDog implements Runnable {
  62 + public void run() {
  63 + try {
  64 + ServerSocket ss = new ServerSocket(port, 5);
  65 + while (running) {
  66 + System.out.println("等待客户端。。。");
  67 + Socket s = ss.accept();
  68 + new Thread(new SocketAction(s)).start();
  69 + }
  70 + } catch (IOException e) {
  71 + e.printStackTrace();
  72 + SocketServer.this.stop();
  73 + }
  74 +
  75 + }
  76 + }
  77 +
  78 + class SocketAction implements Runnable {
  79 + Socket s;
  80 + boolean run = true;
  81 + long lastReceiveTime = System.currentTimeMillis();
  82 +
  83 + public SocketAction(Socket s) {
  84 + this.s = s;
  85 + }
  86 +
  87 + public void run() {
  88 + while (running && run) {
  89 + try {
90 90 Thread.sleep(3000);
91 91 } catch (InterruptedException e1) {
92   - // TODO Auto-generated catch block
93 92 e1.printStackTrace();
94 93 }
95   - try {
96   - InputStream in = s.getInputStream();
97   - OutputStream out = s.getOutputStream();
98   - byte[] recData = null;
99   - while(true) {
100   - recData = new byte[1024];
101   - int r = in.read(recData);
102   - if(r>-1) {
103   - String data = new String(recData);
104   - /* if(data.trim().equals("over")) {
105   - s.close();
106   - break;
107   - }*/
108   - System.out.println("读取到客户端发送的来数据:"+data);
109   - }
110   - }
111   - /* if(in.available()>0){
112   - BufferedReader br = new BufferedReader(new InputStreamReader(in));
113   - //out = new PrintWriter(socket.getOutputStream(), true);
114   - String line = br.readLine();
115   - System.out.println("you input is : " + line);
116   - //out.println("you input is :" + line);
117   - //out.close();
118   - // in.close();
119   - }*/
120   - /*ObjectInputStream ois = new ObjectInputStream(in);
121   - Object obj = ois.readObject();
122   - lastReceiveTime = System.currentTimeMillis();
123   - System.out.println("接收:\t"+obj);
124   - ObjectAction oa = actionMapping.get(obj.getClass());
125   - oa = oa==null?new DefaultObjectAction():oa;
126   - Object out = oa.doAction(obj);
127   - if(out!=null){
128   - ObjectOutputStream oos = new ObjectOutputStream(s.getOutputStream());
129   - oos.writeObject(out);
130   - oos.flush();
131   - } */
132   - } catch (Exception e) {
133   - System.out.println(System.currentTimeMillis()-lastReceiveTime);
134   - e.printStackTrace();
135   - overThis();
136   - }
137   - }
138   - }
139   -
140   - private void overThis() {
141   - if(run)run=false;
142   - if(s!=null){
143   - try {
144   - s.close();
145   - } catch (IOException e) {
146   - e.printStackTrace();
147   - }
148   - }
149   - System.out.println("关闭:"+s.getRemoteSocketAddress());
150   - }
151   -
152   - }
  94 + try {
  95 + InputStream in = s.getInputStream();
  96 + OutputStream out = s.getOutputStream();
  97 + byte[] recData = null;
  98 + while (true) {
  99 + recData = new byte[1024];
  100 + int r = in.read(recData);
  101 + if (r > -1) {
  102 + String data = new String(recData);
  103 + /*
  104 + * if(data.trim().equals("over")) { s.close();
  105 + * break; }
  106 + */
  107 + System.out.println("读取到客户端发送的来数据:" + data);
  108 + }
  109 + }
  110 + /*
  111 + * if(in.available()>0){ BufferedReader br = new
  112 + * BufferedReader(new InputStreamReader(in)); //out = new
  113 + * PrintWriter(socket.getOutputStream(), true); String line
  114 + * = br.readLine(); System.out.println("you input is : " +
  115 + * line); //out.println("you input is :" + line);
  116 + * //out.close(); // in.close(); }
  117 + */
  118 + /*
  119 + * ObjectInputStream ois = new ObjectInputStream(in); Object
  120 + * obj = ois.readObject(); lastReceiveTime =
  121 + * System.currentTimeMillis();
  122 + * System.out.println("接收:\t"+obj); ObjectAction oa =
  123 + * actionMapping.get(obj.getClass()); oa = oa==null?new
  124 + * DefaultObjectAction():oa; Object out = oa.doAction(obj);
  125 + * if(out!=null){ ObjectOutputStream oos = new
  126 + * ObjectOutputStream(s.getOutputStream());
  127 + * oos.writeObject(out); oos.flush(); }
  128 + */
  129 + } catch (Exception e) {
  130 + System.out.println(System.currentTimeMillis() - lastReceiveTime);
  131 + e.printStackTrace();
  132 + overThis();
  133 + }
  134 + }
  135 + }
  136 +
  137 + private void overThis() {
  138 + if (run)
  139 + run = false;
  140 + if (s != null) {
  141 + try {
  142 + s.close();
  143 + } catch (IOException e) {
  144 + e.printStackTrace();
  145 + }
  146 + }
  147 + System.out.println("关闭:" + s.getRemoteSocketAddress());
  148 + }
  149 +
  150 + }
153 151 }
... ...
src/main/java/com/cnlive/socket/TE.java 0 → 100644
  1 +package com.cnlive.socket;
  2 +
  3 +import java.io.BufferedReader;
  4 +import java.io.IOException;
  5 +import java.io.InputStream;
  6 +import java.io.InputStreamReader;
  7 +
  8 +import org.apache.commons.httpclient.Header;
  9 +import org.apache.commons.httpclient.HttpClient;
  10 +import org.apache.commons.httpclient.HttpException;
  11 +import org.apache.commons.httpclient.HttpMethod;
  12 +import org.apache.commons.httpclient.StatusLine;
  13 +import org.apache.commons.httpclient.methods.GetMethod;
  14 +
  15 +public class TE {
  16 +public static void main(String[] args) {
  17 + new TE().doGet("http://bc.cnlive.com/live/epg/play/app?app_id=60_irg1rhs308&channelID=1471754157393");
  18 +}
  19 +
  20 +private HttpClient getHttpClient() {
  21 + HttpClient client = new HttpClient();
  22 + client.getHttpConnectionManager().getParams().setConnectionTimeout(2200);
  23 + client.getHttpConnectionManager().getParams().setSoTimeout(2200);
  24 + return client;
  25 +}
  26 +public void doGet(String url) {
  27 + BufferedReader in = null;
  28 + HttpClient client = this.getHttpClient();
  29 + HttpMethod method = new GetMethod(url);
  30 + method.setFollowRedirects(false);
  31 + InputStream stream = null;
  32 + try {
  33 + int exeCode = client.executeMethod(method);
  34 + StatusLine status = method.getStatusLine();
  35 + int statusCode = status.getStatusCode();
  36 + StringBuffer buf = new StringBuffer();
  37 + if (statusCode == 301 || statusCode == 302) {
  38 + Header[] hs = method.getResponseHeaders("Location");
  39 + for (Header h : hs) {
  40 + System.out.println(h.getName() + "--" + h.getValue());
  41 + String playUrl = h.getValue();
  42 +
  43 + }
  44 + } else {
  45 + stream = method.getResponseBodyAsStream();
  46 + in = new BufferedReader(new InputStreamReader(stream, "UTF-8"));
  47 + String line;
  48 + while (null != (line = in.readLine())) {
  49 + buf.append(line).append("\n");
  50 + }
  51 + System.out.println(buf.toString());
  52 + }
  53 + } catch (HttpException e) {
  54 + e.printStackTrace();
  55 + } catch (IOException e) {
  56 + e.printStackTrace();
  57 + } finally {
  58 + if (in != null) {
  59 + try {
  60 + in.close();
  61 + } catch (Exception e) {
  62 + e.printStackTrace();
  63 + }
  64 + }
  65 + if (stream != null) {
  66 + try {
  67 + stream.close();
  68 + } catch (Exception e) {
  69 + e.printStackTrace();
  70 + }
  71 + }
  72 + method.releaseConnection();
  73 + }
  74 +}
  75 +
  76 +}
... ...
target/m2e-wtp/web-resources/META-INF/maven/com.cnlive.mz.live.web/cnlive_live_web/pom.properties
1 1 #Generated by Maven Integration for Eclipse
2   -#Sat Aug 20 22:58:05 CST 2016
  2 +#Sun Aug 21 18:26:43 CST 2016
3 3 version=0.0.1-SNAPSHOT
4 4 groupId=com.cnlive.mz.live.web
5 5 m2e.projectName=cnlive_live_web
... ...