package com.newvideo.web.action;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
import java.util.Map;
|
|
import javax.annotation.Resource;
|
import javax.servlet.http.HttpServletRequest;
|
|
import org.apache.struts2.interceptor.ServletRequestAware;
|
import org.springframework.stereotype.Controller;
|
|
import com.newvideo.domain.DetailSystem;
|
import com.newvideo.domain.VideoInfo;
|
import com.newvideo.domain.VideoIntersection;
|
import com.newvideo.service.imp.ConfigService;
|
import com.newvideo.service.imp.IntersectionService;
|
import com.newvideo.service.imp.OtherService;
|
import com.newvideo.service.imp.SystemService;
|
import com.newvideo.service.imp.VideoService;
|
import com.newvideo.util.LogUtil;
|
import com.newvideo.util.StringUtil;
|
import com.newvideo.util.Utils;
|
import com.newvideo.util.push.PushUtil;
|
import com.opensymphony.xwork2.ActionSupport;
|
|
@Controller
|
public class PushAction extends ActionSupport implements ServletRequestAware {
|
@Resource
|
private ConfigService configService;
|
@Resource
|
private SystemService systemService;
|
@Resource
|
private IntersectionService intersectionService;
|
@Resource
|
private VideoService videoService;
|
|
public ConfigService getConfigService() {
|
return configService;
|
}
|
|
public void setConfigService(ConfigService configService) {
|
this.configService = configService;
|
}
|
|
public SystemService getSystemService() {
|
return systemService;
|
}
|
|
public void setSystemService(SystemService systemService) {
|
this.systemService = systemService;
|
}
|
|
public IntersectionService getIntersectionService() {
|
return intersectionService;
|
}
|
|
public void setIntersectionService(IntersectionService intersectionService) {
|
this.intersectionService = intersectionService;
|
}
|
|
public VideoService getVideoService() {
|
return videoService;
|
}
|
|
public void setVideoService(VideoService videoService) {
|
this.videoService = videoService;
|
}
|
|
/**
|
*
|
*/
|
private static final long serialVersionUID = 1L;
|
|
HttpServletRequest request;
|
|
public String getPush() {
|
List<VideoIntersection> intersectionList = intersectionService.getIntersectionList();
|
|
List<DetailSystem> detailSystemList = systemService.getDetailSystemList();
|
|
Map<String, String> map = configService.getConfigAsMap();
|
String versions = map.get("versions");
|
String[] versionSts = versions.split(",");
|
List<String> versionList = new ArrayList<String>();
|
for (String st : versionSts)
|
versionList.add(st);
|
request.setAttribute("detailSystemList", detailSystemList);
|
request.setAttribute("versionList", versionList);
|
request.setAttribute("intersectionList", intersectionList);
|
|
return SUCCESS;
|
}
|
|
public String push() {
|
|
List<String> versionList = new ArrayList<String>();
|
String[] versionSts = versions.split(",");
|
for (String st : versionSts)
|
versionList.add(st);
|
|
title = StringUtil.getUTF8String(title, "iso-8859-1");
|
content = StringUtil.getUTF8String(content, "iso-8859-1");
|
|
String[] detailsystemSts = apps.split(",");
|
|
List<DetailSystem> systemList = new ArrayList<DetailSystem>();
|
for (String st : detailsystemSts)
|
systemList.add(systemService.getDetailSystemById(st));
|
boolean isS = false;
|
switch (pushtype) {
|
case 1:
|
isS = PushUtil.sendText(title, content, versionList, systemList);
|
break;// ����
|
case 2:
|
VideoInfo video = videoService.getVideoInfo(videoid);
|
isS = PushUtil.sendVideoInfo(title, content, versionList, systemList, video);
|
break;// ��Ƶ
|
case 3:
|
isS = PushUtil.sendUrl(title, content, versionList, systemList, url);
|
break;// ����
|
case 4:
|
VideoIntersection vi = intersectionService.getIntersectionById(intersectionid);
|
isS = PushUtil.sendIntersection(title, content, versionList, systemList, vi);
|
break;// �ϼ�
|
}
|
if (isS)
|
request.setAttribute("result", "�Ѿ��������Ͷ���");
|
else
|
request.setAttribute("result", "����ʧ��");
|
return SUCCESS;
|
}
|
|
public void setServletRequest(HttpServletRequest arg0) {
|
this.request = arg0;
|
}
|
|
// ���͵�ʵ��
|
private int pushtype;// ���͵�����
|
private String versions;
|
private String apps;
|
private String title;// ����
|
private String content;// ����
|
private String videoid;// ��ƵID
|
private String url;// ��������
|
private String intersectionid;// �ϼ�ID
|
|
public String getVersions() {
|
return versions;
|
}
|
|
public void setVersions(String versions) {
|
this.versions = versions;
|
}
|
|
public String getApps() {
|
return apps;
|
}
|
|
public void setApps(String apps) {
|
this.apps = apps;
|
}
|
|
public int getPushtype() {
|
return pushtype;
|
}
|
|
public void setPushtype(int pushtype) {
|
this.pushtype = pushtype;
|
}
|
|
public String getTitle() {
|
return title;
|
}
|
|
public void setTitle(String title) {
|
this.title = title;
|
}
|
|
public String getContent() {
|
return content;
|
}
|
|
public void setContent(String content) {
|
this.content = content;
|
}
|
|
public String getVideoid() {
|
return videoid;
|
}
|
|
public void setVideoid(String videoid) {
|
this.videoid = videoid;
|
}
|
|
public String getUrl() {
|
return url;
|
}
|
|
public void setUrl(String url) {
|
this.url = url;
|
}
|
|
public String getIntersectionid() {
|
return intersectionid;
|
}
|
|
public void setIntersectionid(String intersectionid) {
|
this.intersectionid = intersectionid;
|
}
|
|
// ������
|
|
@Override
|
public void addActionError(String anErrorMessage) {
|
// TODO Auto-generated method stub
|
super.addActionError(anErrorMessage);
|
LogUtil.i(anErrorMessage);
|
}
|
|
@Override
|
public void addFieldError(String fieldName, String errorMessage) {
|
// TODO Auto-generated method stub
|
super.addFieldError(fieldName, errorMessage);
|
LogUtil.i(errorMessage);
|
}
|
|
@Override
|
public void addActionMessage(String aMessage) {
|
// TODO Auto-generated method stub
|
super.addActionMessage(aMessage);
|
LogUtil.i(aMessage);
|
}
|
|
}
|