本文整理汇总了Java中org.apache.commons.httpclient.protocol.Protocol.getScheme方法的典型用法代码示例。如果您正苦于以下问题:Java Protocol.getScheme方法的具体用法?Java Protocol.getScheme怎么用?Java Protocol.getScheme使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.httpclient.protocol.Protocol
的用法示例。
在下文中一共展示了Protocol.getScheme方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getProtocol
import org.apache.commons.httpclient.protocol.Protocol; //导入方法依赖的package包/类
/**
* Get a Protocol for the given parameters. The default implementation
* selects a protocol based only on the scheme. Subclasses can do fancier
* things, such as select SSL parameters based on the host or port. This
* method must not return null.
*/
protected Protocol getProtocol(HostConfiguration old, String scheme, String host, int port)
{
final Protocol oldProtocol = old.getProtocol();
if (oldProtocol != null) {
final String oldScheme = oldProtocol.getScheme();
if (oldScheme == scheme || (oldScheme != null && oldScheme.equalsIgnoreCase(scheme))) {
// The old protocol has the desired scheme.
return oldProtocol; // Retain it.
}
}
Protocol newProtocol = (scheme != null && scheme.toLowerCase().endsWith("s")) ? httpsProtocol
: httpProtocol;
if (newProtocol == null) {
newProtocol = Protocol.getProtocol(scheme);
}
return newProtocol;
}
示例2: testConnect
import org.apache.commons.httpclient.protocol.Protocol; //导入方法依赖的package包/类
public boolean testConnect(Calendar cal) throws MalformedURLException, ObjectStoreException
{
boolean connected = false;
PathResolver RESOLVER = getPathResolver(cal.getTypeSelect());
Protocol protocol = getProtocol(cal.getIsSslConnection());
URL url = new URL(protocol.getScheme(), cal.getUrl(), cal.getPort(), "");
ICalendarStore store = new ICalendarStore(url, RESOLVER);
try
{
connected = store.connect(cal.getLogin(), cal.getPassword());
}
finally {
store.disconnect();
}
return connected;
}
示例3: sync
import org.apache.commons.httpclient.protocol.Protocol; //导入方法依赖的package包/类
@Transactional
public void sync(Calendar calendar)
throws ICalendarException, MalformedURLException {
PathResolver RESOLVER = getPathResolver(calendar.getTypeSelect());
Protocol protocol = getProtocol(calendar.getIsSslConnection());
URL url = new URL(protocol.getScheme(), calendar.getUrl(), calendar.getPort(), "");
ICalendarStore store = new ICalendarStore(url, RESOLVER);
try {
if(calendar.getLogin() != null && calendar.getPassword() != null && store.connect(calendar.getLogin(), calendar.getPassword())){
List<CalDavCalendarCollection> colList = store.getCollections();
if(!colList.isEmpty()){
calendar = doSync(calendar, colList.get(0));
calendarRepo.save(calendar);
}
}
else{
throw new AxelorException(String.format(I18n.get(IExceptionMessage.CALENDAR_NOT_VALID)), IException.CONFIGURATION_ERROR);
}
} catch (Exception e) {
throw new ICalendarException(e);
}
finally {
store.disconnect();
}
}
示例4: getCalendar
import org.apache.commons.httpclient.protocol.Protocol; //导入方法依赖的package包/类
public net.fortuna.ical4j.model.Calendar getCalendar(String uid, Calendar calendar) throws ICalendarException, MalformedURLException{
net.fortuna.ical4j.model.Calendar cal = null;
PathResolver RESOLVER = getPathResolver(calendar.getTypeSelect());
Protocol protocol = getProtocol(calendar.getIsSslConnection());
URL url = new URL(protocol.getScheme(), calendar.getUrl(), calendar.getPort(), "");
ICalendarStore store = new ICalendarStore(url, RESOLVER);
try {
if(store.connect(calendar.getLogin(), calendar.getPassword())){
List<CalDavCalendarCollection> colList = store.getCollections();
if(!colList.isEmpty()){
CalDavCalendarCollection collection = colList.get(0);
cal = collection.getCalendar(uid);
}
}
else{
throw new AxelorException(String.format(I18n.get(IExceptionMessage.CALENDAR_NOT_VALID)), IException.CONFIGURATION_ERROR);
}
} catch (Exception e) {
throw new ICalendarException(e);
}
finally {
store.disconnect();
}
return cal;
}
示例5: getHttpUrl
import org.apache.commons.httpclient.protocol.Protocol; //导入方法依赖的package包/类
private String getHttpUrl(String host, int port, URI uri, HttpConnection httpConnection) throws URIException {
final Protocol protocol = httpConnection.getProtocol();
if (protocol == null) {
return uri.getURI();
}
final StringBuilder sb = new StringBuilder();
final String scheme = protocol.getScheme();
sb.append(scheme).append("://");
sb.append(host);
// if port is default port number.
if (port != SKIP_DEFAULT_PORT) {
sb.append(':').append(port);
}
sb.append(uri.getURI());
return sb.toString();
}
示例6: getAbsoluteDestination
import org.apache.commons.httpclient.protocol.Protocol; //导入方法依赖的package包/类
/**
* A client of the {@link MoveMethod} can specify a destination as either an
* absolute URL (possibly to a different server), or as a absolute path on
* the same server, but this function makes sure that the path sent to the
* server is always an absolute URL.
*
* <p>Note that this function will add server and port to the request -
* however, port is not added if it is the default port for the scheme
* in question. </p>
*
* <p>This function is static so that it can be reused by the {@link CopyMethod}.
* </p>
*
* @param conn The connection for the current request, in case the caller
* specifies an absolute path.
*
* @param absolutePathOrURL If an absolute URL, nothing done, but if an absolute
* path, it is converted into an absolute URL.
*
* @return An absolute URL
*/
static String getAbsoluteDestination(HttpConnection conn, String absolutePathOrURL) {
String absoluteDestination = absolutePathOrURL;
// is this an absolute path?
if (absolutePathOrURL.startsWith("/")) {
// yes - get the protocol to start the URL with the appropriate scheme.
Protocol protocol = conn.getProtocol();
StringBuffer bufDest = new StringBuffer(protocol.getScheme());
bufDest.append("://").append(conn.getHost());
// only add in the port if it is not the default port.
if (conn.getPort() != protocol.getDefaultPort()) {
bufDest.append(':').append(conn.getPort());
}
// append the path.
bufDest.append(absolutePathOrURL);
absoluteDestination = bufDest.toString();
}
return absoluteDestination;
}
示例7: getNewProtocol
import org.apache.commons.httpclient.protocol.Protocol; //导入方法依赖的package包/类
/**
* Select a Protocol to be used for the given host, port and scheme. The
* current Protocol may be selected, if appropriate. This method need not be
* thread-safe; the caller must synchronize if necessary.
* <p/>
* This implementation returns the current Protocol if it has the given
* scheme; otherwise it returns the Protocol registered for that scheme.
*/
protected Protocol getNewProtocol(String host, int port, String scheme) {
final Protocol oldProtocol = getProtocol();
if (oldProtocol != null) {
final String oldScheme = oldProtocol.getScheme();
if (oldScheme == scheme || (oldScheme != null && oldScheme.equalsIgnoreCase(scheme))) {
// The old {rotocol has the desired scheme.
return oldProtocol; // Retain it.
}
}
return Protocol.getProtocol(scheme);
}
示例8: getNewProtocol
import org.apache.commons.httpclient.protocol.Protocol; //导入方法依赖的package包/类
/**
* Select a Protocol to be used for the given host, port and scheme. The
* current Protocol may be selected, if appropriate. This method need not be
* thread-safe; the caller must synchronize if necessary.
* <p>
* This implementation returns the current Protocol if it has the given
* scheme; otherwise it returns the Protocol registered for that scheme.
*/
protected Protocol getNewProtocol(String host, int port, String scheme)
{
final Protocol oldProtocol = getProtocol();
if (oldProtocol != null) {
final String oldScheme = oldProtocol.getScheme();
if (oldScheme == scheme || (oldScheme != null && oldScheme.equalsIgnoreCase(scheme))) {
// The old {rotocol has the desired scheme.
return oldProtocol; // Retain it.
}
}
return Protocol.getProtocol(scheme);
}
示例9: keepProtocol
import org.apache.commons.httpclient.protocol.Protocol; //导入方法依赖的package包/类
protected Protocol keepProtocol(String host, int port, String scheme) {
final Protocol oldProtocol = getProtocol();
if (oldProtocol != null) {
final String oldScheme = oldProtocol.getScheme();
if (oldScheme == scheme || (oldScheme != null && oldScheme.equalsIgnoreCase(scheme))) {
return oldProtocol;
}
}
return Protocol.getProtocol(scheme);
}
示例10: removeEventFromIcal
import org.apache.commons.httpclient.protocol.Protocol; //导入方法依赖的package包/类
public void removeEventFromIcal(Event event) throws MalformedURLException, ICalendarException{
if(event.getCalendarCrm() != null && !Strings.isNullOrEmpty(event.getUid())){
Calendar calendar = event.getCalendarCrm();
PathResolver RESOLVER = getPathResolver(calendar.getTypeSelect());
Protocol protocol = getProtocol(calendar.getIsSslConnection());
URL url = new URL(protocol.getScheme(), calendar.getUrl(), calendar.getPort(), "");
ICalendarStore store = new ICalendarStore(url, RESOLVER);
try {
if(store.connect(calendar.getLogin(), calendar.getPassword())){
List<CalDavCalendarCollection> colList = store.getCollections();
if(!colList.isEmpty()){
CalDavCalendarCollection collection = colList.get(0);
final Map<String, VEvent> remoteEvents = new HashMap<>();
for (VEvent item : ICalendarStore.getEvents(collection)) {
remoteEvents.put(item.getUid().getValue(), item);
}
VEvent target = remoteEvents.get(event.getUid());
removeCalendar(collection,target.getUid().getValue());
}
}
else{
throw new AxelorException(String.format(I18n.get(IExceptionMessage.CALENDAR_NOT_VALID)), IException.CONFIGURATION_ERROR);
}
} catch (Exception e) {
throw new ICalendarException(e);
}
finally {
store.disconnect();
}
}
}