Java Code Examples for net.sf.json.JSONObject#containsKey()

The following examples show how to use net.sf.json.JSONObject#containsKey() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UsergroupClient.java    From primecloud-controller with GNU General Public License v2.0 6 votes vote down vote up
/**
 * ユーザグループ情報を更新します。
 * usrgrpidパラメータを必ず指定する必要があります。<br/>
 * @param param {@link UsergroupUpdateParam}
 * @return 更新されたユーザグループ情報のusrgrpidのリスト
 */
@SuppressWarnings("unchecked")
public List<String> update(UsergroupUpdateParam param) {
    if (param.getUsrgrpid() == null || param.getUsrgrpid().length() == 0) {
        throw new IllegalArgumentException("usrgrpid is required.");
    }

    JSONObject params = JSONObject.fromObject(param, defaultConfig);
    if (accessor.checkVersion("2.0") >= 0) {
        // api_accessは2.0以降で廃止されたパラメータ
        if (params.containsKey("api_access")) {
            params.remove("api_access");
        }
    }

    JSONObject result = (JSONObject) accessor.execute("usergroup.update", params);

    JSONArray usrgrpids = result.getJSONArray("usrgrpids");
    JsonConfig config = defaultConfig.copy();
    config.setCollectionType(List.class);
    config.setRootClass(String.class);
    return (List<String>) JSONArray.toCollection(usrgrpids, config);
}
 
Example 2
Source File: UsergroupClient.java    From primecloud-controller with GNU General Public License v2.0 6 votes vote down vote up
/**
 * ユーザグループ情報を作成します。<br/>
 * nameパラメータを必ず指定する必要があります。<br/>
 * 既に存在するユーザグループのnameを指定した場合、例外をスローします。
 *
 * @param param {@link UsergroupCreateParam}
 * @return 作成されたユーザグループ情報のusrgrpidのリスト
 */
@SuppressWarnings("unchecked")
public List<String> create(UsergroupCreateParam param) {
    if (param.getName() == null || param.getName().length() == 0) {
        throw new IllegalArgumentException("name is required.");
    }

    JSONObject params = JSONObject.fromObject(param, defaultConfig);
    if (accessor.checkVersion("2.0") >= 0) {
        // api_accessは2.0以降で廃止されたパラメータ
        if (params.containsKey("api_access")) {
            params.remove("api_access");
        }
    }

    JSONObject result = (JSONObject) accessor.execute("usergroup.create", params);

    JSONArray usrgrpids = result.getJSONArray("usrgrpids");
    JsonConfig config = defaultConfig.copy();
    config.setCollectionType(List.class);
    config.setRootClass(String.class);
    return (List<String>) JSONArray.toCollection(usrgrpids, config);
}
 
Example 3
Source File: Approval.java    From gerrit-events with MIT License 6 votes vote down vote up
@Override
public void fromJson(JSONObject json) {
    if (json.containsKey(TYPE) && json.containsKey(VALUE)) {
        type = getString(json, TYPE);
        value = getString(json, VALUE);
    }
    if (json.containsKey(BY)) {
        by = new Account(json.getJSONObject(BY));
    }
    if (json.containsKey(UPDATED)) {
        updated = getBoolean(json, UPDATED);
    }
    if (json.containsKey(OLD_VALUE)) {
        oldValue = getString(json, OLD_VALUE);
    }
}
 
Example 4
Source File: Awvs.java    From TrackRay with GNU General Public License v3.0 6 votes vote down vote up
public List<Vulnerabilities> vulns(String sessionId,String scanId){
    ArrayList<Vulnerabilities> obj = new ArrayList<>();
    JSONObject jsonObject = vulnsJSON(sessionId, scanId);
    if (jsonObject.containsKey("vulnerabilities")){
        JSONArray vulnerabilities = jsonObject.getJSONArray("vulnerabilities");
        for (int i = 0; i < vulnerabilities.size(); i++) {
            JSONObject vul = vulnerabilities.getJSONObject(i);
            try {
                Vulnerabilities vulnbean = toBean(vul.toString(), Vulnerabilities. class);
                /*Vulndetail vulndetail = vuln(scanId, sessionId, vulnbean.getVulnId());
                vulnbean.getVuln().add(vulndetail);*/
                obj.add(vulnbean);
            } catch (IOException e) {
                continue;
            }
        }
    }
    return obj;
}
 
Example 5
Source File: JwMediaAPI.java    From jeewx-api with Apache License 2.0 6 votes vote down vote up
/**
 * 新增其他永久素材   
 * @param accesstoken
 * @param wx
 * @return
 * @throws WexinReqException
 */
public static WxMediaForMaterialResponse addMediaFileByMaterialNews(String accesstoken, String type,String filePath,String fileName) throws WexinReqException {
	WxMediaForMaterialResponse mediaResource = null;
	if (accesstoken != null) {
		String requestUrl = add_material.replace("ACCESS_TOKEN", accesstoken);
		String url = requestUrl.replace("TYPE", type);
		File file = new File(filePath + fileName);
		String contentType = WeiXinReqUtil.getFileContentType(fileName.substring(fileName.lastIndexOf(".") + 1));
		JSONObject result = WxstoreUtils.uploadMediaFileNews(url, file, contentType);
		if (result.containsKey("errcode")) {
			logger.error("新增其他永久素材 失败!errcode=" + result.getString("errcode") + ",errmsg = " + result.getString("errmsg"));
			throw new WexinReqException(result.getString("errcode"));
		} else {
			logger.info("====新增其他永久素材  成功====result:"+result.toString());
			mediaResource = new WxMediaForMaterialResponse();
			if("thumb".equals(type)){
				mediaResource.setMedia_id(result.getString("thumb_media_id"));
			}else{
				mediaResource.setMedia_id(result.getString("media_id"));
			}
			mediaResource.setUrl(result.getString("url"));
		}
	}
	return mediaResource;
}
 
Example 6
Source File: WeixinNewstemplateServiceImpl.java    From jeewx-boot with Apache License 2.0 6 votes vote down vote up
private String uploadPhoto(String imagePath, String jwid) {
	String media_id="";
	HttpServletRequest request =((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
	//获取token方法替换
	String accessToken =WeiXinHttpUtil.getRedisWeixinToken(jwid);
	//String url=request.getSession().getServletContext().getRealPath("/")+imagePath;
	//update-begin--Author:zhaofei  Date: 20191023 for:修改图文素材上传封面图到服务器
	String url = imagePath;
	JSONObject jsonObj=WeixinUtil.sendMediaByUrl("image", url, accessToken);
	//update-end--Author:zhaofei  Date: 20191023 for:修改图文素材上传封面图到服务器
	if(jsonObj!=null){
		if(jsonObj.containsKey("errcode")){
			//author:sunkai--date:2018-09-26--for:粉丝同步错误返回码信息转义
			//String errcode = jsonObj.getString("errcode");
			//String errmsg = jsonObj.getString("errmsg");
			String msg = WxErrCodeUtil.testErrCode(jsonObj.getString("errcode"));
			System.out.println("图片同步微信服务器失败! "+msg);
			//author:sunkai--date:2018-09-26--for:粉丝同步错误返回码信息转义
		}else{
			System.out.println("图片素材同步微信服务器成功");
			media_id = jsonObj.getString("media_id");
		}
	}
	return media_id;
}
 
Example 7
Source File: DraftPublished.java    From gerrit-events with MIT License 5 votes vote down vote up
@Override
public void fromJson(JSONObject json) {
    super.fromJson(json);
    if (json.containsKey(UPLOADER)) {
        this.account = new Account(json.getJSONObject(UPLOADER));
    }
}
 
Example 8
Source File: GerritTriggeredEvent.java    From gerrit-events with MIT License 5 votes vote down vote up
@Override
public void fromJson(JSONObject json) {
    if (json.containsKey(PROVIDER)) {
        provider = new Provider(json.getJSONObject(PROVIDER));
    }
    if (json.containsKey(EVENTCREATED_ON)) {
        eventCreatedOn = getDate(json, EVENTCREATED_ON);
    }
}
 
Example 9
Source File: SQLinjectionByCrawler.java    From TrackRay with GNU General Public License v3.0 5 votes vote down vote up
private void dataScan(){
    JSONObject json = toJSON(get(server + "scan/" + taskid + "/data").body());
    if (json.containsKey("data")){
        JSONArray data = json.getJSONArray("data");
        if(data.size()>0){
            this.result = data.toString();
            log.info("存在注入:"+ this.result);
        }
    }
}
 
Example 10
Source File: SQLMapInner.java    From TrackRay with GNU General Public License v3.0 5 votes vote down vote up
public List<String> findTasks(){
    List<String> list = new ArrayList<>();
    HttpResponse req = get(server + "admin/list");
    JSONObject json = toJSON(req.body());
    if (json.containsKey("tasks")){
        JSONObject tasks = json.getJSONObject("tasks");
        list.addAll(tasks.keySet());
    }
    return list;
}
 
Example 11
Source File: JobConfigurationService.java    From sonar-quality-gates-plugin with MIT License 5 votes vote down vote up
protected String hasFormDataKey(JSONObject formData, GlobalConfig globalConfig) {

        String instanceName;

        if (formData.containsKey("sonarInstancesName")) {
            instanceName = formData.getString("sonarInstancesName");
        } else {
            instanceName = globalConfig.fetchListOfGlobalConfigData().get(0).getName();
        }

        return instanceName;
    }
 
Example 12
Source File: RestUtils.java    From mobi with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Retrieves a single Entity object from a JSON-LD string and returns it as a JSONObject. Looks within the first
 * context object if present.
 *
 * @param json A JSON-LD string
 * @return The first object representing a single Entity present in the JSON-LD array.
 */
public static JSONObject getObjectFromJsonld(String json) {
    JSONArray array = JSONArray.fromObject(json);
    JSONObject firstObject = Optional.ofNullable(array.optJSONObject(0)).orElse(new JSONObject());
    if (firstObject.containsKey("@graph")) {
        firstObject = Optional.ofNullable(firstObject.getJSONArray("@graph").optJSONObject(0))
                .orElse(new JSONObject());
    }
    return firstObject;
}
 
Example 13
Source File: JsonUtil.java    From zxl with Apache License 2.0 5 votes vote down vote up
public static <E extends Table> Table parse(String json, Class<E> clazz) throws Exception {
	JSONObject jsonObject = JSONObject.fromObject(json);
	E entity = clazz.newInstance();
	if (jsonObject.containsKey("id"))
		entity.setId(jsonObject.getString("id"));
	for (Field field : ReflectUtil.getAllFields(clazz)) {
		if (!HBaseUtil.isFamily(field)) {
			continue;
		}
		if (HBaseUtil.isBaseFamily(field)) {
			Family family = new Family();
			family.putJsonObject(jsonObject.getJSONObject(field.getName()));
			ReflectUtil.setFieldValue(entity, field, family);
		} else if (HBaseUtil.isArrayFamily(field)) {
			JSONArray familyArray = jsonObject.getJSONArray(field.getName());
			Class<?> genericClass = ReflectUtil.getParameterizedType(field);
			List<Object> list = new ArrayList<Object>();
			if (genericClass == String.class) {
				for (int i = 0; i < familyArray.size(); i++) {
					list.add(familyArray.getString(i));
				}
			} else if (Family.class.isAssignableFrom(genericClass)) {
				for (int i = 0; i < familyArray.size(); i++) {
					list.add(new Family(familyArray.getJSONObject(i)));
				}
			} else {
				LogUtil.warn(LOGGER, field.getName() + "����Family���ͣ�");
			}
		} else {
			LogUtil.warn(LOGGER, "������ݿ��ѯ���ʱ��������[" + field.getName() + "]");
		}
	}
	return entity;
}
 
Example 14
Source File: PatchSet.java    From gerrit-events with MIT License 5 votes vote down vote up
@Override
public void fromJson(JSONObject json) {
    number = getString(json, NUMBER);
    revision = getString(json, REVISION);
    draft = getBoolean(json, IS_DRAFT);
    createdOn = getDate(json, CREATED_ON);
    if (json.containsKey(KIND)) {
        kind = GerritChangeKind.fromString(getString(json, KIND));
    }
    ref = getString(json, REF);
    if (json.containsKey(UPLOADER)) {
        uploader = new Account(json.getJSONObject(UPLOADER));
    }
    if (json.containsKey(AUTHOR)) {
        author = new Account(json.getJSONObject(AUTHOR));
    }
    if (json.containsKey(APPROVALS)) {
        approvals = new ArrayList<Approval>();
        JSONArray eventApprovals = json.getJSONArray(APPROVALS);
        for (int i = 0; i < eventApprovals.size(); i++) {
            approvals.add(new Approval(eventApprovals.getJSONObject(i)));
        }
    }
    if (json.containsKey(PARENTS)) {
        parents = new ArrayList<String>();
        JSONArray eventParents = json.getJSONArray(PARENTS);
        for (int i = 0; i < eventParents.size(); i++) {
            parents.add(eventParents.getString(i));
        }
    }
}
 
Example 15
Source File: ChangeMerged.java    From gerrit-events with MIT License 5 votes vote down vote up
@Override
public void fromJson(JSONObject json) {
    super.fromJson(json);
    if (json.containsKey(SUBMITTER)) {
        account = new Account(json.getJSONObject(SUBMITTER));
    }

    if (json.containsKey(NEWREV)) {
        this.newRev = getString(json, NEWREV);
    }
}
 
Example 16
Source File: MyJwWebJwidController.java    From jeewx-boot with Apache License 2.0 5 votes vote down vote up
/**
 * 保存内容
 * @param jsonObject
 * @param myJwWebJwid
 */
private void save(JSONObject jsonObject,MyJwWebJwid myJwWebJwid) {
	try {
		String authorizationInfoStr = jsonObject.getString("authorization_info");
		JSONObject authorizationInfoJson = JSONObject.fromObject(authorizationInfoStr);
		String authorizerAppid = null;
		if(authorizationInfoJson.containsKey("authorizer_appid")){
			authorizerAppid=authorizationInfoJson.getString("authorizer_appid");
		}else if(jsonObject.containsKey("authorizer_appid")){
			authorizerAppid = jsonObject.getString("authorizer_appid");
		}
		String authorizerAccessToken = authorizationInfoJson.getString("authorizer_access_token");
		String authorizerRefreshToken = authorizationInfoJson.getString("authorizer_refresh_token");
		String funcInfoStr ="";
		if(authorizationInfoJson.containsKey("func_info")){
			funcInfoStr= authorizationInfoJson.getString("func_info");
		}else if(jsonObject.containsKey("func_info")){
			funcInfoStr= jsonObject.getString("func_info");
		}
		myJwWebJwid.setAuthorizationInfo(authorizationInfoStr);
		myJwWebJwid.setAccessToken(authorizerAccessToken);
		myJwWebJwid.setTokenGetTime(new Date());
		myJwWebJwid.setWeixinAppId(authorizerAppid);
		myJwWebJwid.setAuthorizerRefreshToken(authorizerRefreshToken);
		myJwWebJwid.setFuncInfo(funcInfoStr);
		myJwWebJwid.setAuthType("2");
		//授权状态(1正常,2已取消)
		myJwWebJwid.setAuthorizationStatus("1");
	} catch (Exception e) {
		e.printStackTrace();
		throw new CommonweixinException("解析授权信息==DOADD时发生错误"+e.getMessage());
	}

}
 
Example 17
Source File: WeixinQrcodeController.java    From jeewx-boot with Apache License 2.0 4 votes vote down vote up
/**
 * 生成二维码
 * @return
 */
@RequestMapping(value = "/generateQrcode",method ={RequestMethod.GET, RequestMethod.POST})
@ResponseBody
public AjaxJson generateQrcode(WeixinQrcode weixinQrcode){
	AjaxJson j = new AjaxJson();
	j.setSuccess(false);
	//获取token方法
	String accessToken =WeiXinHttpUtil.getRedisWeixinToken(weixinQrcode.getJwid());
	if(oConvertUtils.isEmpty(accessToken)){
		j.setSuccess(false);
		j.setMsg("未获取到公众号accessToken");
		return j;
	}
	 String ticketurl = WeixinUtil.qrcode_ticket_url.replace("ACCESS_TOKEN",accessToken);
	 HashMap<String, Object> map = new HashMap<String, Object>();
	 HashMap<String, String> sceneMap = new HashMap<String, String>();
	 sceneMap.put("scene_id", weixinQrcode.getSceneId().toString());
	 map.put("scene", sceneMap);
	 JSONObject jsonQrcode = new JSONObject();
	 jsonQrcode.put("action_name", weixinQrcode.getActionName());
	 jsonQrcode.put("action_info", JSONObject.fromObject(map));
	 if(weixinQrcode.getActionName().equals("QR_SCENE")){
		 jsonQrcode.put("expire_seconds", weixinQrcode.getExpireSeconds());  //有效期
	 }
	 JSONObject ticketjson  = WeixinUtil.httpRequest(ticketurl, "POST", jsonQrcode.toString());
	 //判断是否执行成功
	 if(!ticketjson.containsKey("errcode")){
		 //取到ticket
		 String ticket = ticketjson.getString("ticket");
		 weixinQrcode.setTicket(ticket);
		 //通过ticket获取图片
		 String qrcodeimgurl =  WeixinUtil.get_qrcode_url.replace("TICKET",ticket);
		 weixinQrcode.setQrcodeUrl(qrcodeimgurl);
		 if(weixinQrcode.getActionName().equals("QR_SCENE")){
			 weixinQrcode.setExpireSeconds(weixinQrcode.getExpireSeconds());
			 Calendar cal = Calendar.getInstance(); 
			 cal.add(Calendar.SECOND,weixinQrcode.getExpireSeconds()); 
			 weixinQrcode.setExpireDate(cal.getTime());
		 }
		 weixinQrcodeService.doEdit(weixinQrcode);
		 j.setObj(qrcodeimgurl);
		 if(weixinQrcode.getExpireDate()!=null){
			 j.setMsg(DateUtils.formatDate(weixinQrcode.getExpireDate(),"yyyy-MM-dd HH:mm:ss"));
		 }
		 j.setSuccess(true);
	 }else{
		 j.setSuccess(false);
	 }
	 return j;
	 
}
 
Example 18
Source File: WeixinNewstemplateServiceImpl.java    From jeewx-boot with Apache License 2.0 4 votes vote down vote up
@Transactional(rollbackFor = {Exception.class})
@Override
public String uploadNewstemplate(String id,String jwid) {
	
	String message=null;
	WeixinNewstemplate newsTemplate=weixinNewstemplateDao.get(id);
	//1.根据id获取当前模板的所有图文
	List<WeixinNewsitem> newsItems=weixinNewsitemDao.queryByNewstemplateId(id);
	if(newsItems.size()>0){
		//author:sunkai--date:2018-10-09--for:异常捕获
		try {
			//设置图文上传状态为上传中
			newsTemplate.setUploadType("1");
			weixinNewstemplateDao.update(newsTemplate);
			//2.遍历所有的图文
			List<BaseGraphic> baseGraphicList = new ArrayList<BaseGraphic>();
			for(int i=0;i<newsItems.size();i++){
				//3.1装载图文参数
				WeixinNewsitem newsItem=newsItems.get(i);
				BaseGraphic baseGraphic=new BaseGraphic();
				//update-begin--Author:zhangweijian  Date: 20180820 for:位置调整
				baseGraphic.setThumb_media_id(this.uploadPhoto(newsItem.getImagePath(),jwid));
				baseGraphic.setAuthor(newsItem.getAuthor());
				baseGraphic.setTitle(newsItem.getTitle());
				baseGraphic.setContent_source_url(newsItem.getUrl());
				baseGraphic.setContent(this.updateContent(newsItem.getContent(),jwid));
				baseGraphic.setDigest(newsItem.getDescription());
				//update-begin--Author:zhangweijian Date:20181016 for:传入封面图是否展示参数
				//是否显示封面图,1为显示,0为不显示
				baseGraphic.setShow_cover_pic(newsItem.getShowCoverPic());
				//update-end--Author:zhangweijian Date:20181016 for:传入封面图是否展示参数
				//update-end--Author:zhangweijian  Date: 20180820 for:位置调整
				baseGraphicList.add(baseGraphic);
				//3.2更新图文素材信息
				newsItem.setThumbMediaId(baseGraphic.getThumb_media_id());
				newsItem.setContent(baseGraphic.getContent());
				weixinNewsitemDao.update(newsItem);
			}
			UploadGraphic graphic = new UploadGraphic();
			graphic.setArticles(baseGraphicList);
			JSONObject resultJson=uploadGroupNewsTemplate(graphic,jwid);
			if(resultJson.containsKey("media_id")){
				newsTemplate.setMediaId(resultJson.getString("media_id"));
				newsTemplate.setUploadTime(new Date());
				//update-begin--Author:zhangweijian  Date: 20180807 for:上传成功状态
				//"2":上传成功;"3":上传失败
				newsTemplate.setUploadType("2");
				//update-end--Author:zhangweijian  Date: 20180807 for:上传成功状态
				weixinNewstemplateDao.update(newsTemplate);
				message= "图文素材上传成功!";
			}else{
				//update-begin--Author:zhangweijian  Date: 20180807 for:上传成功状态
				newsTemplate.setUploadType("3");
				weixinNewstemplateDao.update(newsTemplate);
				//update-end--Author:zhangweijian  Date: 20180807 for:上传成功状态
				//author:sunkai--date:2018-09-26--for:粉丝同步错误返回码信息转义
				String msg = WxErrCodeUtil.testErrCode(resultJson.getString("errcode"));
				message= "图文素材上传失败,"+msg;
				//author:sunkai--date:2018-09-26--for:粉丝同步错误返回码信息转义
			}
		} catch (Exception e) {
			e.printStackTrace();
			message= "图文素材上传失败";
			newsTemplate.setUploadType("3");
			weixinNewstemplateDao.update(newsTemplate);
		}
		//author:sunkai--date:2018-10-09--for:异常捕获
	}else{
		message="该图文模板尚未添加图文消息!";
	}
	return message;
}
 
Example 19
Source File: TestGoogleSearch.java    From albert with MIT License 4 votes vote down vote up
public static void main(String[] args) throws ClientProtocolException, IOException {
		StringBuffer sb = new StringBuffer(); 
		HttpClient client = ProxyUtil.getHttpClient();
		 HttpGet httpGet = new HttpGet(Constants.GOOGLE_SEARCH_URL+"哈哈"+"&start=1&num=10");
		 HttpResponse response = client.execute(httpGet);
		 
		 Header[] headers = response.getAllHeaders();
		 
		 if(200!=response.getStatusLine().getStatusCode()){
			  System.out.println("无法访问");
		 }
		 
		 HttpEntity entry = response.getEntity();
		 
		 if(entry != null)
		  {
		    InputStreamReader is = new InputStreamReader(entry.getContent());
		    BufferedReader br = new BufferedReader(is);
		    String str = null;
		    while((str = br.readLine()) != null)
		    {
		     sb.append(str.trim());
		    }
		    br.close();
		  }
		 
		 
		 
//		 System.out.println(sb.toString());
		  JSONArray jsonArray = null;
		  JSONObject jsonObject=null;
		  jsonArray = JSONObject.fromObject(sb.toString()).getJSONArray("items");
		  
		  GoogleSearchResult googleSearchResult =new GoogleSearchResult();
		  
		  for(int i=0,length=jsonArray.size();i<length;i++){
			  jsonObject = jsonArray.getJSONObject(i);
			  googleSearchResult.setHtmlTitle(jsonObject.getString("htmlTitle"));
			  googleSearchResult.setLink(jsonObject.getString("link"));
			  googleSearchResult.setLink(jsonObject.getString("htmlSnippet"));
			  if(jsonObject.containsKey("pagemap")&&jsonObject.getJSONObject("pagemap").containsKey("cse_thumbnail")){
				  googleSearchResult.setSrc(jsonObject.getJSONObject("pagemap").getJSONArray("cse_thumbnail").getJSONObject(0).getString("src"));
				  googleSearchResult.setWidth(jsonObject.getJSONObject("pagemap").getJSONArray("cse_thumbnail").getJSONObject(0).getString("width"));
				  googleSearchResult.setHeight(jsonObject.getJSONObject("pagemap").getJSONArray("cse_thumbnail").getJSONObject(0).getString("height"));
			  }
			  System.out.println(googleSearchResult.toString());
		  }
		 
	}
 
Example 20
Source File: NewsTemplateController.java    From jeewx with Apache License 2.0 4 votes vote down vote up
@RequestMapping(params = "doUpNews")
@ResponseBody
public AjaxJson doUploadwx(HttpServletRequest request, HttpServletResponse response) {
	AjaxJson j = new AjaxJson();
	try {
		String tempid = request.getParameter("tempid");
		//先判断图文模板下的图文消息是否都已经上传图片
		NewsTemplate newsTemplate = this.newsTemplateService.get(NewsTemplate.class, tempid);
		this.message="上传图文信息成功!";
		if(newsTemplate!=null){
			String hql = "from NewsItem where newsTemplate.id='"+tempid+"' order by orders asc";
			org.jeecgframework.core.util.LogUtil.info("...hql..."+hql);
			List<NewsItem> weixinnewsitem = this.systemService.findByQueryString(hql);
			int size = weixinnewsitem.size();
			if(size>0){
				List<BaseGraphic> baseGraphicList = new ArrayList<BaseGraphic>();
				for(int i=0;i<size;i++){
					 NewsItem newItem = weixinnewsitem.get(i);
					 BaseGraphic baseGraphic = new BaseGraphic();
					 baseGraphic.setTitle(newItem.getTitle());
					 String thumb_media_id = uploadPhoto(newItem.getImagePath(), newsTemplate.getAccountId(), request);
					 baseGraphic.setThumb_media_id(thumb_media_id);
					 baseGraphic.setAuthor(newItem.getAuthor());
					 baseGraphic.setDigest(newItem.getDescription());
					 //TODO:这里 暂定为不显示封面图
				     baseGraphic.setShow_cover_pic("0");
					 baseGraphic.setContent(newItem.getContent());
					 baseGraphic.setContent_source_url(newItem.getUrl());
					 baseGraphicList.add(baseGraphic);
				 }
				
				 UploadGraphic graphic = new UploadGraphic();
				 graphic.setArticles(baseGraphicList);
				 JSONObject resultJson = this.newsTemplateService.uploadNewsTemplate(graphic);
				 if(resultJson!=null && resultJson.containsKey("media_id")){
					 newsTemplate.setMediaid(resultJson.getString("media_id"));
					 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
					 newsTemplate.setAddTime(sdf.format(new Date()));
					 newsTemplate.setIsup("1");
					 this.newsTemplateService.updateEntitie(newsTemplate);
				 }else{
					 message= "分组群发图文消息同步出错,错误信息"+resultJson.toString();
				 }
			}else{
				message="该图文模板尚未添加图文消息!";
			}
		}	
		
	} catch (Exception e) {
		message= "图文素材上传失败。";
		e.printStackTrace();
	}
	j.setMsg(message);
	j.setSuccess(true);
	return j;
}