本文整理汇总了Java中org.apache.commons.httpclient.HttpURL类的典型用法代码示例。如果您正苦于以下问题:Java HttpURL类的具体用法?Java HttpURL怎么用?Java HttpURL使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HttpURL类属于org.apache.commons.httpclient包,在下文中一共展示了HttpURL类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getChildNode
import org.apache.commons.httpclient.HttpURL; //导入依赖的package包/类
protected WebdavContentNode getChildNode(String name)
throws ContentRepositoryException
{
// make sure this isn't a path
if (name.contains("/")) {
throw new ContentRepositoryException("Paths not allowed: " + name);
}
try {
HttpURL url = getChildURL(getResource().getHttpURL(), name);
logger.fine("[WebdavContentCollection] Get child " + name +
" returns " + url + " from " + this);
AuthenticatedWebdavResource resource =
new AuthenticatedWebdavResource(getResource(), url);
if (resource.getExistence()) {
return getContentNode(resource);
}
return null;
} catch (IOException ioe) {
throw new ContentRepositoryException(ioe);
}
}
开发者ID:josmas,项目名称:openwonderland,代码行数:26,代码来源:WebdavContentCollection.java
示例2: removeChild
import org.apache.commons.httpclient.HttpURL; //导入依赖的package包/类
public WebdavContentNode removeChild(String name)
throws ContentRepositoryException
{
// make sure this isn't a path
if (name.contains("/")) {
throw new ContentRepositoryException("Paths not allowed: " + name);
}
try {
HttpURL removeURL = getChildURL(getResource().getHttpURL(), name);
AuthenticatedWebdavResource removeResource =
new AuthenticatedWebdavResource(getResource(), removeURL);
if (removeResource.exists()) {
removeResource.deleteMethod();
}
return getContentNode(removeResource);
} catch (IOException ioe) {
throw new ContentRepositoryException(ioe);
}
}
开发者ID:josmas,项目名称:openwonderland,代码行数:22,代码来源:WebdavContentCollection.java
示例3: execute
import org.apache.commons.httpclient.HttpURL; //导入依赖的package包/类
@Override
public boolean execute()
throws Exception {
String stateValue = _state.toLowerCase();
if ( ! stateValue.equals("enable") &&
! stateValue.equals("disable") &&
! stateValue.equals("drop")) {
throw new IllegalArgumentException("Invalid value for state: " + _state
+ "\n Value must be one of enable|disable|drop");
}
HttpClient httpClient = new HttpClient();
HttpURL url = new HttpURL(_controllerHost,
Integer.parseInt(_controllerPort),
URI_TABLES_PATH + _tableName);
url.setQuery("state", stateValue);
GetMethod httpGet = new GetMethod(url.getEscapedURI());
int status = httpClient.executeMethod(httpGet);
if (status != 200) {
throw new RuntimeException(
"Failed to change table state, error: " + httpGet.getResponseBodyAsString());
}
return true;
}
开发者ID:Hanmourang,项目名称:Pinot,代码行数:24,代码来源:ChangeTableState.java
示例4: execute
import org.apache.commons.httpclient.HttpURL; //导入依赖的package包/类
@Override
public boolean execute() throws Exception {
if (_controllerHost == null) {
_controllerHost = NetUtil.getHostAddress();
}
String stateValue = _state.toLowerCase();
if (!stateValue.equals("enable")
&& !stateValue.equals("disable")
&& !stateValue.equals("drop")) {
throw new IllegalArgumentException("Invalid value for state: " + _state
+ "\n Value must be one of enable|disable|drop");
}
HttpClient httpClient = new HttpClient();
HttpURL url = new HttpURL(_controllerHost,
Integer.parseInt(_controllerPort),
URI_TABLES_PATH + _tableName);
url.setQuery("state", stateValue);
GetMethod httpGet = new GetMethod(url.getEscapedURI());
int status = httpClient.executeMethod(httpGet);
if (status != 200) {
throw new RuntimeException(
"Failed to change table state, error: " + httpGet.getResponseBodyAsString());
}
return true;
}
开发者ID:linkedin,项目名称:pinot,代码行数:27,代码来源:ChangeTableState.java
示例5: downloadFile
import org.apache.commons.httpclient.HttpURL; //导入依赖的package包/类
protected void downloadFile(HttpURL url,
String relativePath,
CollectionScanner scanner)
throws IOException
{
File target = new File(this.toDir, relativePath);
long lastMod = scanner.getProperties().getLastModified(url.toString());
if (shallWeGetIt(target, lastMod)) {
getAndStoreResource(url, target, lastMod, relativePath);
} else {
log("Omitted: " + relativePath + " (uptodate)", ifVerbose());
this.countOmittedFiles++;
}
}
开发者ID:integrated,项目名称:jakarta-slide-webdavclient,代码行数:17,代码来源:Get.java
示例6: getAndStoreResource
import org.apache.commons.httpclient.HttpURL; //导入依赖的package包/类
/**
* Retrieves the data of a resource and stores it in a file.
*
* Creates required directories and sets the last modified time of the file.
*
* @param url path of the resource to be retrieved
* @param target file where the resource data ist stored
* @param lastMod last modified date of the resource, used to set
* the last modified date of the target file
* @param relative path og the resource for logging purposes.
* @throws IOException
* @throws HttpException
* @throws FileNotFoundException
*/
private void getAndStoreResource(HttpURL url, File target, long lastMod, String relative)
throws IOException, HttpException, FileNotFoundException
{
log("downloading: " + relative, ifVerbose());
File directory = target.getParentFile();
if (!directory.exists()) {
directory.mkdirs();
}
InputStream in = Utils.getFile(getHttpClient(), url);
if (!target.exists()) {
target.createNewFile();
}
FileOutputStream out = new FileOutputStream(target);
copyStream(in, out, this.filterSets, this.encoding);
out.close();
target.setLastModified(lastMod);
this.countWrittenFiles++;
}
开发者ID:integrated,项目名称:jakarta-slide-webdavclient,代码行数:37,代码来源:Get.java
示例7: resourceExists
import org.apache.commons.httpclient.HttpURL; //导入依赖的package包/类
/**
* Returns <code>true</code> if the resource given as URL does exist.
* @param client
* @param httpURL
* @return <code>true</code>if the resource exists
* @throws IOException
* @throws HttpException
*/
public static boolean resourceExists(HttpClient client, HttpURL httpURL)
throws IOException, HttpException
{
HeadMethod head = new HeadMethod(httpURL.getURI());
head.setFollowRedirects(true);
int status = client.executeMethod(head);
switch (status) {
case WebdavStatus.SC_OK:
return true;
case WebdavStatus.SC_NOT_FOUND:
return false;
default:
HttpException ex = new HttpException();
ex.setReasonCode(status);
ex.setReason(head.getStatusText());
throw ex;
}
}
开发者ID:integrated,项目名称:jakarta-slide-webdavclient,代码行数:28,代码来源:Utils.java
示例8: putFile
import org.apache.commons.httpclient.HttpURL; //导入依赖的package包/类
public static void putFile(HttpClient client,
HttpURL url,
InputStream is,
String contentType,
String lockToken)
throws IOException, HttpException
{
PutMethod put = new PutMethod(url.getURI());
generateIfHeader(put, lockToken);
put.setRequestHeader("Content-Type", contentType);
put.setRequestBody(is);
put.setFollowRedirects(true);
int status = client.executeMethod(put);
switch (status) {
case WebdavStatus.SC_OK:
case WebdavStatus.SC_CREATED:
case WebdavStatus.SC_NO_CONTENT:
return;
default:
HttpException ex = new HttpException();
ex.setReason(put.getStatusText());
ex.setReasonCode(status);
throw ex;
}
}
开发者ID:integrated,项目名称:jakarta-slide-webdavclient,代码行数:26,代码来源:Utils.java
示例9: getFile
import org.apache.commons.httpclient.HttpURL; //导入依赖的package包/类
public static InputStream getFile(HttpClient client, HttpURL url)
throws IOException, HttpException
{
GetMethod get = new GetMethod(url.toString());
get.setFollowRedirects(true);
int status = client.executeMethod(get);
switch (status) {
case WebdavStatus.SC_OK:
return get.getResponseBodyAsStream();
default:
HttpException ex = new HttpException();
ex.setReason(get.getStatusText());
ex.setReasonCode(status);
throw ex;
}
}
开发者ID:integrated,项目名称:jakarta-slide-webdavclient,代码行数:19,代码来源:Utils.java
示例10: unlockResource
import org.apache.commons.httpclient.HttpURL; //导入依赖的package包/类
public static void unlockResource(HttpClient client, HttpURL url,
String lockToken)
throws IOException, HttpException
{
UnlockMethod unlock = new UnlockMethod(url.getURI(), lockToken);
unlock.setFollowRedirects(true);
int status = client.executeMethod(unlock);
switch (status) {
case WebdavStatus.SC_OK:
case WebdavStatus.SC_NO_CONTENT:
return;
default:
HttpException ex = new HttpException();
ex.setReasonCode(status);
ex.setReason(unlock.getStatusText());
throw ex;
}
}
开发者ID:integrated,项目名称:jakarta-slide-webdavclient,代码行数:21,代码来源:Utils.java
示例11: copyResource
import org.apache.commons.httpclient.HttpURL; //导入依赖的package包/类
public static void copyResource(HttpClient client, HttpURL url,
String destination, int depth, boolean overwrite)
throws IOException, HttpException
{
CopyMethod copy = new CopyMethod(
url.getURI(),
destination,
overwrite,
depth);
copy.setFollowRedirects(true);
int status = client.executeMethod(copy);
switch (status) {
case WebdavStatus.SC_OK:
case WebdavStatus.SC_CREATED:
case WebdavStatus.SC_NO_CONTENT:
return;
default:
HttpException ex = new HttpException();
ex.setReasonCode(status);
ex.setReason(copy.getStatusText());
throw ex;
}
}
开发者ID:integrated,项目名称:jakarta-slide-webdavclient,代码行数:25,代码来源:Utils.java
示例12: moveResource
import org.apache.commons.httpclient.HttpURL; //导入依赖的package包/类
public static void moveResource(HttpClient client, HttpURL url,
String destination, boolean overwrite)
throws IOException, HttpException
{
MoveMethod move = new MoveMethod(url.getURI(), destination, overwrite);
move.setFollowRedirects(true);
int status = client.executeMethod(move);
switch (status) {
case WebdavStatus.SC_OK:
case WebdavStatus.SC_CREATED:
case WebdavStatus.SC_NO_CONTENT:
return;
default:
HttpException ex = new HttpException();
ex.setReasonCode(status);
ex.setReason(move.getStatusText());
throw ex;
}
}
开发者ID:integrated,项目名称:jakarta-slide-webdavclient,代码行数:21,代码来源:Utils.java
示例13: getParentFile
import org.apache.commons.httpclient.HttpURL; //导入依赖的package包/类
public File getParentFile() {
try {
HttpURL httpURL = null;
String parent = null;
parent = this.getParent();
if (parent == null) {
//System.out.println("getParentFile : at root so return null");
return null;
} else {
httpURL = this.rootUrl;
httpURL.setPath(parent);
//System.out.println("getParentFile : set path to " + parent);
return new WebdavFile(httpURL, this.rootUrl);
}
} catch (Exception e) {
System.err.println(e.toString());
e.printStackTrace();
return null;
}
}
开发者ID:integrated,项目名称:jakarta-slide-webdavclient,代码行数:22,代码来源:WebdavSystemView.java
示例14: RootWebdavResource
import org.apache.commons.httpclient.HttpURL; //导入依赖的package包/类
public RootWebdavResource(HttpURL url, String authCookieName,
String authCookieValue)
throws HttpException, IOException
{
super (url, authCookieName, authCookieValue);
connectionManager = new MultiThreadedHttpConnectionManager();
}
开发者ID:josmas,项目名称:openwonderland,代码行数:8,代码来源:WebdavClientPlugin.java
示例15: AuthenticatedWebdavResource
import org.apache.commons.httpclient.HttpURL; //导入依赖的package包/类
public AuthenticatedWebdavResource(AuthenticatedWebdavResource parent,
HttpURL url)
throws HttpException, IOException
{
super (parent.connectionManager);
setupResource(this, url, parent.getAuthCookieName(),
parent.getAuthCookieValue());
}
开发者ID:josmas,项目名称:openwonderland,代码行数:9,代码来源:AuthenticatedWebdavResource.java
示例16: setupResource
import org.apache.commons.httpclient.HttpURL; //导入依赖的package包/类
protected static void setupResource(AuthenticatedWebdavResource resource,
HttpURL url,
String authCookieName,
String authCookieValue)
throws HttpException, IOException
{
resource.setFollowRedirects(true);
resource.setCredentials(new TokenCredentials(authCookieName,
authCookieValue));
resource.setHttpURL(url);
}
开发者ID:josmas,项目名称:openwonderland,代码行数:12,代码来源:AuthenticatedWebdavResource.java
示例17: createChild
import org.apache.commons.httpclient.HttpURL; //导入依赖的package包/类
public WebdavContentNode createChild(String name, Type type)
throws ContentRepositoryException
{
// make sure this isn't a path
if (name.contains("/")) {
throw new ContentRepositoryException("Paths not allowed: " + name);
}
try {
HttpURL newURL = getChildURL(getResource().getHttpURL(), name);
logger.fine("[WebdavContentCollection] Create child " + name +
" returns " + newURL + " from " + this);
AuthenticatedWebdavResource newResource =
new AuthenticatedWebdavResource(getResource(), newURL);
if (newResource.exists()) {
throw new ContentRepositoryException("Path " + newURL +
" already exists.");
}
switch (type) {
case COLLECTION:
newResource.mkcolMethod();
break;
case RESOURCE:
break;
}
return getContentNode(newResource);
} catch (IOException ioe) {
throw new ContentRepositoryException(ioe);
}
}
开发者ID:josmas,项目名称:openwonderland,代码行数:34,代码来源:WebdavContentCollection.java
示例18: getChildURL
import org.apache.commons.httpclient.HttpURL; //导入依赖的package包/类
protected HttpURL getChildURL(HttpURL parent, String childPath)
throws URIException
{
if (childPath.startsWith("/")) {
childPath = childPath.substring(1);
}
if (!parent.getPath().endsWith("/")) {
parent.setPath(parent.getPath() + "/");
}
return new HttpURL(parent, childPath);
}
开发者ID:josmas,项目名称:openwonderland,代码行数:14,代码来源:WebdavContentCollection.java
示例19: start
import org.apache.commons.httpclient.HttpURL; //导入依赖的package包/类
/**
* Create the davClient and authenticate with the resource. serviceContact
* should be in the form of a url
*/
public void start() throws IllegalHostException,
InvalidSecurityContextException, FileResourceException {
ServiceContact serviceContact = getAndCheckServiceContact();
try {
SecurityContext securityContext = getOrCreateSecurityContext("WebDAV", serviceContact);
String contact = getServiceContact().getContact().toString();
if (!contact.startsWith("http")) {
contact = "http://" + contact;
}
HttpURL hrl = new HttpURL(contact);
PasswordAuthentication credentials = getCredentialsAsPasswordAuthentication(securityContext);
String username = credentials.getUserName();
String password = String.valueOf(credentials.getPassword());
hrl.setUserinfo(username, password);
davClient = new WebdavResource(hrl);
setStarted(true);
}
catch (URIException ue) {
throw new IllegalHostException(
"Error connecting to the WebDAV server at " + serviceContact, ue);
}
catch (Exception e) {
throw new IrrecoverableResourceException(e);
}
}
开发者ID:swift-lang,项目名称:swift-k,代码行数:36,代码来源:FileResourceImpl.java
示例20: uploadFileSet
import org.apache.commons.httpclient.HttpURL; //导入依赖的package包/类
private void uploadFileSet(FileSet fileSet)
throws IOException
{
DirectoryScanner scanner = fileSet.getDirectoryScanner(getProject());
String basedir = scanner.getBasedir().getAbsolutePath();
// assert that all required collections does exist
for(Iterator i = determineRequiredDirectories(scanner); i.hasNext();) {
String dir = (String)i.next();
if (dir.equals("")) {
Utils.assureExistingCollection(getHttpClient(),
getUrl(),
this.locktoken);
} else {
HttpURL collURL = Utils.createHttpURL(getUrl(), dir + "/");
Utils.assureExistingCollection(getHttpClient(),
collURL,
this.locktoken);
}
}
// write all files
String[] files = scanner.getIncludedFiles();
for (int i = 0; i < files.length; ++i) {
File file = getProject().resolveFile(basedir + File.separator + files[i]);
uploadFile(asDavPath(files[i]), file);
}
}
开发者ID:integrated,项目名称:jakarta-slide-webdavclient,代码行数:29,代码来源:Put.java
注:本文中的org.apache.commons.httpclient.HttpURL类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论