/*
+---------------------------------------------------------------------------+
| OpenX v2.8 |
| ========= |
| |
| Copyright (c) 2003-2009 OpenX Limited |
| For contact details, see: http://www.openx.org/ |
| |
| This program is free software; you can redistribute it and/or modify |
| it under the terms of the GNU General Public License as published by |
| the Free Software Foundation; either version 2 of the License, or |
| (at your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU General Public License for more details. |
| |
| You should have received a copy of the GNU General Public License |
| along with this program; if not, write to the Free Software |
| Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
+---------------------------------------------------------------------------+
$Id:$
*/
package org.openads.proxy;
import java.io.IOException;
import java.net.URL;
import java.util.Date;
import java.util.Map;
import org.apache.xmlrpc.XmlRpcException;
/**
* The Class OpenAdsApiXmlRpcProxy.
*
* @author Andriy Petlyovanyy <apetlyovanyy@lohika.com>
*/
public class OpenAdsApiXmlRpcProxy {
private String host;
private String basepath;
private int port;
private boolean ssl;
private String sessionId;
private LogonService logonService;
private AgencyService agencyService;
private AdvertiserService advertiserService;
private CampaignService campaignService;
private BannerService bannerService;
private PublisherService publisherService;
private ZoneService zoneService;
/**
* Instantiates a new open ads api xml rpc proxy.
*
* @param host
* the host
* @param basepath
* the basepath
* @param port
* the port
* @param ssl
* the ssl
*/
public OpenAdsApiXmlRpcProxy(String host, String basepath, int port,
boolean ssl) {
this.host = host;
this.basepath = basepath;
this.port = port;
this.ssl = ssl;
try {
String protocol = this.ssl ? "https" : "http";
URL url = new URL(protocol, this.host, this.port, "/"
+ this.basepath);
logonService = new LogonService(url.toString());
agencyService = new AgencyService(url.toString());
advertiserService = new AdvertiserService(url.toString());
campaignService = new CampaignService(url.toString());
bannerService = new BannerService(url.toString());
publisherService = new PublisherService(url.toString());
zoneService = new ZoneService(url.toString());
} catch (Exception e) {
throw new RuntimeException(e.getMessage());
}
}
/**
* Instantiates a new open ads api xml rpc proxy.
*
* @param host
* the host
* @param basepath
* the basepath
*/
public OpenAdsApiXmlRpcProxy(String host, String basepath) {
this(host, basepath, -1, false);
}
/**
* This method is used to initialize session of user.
*
* @param username
* the username
* @param password
* the password
*
* @return True if the operation was successful
*
* @throws XmlRpcException, IOException
* the xml rpc exception
*/
public Boolean logon(String username, String password)
throws XmlRpcException, IOException {
try {
sessionId = logonService.logon(username, password);
if (isValidSessionId()) {
logonService.setSessionId(sessionId);
agencyService.setSessionId(sessionId);
advertiserService.setSessionId(sessionId);
campaignService.setSessionId(sessionId);
bannerService.setSessionId(sessionId);
publisherService.setSessionId(sessionId);
zoneService.setSessionId(sessionId);
return true;
} else {
return false;
}
} catch (XmlRpcException e) {
sessionId = null;
throw e;
}
}
/**
* Checks if is valid session id.
*
* @return true, if is valid session id
*/
private boolean isValidSessionId() {
return (sessionId != null);
}
/**
* Verify logon.
*/
private void verifyLogon() {
if (!isValidSessionId())
throw new IllegalArgumentException("Not logined to server");
}
/**
* This method is used to abandon user session.
*
* @return True if the operation was successful
*
* @throws XmlRpcException, IOException
* the xml rpc exception
*/
public Boolean logoff() throws XmlRpcException, IOException {
verifyLogon();
Boolean result = logonService.logoff();
if (result)
sessionId = null;
return result;
}
/**
* This method adds an agency to the system.
*
* @param params -
* Structure with the following fields:
* <ol>
* <li> agencyName String (255) The name of the agency
* <li> contactName String (255) The name of the contact
* <li> emailAddress String (64) The email address of the contact
* <li> username String (64) The username of the contact used to
* log into OA
* <li> password String (64) The password of the contact used to
* log into OA
* <ol>
*
* @return The ID of the newly created agency
*
* @throws XmlRpcException, IOException
* the xml rpc exception
*
* @see Webservices API
*/
public Integer addAgency(Map params) throws XmlRpcException, IOException {
verifyLogon();
return agencyService.addAgency(params);
}
/**
* This method modifies an existing agency.
*
* @param params
* Structure with the following fields:
* <ol>
* <li> agencyId integer The ID of the agency
* <li> agencyName String (255) The name of the agency
* <li> contactName String (255) The name of the contact
* <li> emailAddress String (64) The email address of the contact
* <li> username String (64) The username of the contact used to
* log into OA
* <li> password String (64) The password of the contact used to
* log into OA
* <ol>
*
* @return True if the operation was successful
*
* @throws XmlRpcException, IOException
* the xml rpc exception
*
*
*/
public Boolean modifyAgency(Map params) throws XmlRpcException, IOException {
verifyLogon();
return agencyService.modifyAgency(params);
}
/**
* Delete agency.
*
* @param id
* the id
*
* @return True if the operation was successful
*
* @throws XmlRpcException, IOException
* the xml rpc exception
*/
public Boolean deleteAgency(Integer id) throws XmlRpcException, IOException {
verifyLogon();
return agencyService.deleteAgency(id);
}
/**
* Gets the agency.
*
* @param id
* the id
*
* @return map agency whith key:
*
* <ol>
* <li> agencyName String (255) The name of the agency
* <li> contactName String (255) The name of the contact
* <li> emailAddress String (64) The email address of the contact
* <li> username String (64) The username of the contact used to log into OA
* <li> password String (64) The password of the contact used to log into OA
* </ol>
*
* @throws XmlRpcException, IOException
* the xml rpc exception
*/
public Map getAgency(Integ
没有合适的资源?快使用搜索试试~ 我知道了~
开源广告管理平台openx 多国语言
5星 · 超过95%的资源 需积分: 13 40 下载量 10 浏览量
2011-06-29
11:39:20
上传
评论 1
收藏 10.94MB GZ 举报
温馨提示
开源广告管理平台开源广告管理平台开源广告管理平台开源广告管理平台
资源推荐
资源详情
资源评论
收起资源包目录
开源广告管理平台openx 多国语言 (3363个子文件)
cache_etc-changes_schema-tables-core-332.bin 12KB
cache_etc-changes_schema-tables-core-334.bin 12KB
cache_etc-changes_schema-tables-core-336.bin 12KB
cache_etc-changes_schema-tables-core-331.bin 12KB
cache_etc-changes_schema-tables-core-330.bin 12KB
cache_etc-changes_schema-tables-core-12934a.bin 12KB
cache_etc-changes_schema-tables-core-12934.bin 12KB
cache_etc-changes_schema-tables-core-329.bin 12KB
cache_etc-changes_schema-tables-core-328.bin 12KB
cache_etc-changes_schema-tables-core-327.bin 12KB
cache_etc-changes_schema-tables-core-131.bin 12KB
cache_etc-changes_schema-tables-core-326.bin 12KB
cache_etc-changes_schema-tables-core-129.bin 12KB
cache_etc-changes_schema-tables-core-130.bin 12KB
cache_etc-changes_schema-tables-core-325.bin 12KB
cache_etc-changes_schema-tables-core-128.bin 12KB
cache_etc-changes_schema-tables-core-127.bin 12KB
cache_etc-changes_schema-tables-core-324.bin 11KB
cache_etc-changes_schema-tables-core-323.bin 11KB
cache_etc-changes_schema-tables-core-322.bin 11KB
cache_etc-changes_schema-tables-core-321.bin 11KB
cache_etc-changes_schema-tables-core-308.bin 11KB
cache_etc-changes_schema-tables-core-125.bin 11KB
cache_etc-changes_schema-tables-core-126.bin 11KB
cache_etc-changes_schema-tables-core-124.bin 11KB
cache_etc-changes_schema-tables-core-123.bin 11KB
cache_etc-changes_schema-tables-core-121.bin 11KB
cache_etc-changes_schema-tables-core-108.bin 11KB
cache_etc-changes_schema-tables-core-122.bin 11KB
cache_etc-changes_schema-tables-core-515.bin 10KB
cache_etc-changes_schema-tables-core-513.bin 10KB
cache_etc-changes_schema-tables-core-512.bin 10KB
cache_etc-changes_schema-tables-core-511.bin 10KB
cache_etc-changes_schema-tables-core-510.bin 10KB
cache_etc-changes_schema-tables-core-506.bin 10KB
cache_etc-changes_schema-tables-core-507.bin 10KB
cache_etc-changes_schema-tables-core-399.bin 10KB
cache_etc-changes_schema-tables-core-199.bin 10KB
cache_etc-changes_schema-tables-core-505.bin 10KB
cache_etc-changes_schema-tables-core-544.bin 10KB
cache_etc-changes_schema-tables-core-543.bin 10KB
cache_etc-changes_schema-tables-core-500.bin 10KB
cache_etc-changes_schema-tables-core-542.bin 10KB
cache_etc-changes_schema-tables-core-541.bin 10KB
cache_etc-changes_schema-tables-core-540.bin 10KB
cache_etc-changes_schema-tables-core-537.bin 10KB
cache_etc-changes_schema-tables-core-539.bin 10KB
cache_etc-changes_schema-tables-core-538.bin 10KB
cache_etc-changes_schema-tables-core-534.bin 9KB
cache_etc-changes_schema-tables-core-533.bin 9KB
cache_etc-changes_schema-tables-core-532.bin 9KB
cache_etc-changes_schema-tables-core-531.bin 9KB
cache_etc-changes_schema-tables-core-530.bin 9KB
cache_etc-changes_schema-tables-core-516.bin 9KB
cache_etc-changes_schema-tables-core-535.bin 9KB
cache_etc-changes_schema-tables-core-536.bin 9KB
cache_etc-changes_schema-tables-core-584.bin 8KB
cache_etc-changes_schema-tables-core-583.bin 8KB
cache_etc-changes_schema-tables-core-582.bin 8KB
cache_etc-changes_schema-tables-core-581.bin 8KB
cache_etc-changes_schema-tables-core-613.bin 8KB
cache_etc_tables-core.bin 8KB
cache_etc-changes_schema-tables-core-612.bin 8KB
cache_etc-changes_schema-tables-core-580.bin 8KB
cache_etc-changes_schema-tables-core-600.bin 8KB
cache_etc-changes_schema-tables-core-610.bin 8KB
cache_etc-changes_schema-tables-core-601.bin 8KB
cache_etc-changes_schema-tables-core-548.bin 8KB
cache_etc-changes_schema-tables-core-607.bin 8KB
cache_etc-changes_schema-tables-core-608.bin 8KB
cache_etc-changes_schema-tables-core-611.bin 8KB
cache_etc-changes_schema-tables-core-609.bin 8KB
cache_etc-changes_schema-tables-core-547.bin 8KB
cache_etc-changes_schema-tables-core-606.bin 8KB
cache_etc-changes_schema-tables-core-603.bin 8KB
cache_etc-changes_schema-tables-core-602.bin 8KB
cache_etc-changes_schema-tables-core-604.bin 8KB
cache_etc-changes_schema-tables-core-605.bin 8KB
cache_etc-changes_schema-tables-core-546.bin 8KB
cache_etc-changes_schema-tables-core-300.bin 4KB
cache_etc-changes_schema-tables-core-049.bin 3KB
cache_etc-changes_schema-tables-core-100.bin 3KB
cache_etc-changes_schema-tables-core-099.bin 3KB
cache_etc-changes_changes-tables-core-505.bin 3KB
cache_adnetworks_getcountries.bin 3KB
cache_etc-changes_changes-tables-core-108.bin 2KB
cache_etc-changes_changes-tables-core-308.bin 2KB
cache_adnetworks_getcategories.bin 2KB
cache_etc-changes_schema-tables-temp-statistics-500.bin 1KB
cache_etc-changes_schema-tables-temp-statistics-501.bin 1KB
cache_etc_tables-temp-statistics.bin 1KB
cache_etc-changes_changes-tables-core-538.bin 1KB
cache_etc-changes_changes-tables-core-127.bin 1KB
cache_etc-changes_changes-tables-core-540.bin 1KB
cache_etc-changes_changes-tables-core-581.bin 1KB
cache_etc-changes_changes-tables-core-124.bin 1KB
cache_etc-changes_changes-tables-core-544.bin 1KB
cache_etc-changes_changes-tables-core-327.bin 1KB
cache_etc-changes_changes-tables-core-506.bin 983B
cache_etc-changes_changes-tables-core-326.bin 847B
共 3363 条
- 1
- 2
- 3
- 4
- 5
- 6
- 34
资源评论
- 达夫_zh2014-02-25中文有乱码,怎么回事呢?
- nsu0022014-08-19有乱码 再看看怎么弄
- faryoungchen2014-08-28不错,但是略微简单了点儿
- andy_melody2012-10-09不错,但是略微简单了点儿
top369ying
- 粉丝: 0
- 资源: 13
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功