Java源码示例:org.apache.jackrabbit.webdav.MultiStatusResponse
示例1
/**
* The PROPPATCH method
*
* @param request the HTTP request
* @param response the server's response
* @param resource the DAV resource
*
* @throws IOException generic I/O error
*/
@SuppressWarnings("rawtypes")
protected void doPropPatch(WebdavRequest request, WebdavResponse response, DavResource resource)
throws IOException, DavException {
log.debug("doPropPatch");
List changeList = request.getPropPatchChangeList();
if (changeList.isEmpty()) {
response.sendError(DavServletResponse.SC_BAD_REQUEST);
return;
}
MultiStatus ms = new MultiStatus();
MultiStatusResponse msr = resource.alterProperties(changeList);
ms.addResponse(msr);
response.sendMultiStatus(ms);
}
示例2
/**
* Build Contact instance from multistatusResponse info
*
* @param multiStatusResponse response
* @throws IOException on error
* @throws DavMailException on error
*/
public Contact(MultiStatusResponse multiStatusResponse) throws IOException, DavMailException {
setHref(URIUtil.decode(multiStatusResponse.getHref()));
DavPropertySet properties = multiStatusResponse.getProperties(HttpStatus.SC_OK);
permanentUrl = getURLPropertyIfExists(properties, "permanenturl");
etag = getPropertyIfExists(properties, "etag");
displayName = getPropertyIfExists(properties, "displayname");
for (String attributeName : CONTACT_ATTRIBUTES) {
String value = getPropertyIfExists(properties, attributeName);
if (value != null) {
if ("bday".equals(attributeName) || "anniversary".equals(attributeName)
|| "lastmodified".equals(attributeName) || "datereceived".equals(attributeName)) {
value = convertDateFromExchange(value);
} else if ("haspicture".equals(attributeName) || "private".equals(attributeName)) {
value = "1".equals(value) ? "true" : "false";
}
put(attributeName, value);
}
}
}
示例3
/**
* @inheritDoc
*/
@Override
public List<Folder> getSubFolders(String folderPath, Condition condition, boolean recursive) throws IOException {
boolean isPublic = folderPath.startsWith("/public");
FolderQueryTraversal mode = (!isPublic && recursive) ? FolderQueryTraversal.Deep : FolderQueryTraversal.Shallow;
List<Folder> folders = new ArrayList<>();
MultiStatusResponse[] responses = searchItems(folderPath, FOLDER_PROPERTIES, and(isTrue("isfolder"), isFalse("ishidden"), condition), mode, 0);
for (MultiStatusResponse response : responses) {
Folder folder = buildFolder(response);
folders.add(buildFolder(response));
if (isPublic && recursive) {
getSubFolders(folder.folderPath, condition, recursive);
}
}
return folders;
}
示例4
@Override
public List<ExchangeSession.Event> searchEvents(String folderPath, Set<String> attributes, Condition condition) throws IOException {
List<ExchangeSession.Event> events = new ArrayList<>();
MultiStatusResponse[] responses = searchItems(folderPath, attributes, and(isFalse("isfolder"), isFalse("ishidden"), condition), FolderQueryTraversal.Shallow, 0);
for (MultiStatusResponse response : responses) {
String instancetype = getPropertyIfExists(response.getProperties(HttpStatus.SC_OK), "instancetype");
Event event = new Event(response);
//noinspection VariableNotUsedInsideIf
if (instancetype == null) {
// check ics content
try {
event.getBody();
// getBody success => add event or task
events.add(event);
} catch (IOException e) {
// invalid event: exclude from list
LOGGER.warn("Invalid event " + event.displayName + " found at " + response.getHref(), e);
}
} else {
events.add(event);
}
}
return events;
}
示例5
protected void handlePropstat(XMLStreamReader reader, MultiStatusResponse multiStatusResponse) throws XMLStreamException {
int propstatStatus = 0;
while (reader.hasNext() && !XMLStreamUtil.isEndTag(reader, "propstat")) {
reader.next();
if (XMLStreamUtil.isStartTag(reader)) {
String tagLocalName = reader.getLocalName();
if ("status".equals(tagLocalName)) {
if ("HTTP/1.1 200 OK".equals(reader.getElementText())) {
propstatStatus = HttpStatus.SC_OK;
} else {
propstatStatus = 0;
}
} else if ("prop".equals(tagLocalName) && propstatStatus == HttpStatus.SC_OK) {
handleProperty(reader, multiStatusResponse);
}
}
}
}
示例6
protected void handleProperty(XMLStreamReader reader, MultiStatusResponse multiStatusResponse) throws XMLStreamException {
while (reader.hasNext() && !XMLStreamUtil.isEndTag(reader, "prop")) {
reader.next();
if (XMLStreamUtil.isStartTag(reader)) {
Namespace namespace = Namespace.getNamespace(reader.getNamespaceURI());
String tagLocalName = reader.getLocalName();
if (reader.getAttributeCount() > 0 && "mv.string".equals(reader.getAttributeValue(0))) {
handleMultiValuedProperty(reader, multiStatusResponse);
} else {
String tagContent = getTagContent(reader);
if (tagContent != null) {
multiStatusResponse.add(new DefaultDavProperty<>(tagLocalName, tagContent, namespace));
}
}
}
}
}
示例7
/**
* Build Contact instance from multistatusResponse info
*
* @param multiStatusResponse response
* @throws IOException on error
* @throws DavMailException on error
*/
public Contact(MultiStatusResponse multiStatusResponse) throws IOException, DavMailException {
setHref(URIUtil.decode(multiStatusResponse.getHref()));
DavPropertySet properties = multiStatusResponse.getProperties(HttpStatus.SC_OK);
permanentUrl = getURLPropertyIfExists(properties, "permanenturl");
etag = getPropertyIfExists(properties, "etag");
displayName = getPropertyIfExists(properties, "displayname");
for (String attributeName : CONTACT_ATTRIBUTES) {
String value = getPropertyIfExists(properties, attributeName);
if (value != null) {
if ("bday".equals(attributeName) || "anniversary".equals(attributeName)
|| "lastmodified".equals(attributeName) || "datereceived".equals(attributeName)) {
value = convertDateFromExchange(value);
} else if ("haspicture".equals(attributeName) || "private".equals(attributeName)) {
value = "1".equals(value) ? "true" : "false";
}
put(attributeName, value);
}
}
}
示例8
@Override
public List<ExchangeSession.Event> searchEvents(String folderPath, Set<String> attributes, Condition condition) throws IOException {
List<ExchangeSession.Event> events = new ArrayList<>();
MultiStatusResponse[] responses = searchItems(folderPath, attributes, and(isFalse("isfolder"), isFalse("ishidden"), condition), FolderQueryTraversal.Shallow, 0);
for (MultiStatusResponse response : responses) {
String instancetype = getPropertyIfExists(response.getProperties(HttpStatus.SC_OK), "instancetype");
Event event = new Event(response);
//noinspection VariableNotUsedInsideIf
if (instancetype == null) {
// check ics content
try {
event.getBody();
// getBody success => add event or task
events.add(event);
} catch (IOException e) {
// invalid event: exclude from list
LOGGER.warn("Invalid event " + event.displayName + " found at " + response.getHref(), e);
}
} else {
events.add(event);
}
}
return events;
}
示例9
protected void handlePropstat(XMLStreamReader reader, MultiStatusResponse multiStatusResponse) throws XMLStreamException {
int propstatStatus = 0;
while (reader.hasNext() && !XMLStreamUtil.isEndTag(reader, "propstat")) {
reader.next();
if (XMLStreamUtil.isStartTag(reader)) {
String tagLocalName = reader.getLocalName();
if ("status".equals(tagLocalName)) {
if ("HTTP/1.1 200 OK".equals(reader.getElementText())) {
propstatStatus = HttpStatus.SC_OK;
} else {
propstatStatus = 0;
}
} else if ("prop".equals(tagLocalName) && propstatStatus == HttpStatus.SC_OK) {
handleProperty(reader, multiStatusResponse);
}
}
}
}
示例10
protected void handleProperty(XMLStreamReader reader, MultiStatusResponse multiStatusResponse) throws XMLStreamException {
while (reader.hasNext() && !XMLStreamUtil.isEndTag(reader, "prop")) {
reader.next();
if (XMLStreamUtil.isStartTag(reader)) {
Namespace namespace = Namespace.getNamespace(reader.getNamespaceURI());
String tagLocalName = reader.getLocalName();
if (reader.getAttributeCount() > 0 && "mv.string".equals(reader.getAttributeValue(0))) {
handleMultiValuedProperty(reader, multiStatusResponse);
} else {
String tagContent = getTagContent(reader);
if (tagContent != null) {
multiStatusResponse.add(new DefaultDavProperty<>(tagLocalName, tagContent, namespace));
}
}
}
}
}
示例11
/**
* Execute webdav request.
*
* @param httpClient http client instance
* @param method webdav method
* @return Responses enumeration
* @throws IOException on error
*/
public static MultiStatusResponse[] executeMethod(HttpClient httpClient, DavMethodBase method) throws IOException {
MultiStatusResponse[] responses;
try {
int status = executeMethodFollowRedirectOnce(httpClient, method);
if (status != HttpStatus.SC_MULTI_STATUS) {
throw buildHttpResponseException(method);
}
responses = method.getResponseBodyAsMultiStatus().getResponses();
} catch (DavException e) {
throw new IOException(e.getMessage());
} finally {
method.releaseConnection();
}
return responses;
}
示例12
/**
* Execute webdav request.
*
* @param httpClient http client instance
* @param method webdav method
* @return Responses enumeration
* @throws IOException on error
*/
public static MultiStatusResponse[] executeMethod(HttpClient httpClient, ExchangeDavMethod method) throws IOException {
MultiStatusResponse[] responses;
try {
int status = executeMethodFollowRedirectOnce(httpClient, method);
if (status != HttpStatus.SC_MULTI_STATUS) {
throw buildHttpResponseException(method);
}
responses = method.getResponses();
} finally {
method.releaseConnection();
}
return responses;
}
示例13
public void testGetFolder() throws IOException {
ExchangeSession.Folder folder = session.getFolder("INBOX");
assertNotNull(folder);
DavPropertyNameSet davPropertyNameSet = new DavPropertyNameSet();
// davPropertyNameSet.add(Field.getPropertyName("displayname"));
//PropFindMethod propFindMethod = new PropFindMethod(URIUtil.encodePath(((DavExchangeSession)session).getFolderPath(folder.folderPath)));
//session.httpClient.executeMethod(propFindMethod);
//propFindMethod.getResponseBodyAsMultiStatus();
ExchangePropFindMethod exchangePropFindMethod = new ExchangePropFindMethod(URIUtil.encodePath(((DavExchangeSession)session).getFolderPath(folder.folderPath)), davPropertyNameSet, 0);
//PropFindMethod propFindMethod = new PropFindMethod(URIUtil.encodePath(((DavExchangeSession)session).getFolderPath(folder.folderPath)));
session.httpClient.executeMethod(exchangePropFindMethod);
MultiStatusResponse response = exchangePropFindMethod.getResponse();
DavPropertySet properties = response.getProperties(HttpStatus.SC_OK);
System.out.println(properties);
}
示例14
/**
* Retrieve all hidden items
*
* @throws IOException on error
*/
public void testAllHidden() throws IOException {
Set<String> attributes = new HashSet<>();
attributes.add("messageclass");
attributes.add("permanenturl");
attributes.add("roamingxmlstream");
attributes.add("displayname");
MultiStatusResponse[] responses = davSession.searchItems("/users/" + davSession.getEmail() + '/', attributes, davSession.and(davSession.isTrue("ishidden")), HC4DavExchangeSession.FolderQueryTraversal.Deep, 0);
for (MultiStatusResponse response : responses) {
System.out.println(response.getProperties(HttpStatus.SC_OK).get(Field.getPropertyName("messageclass")).getValue() + ": "
+ response.getProperties(HttpStatus.SC_OK).get(Field.getPropertyName("displayname")).getValue());
DavProperty<?> roamingxmlstreamProperty = response.getProperties(HttpStatus.SC_OK).get(Field.getPropertyName("roamingxmlstream"));
if (roamingxmlstreamProperty != null) {
System.out.println(new String(Base64.decodeBase64(((String) roamingxmlstreamProperty.getValue()).getBytes()), StandardCharsets.UTF_8));
}
}
}
示例15
/**
* Search in non ipm subtree
*
* @throws IOException on error
*/
public void testNonIpmSubtree() throws IOException {
Set<String> attributes = new HashSet<>();
attributes.add("messageclass");
attributes.add("permanenturl");
attributes.add("roamingxmlstream");
attributes.add("roamingdictionary");
attributes.add("displayname");
MultiStatusResponse[] responses = davSession.searchItems("/users/" + davSession.getEmail() + "/non_ipm_subtree", attributes, davSession.and(davSession.isTrue("ishidden")), HC4DavExchangeSession.FolderQueryTraversal.Deep, 0);
for (MultiStatusResponse response : responses) {
System.out.println(response.getHref() + ' ' + response.getProperties(HttpStatus.SC_OK).get(Field.getPropertyName("messageclass")).getValue() + ": "
+ response.getProperties(HttpStatus.SC_OK).get(Field.getPropertyName("displayname")).getValue());
DavProperty<?> roamingxmlstreamProperty = response.getProperties(HttpStatus.SC_OK).get(Field.getPropertyName("roamingxmlstream"));
if (roamingxmlstreamProperty != null) {
System.out.println("roamingxmlstream: " + new String(Base64.decodeBase64(((String) roamingxmlstreamProperty.getValue()).getBytes()), StandardCharsets.UTF_8));
}
DavProperty<?> roamingdictionaryProperty = response.getProperties(HttpStatus.SC_OK).get(Field.getPropertyName("roamingdictionary"));
if (roamingdictionaryProperty != null) {
System.out.println("roamingdictionary: " + new String(Base64.decodeBase64(((String) roamingdictionaryProperty.getValue()).getBytes()), StandardCharsets.UTF_8));
}
}
}
示例16
public void testReportInbox() throws IOException, DavException {
StringBuilder buffer = new StringBuilder();
buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
buffer.append("<C:calendar-query xmlns:C=\"urn:ietf:params:xml:ns:caldav\" xmlns:D=\"DAV:\">");
buffer.append("<D:prop>");
buffer.append("<C:calendar-data/>");
buffer.append("</D:prop>");
buffer.append("<C:filter>");
buffer.append("</C:filter>");
buffer.append("</C:calendar-query>");
SearchReportMethod method = new SearchReportMethod("/users/" + session.getEmail() + "/inbox/", buffer.toString());
httpClient.executeMethod(method);
assertEquals(HttpStatus.SC_MULTI_STATUS, method.getStatusCode());
MultiStatus multiStatus = method.getResponseBodyAsMultiStatus();
MultiStatusResponse[] responses = multiStatus.getResponses();
/*List<ExchangeSession.Event> events = session.searchEvents("/users/" + session.getEmail() + "/calendar/",
session.or(session.isEqualTo("instancetype", 1),
session.and(session.isEqualTo("instancetype", 0), dateCondition))
);*/
//assertEquals(events.size(), responses.length);
}
示例17
public void testReportTasks() throws IOException, DavException {
StringBuilder buffer = new StringBuilder();
buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
buffer.append("<C:calendar-query xmlns:C=\"urn:ietf:params:xml:ns:caldav\" xmlns:D=\"DAV:\">");
buffer.append("<D:prop>");
buffer.append("<C:calendar-data/>");
buffer.append("</D:prop>");
buffer.append("<C:comp-filter name=\"VCALENDAR\">");
buffer.append("<C:comp-filter name=\"VTODO\"/>");
buffer.append("</C:comp-filter>");
buffer.append("<C:filter>");
buffer.append("</C:filter>");
buffer.append("</C:calendar-query>");
SearchReportMethod method = new SearchReportMethod("/users/" + session.getEmail() + "/calendar/", buffer.toString());
httpClient.executeMethod(method);
assertEquals(HttpStatus.SC_MULTI_STATUS, method.getStatusCode());
MultiStatus multiStatus = method.getResponseBodyAsMultiStatus();
MultiStatusResponse[] responses = multiStatus.getResponses();
}
示例18
public void testReportEventsOnly() throws IOException, DavException {
StringBuilder buffer = new StringBuilder();
buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
buffer.append("<C:calendar-query xmlns:C=\"urn:ietf:params:xml:ns:caldav\" xmlns:D=\"DAV:\">");
buffer.append("<D:prop>");
buffer.append("<C:calendar-data/>");
buffer.append("</D:prop>");
buffer.append("<C:comp-filter name=\"VCALENDAR\">");
buffer.append("<C:comp-filter name=\"VEVENT\"/>");
buffer.append("</C:comp-filter>");
buffer.append("<C:filter>");
buffer.append("</C:filter>");
buffer.append("</C:calendar-query>");
SearchReportMethod method = new SearchReportMethod("/users/" + session.getEmail() + "/calendar/", buffer.toString());
httpClient.executeMethod(method);
assertEquals(HttpStatus.SC_MULTI_STATUS, method.getStatusCode());
MultiStatus multiStatus = method.getResponseBodyAsMultiStatus();
MultiStatusResponse[] responses = multiStatus.getResponses();
}
示例19
@Override
BaseDavRequest internalSyncItems() throws IOException, DavException {
//Calendar already inited.
DavPropertyNameSet properties = new DavPropertyNameSet();
properties.add(DNAME_GETCTAG);
HttpPropFindMethod method = new HttpPropFindMethod(path, properties, CalDAVConstants.DEPTH_0);
HttpResponse httpResponse = client.execute(method, context);
if (method.succeeded(httpResponse)) {
for (MultiStatusResponse response : method.getResponseBodyAsMultiStatus(httpResponse).getResponses()) {
DavPropertySet set = response.getProperties(SC_OK);
String ctag = AppointmentManager.getTokenFromProperty(set.get(DNAME_GETCTAG));
if (ctag != null && !ctag.equals(calendar.getToken())) {
EtagsHandler etagsHandler = new EtagsHandler(path, calendar, client, context, appointmentDao, utils);
etagsHandler.syncItems();
calendar.setToken(ctag);
}
}
} else {
log.error("Error executing PROPFIND Method, with status Code: {}", httpResponse.getStatusLine().getStatusCode());
}
return method;
}
示例20
/**
* Resolves the hrefs provided in the report info to resources.
*/
protected void runQuery()
throws CosmoDavException {
DavPropertyNameSet propspec = createResultPropSpec();
if (getResource() instanceof DavCollection) {
DavCollection collection = (DavCollection) getResource();
for (String href : hrefs) {
WebDavResource target = collection.findMember(href);
if (target != null) {
getMultiStatus().addResponse(buildMultiStatusResponse(target, propspec));
}
else {
getMultiStatus().addResponse(new MultiStatusResponse(href,404));
}
}
return;
}
if (getResource() instanceof DavCalendarResource) {
getMultiStatus().addResponse(buildMultiStatusResponse(getResource(), propspec));
return;
}
throw new UnprocessableEntityException(getType() + " report not supported for non-calendar resources");
}
示例21
/**
*
* @param msr
* MultiStatusResponse
* @return boolean
*/
public static boolean hasNonOK(MultiStatusResponse msr) {
if (msr == null || msr.getStatus() == null) {
return false;
}
for (Status status : msr.getStatus()) {
if (status != null) {
int statusCode = status.getStatusCode();
if (statusCode != 200) {
return true;
}
}
}
return false;
}
示例22
DavPropertySet getProperties(final URLFileName name, final int type, final DavPropertyNameSet nameSet,
final boolean addEncoding) throws FileSystemException {
try {
final String urlStr = toUrlString(name);
final PropFindMethod method = new PropFindMethod(urlStr, type, nameSet, DavConstants.DEPTH_0);
setupMethod(method);
execute(method);
if (method.succeeded()) {
final MultiStatus multiStatus = method.getResponseBodyAsMultiStatus();
final MultiStatusResponse response = multiStatus.getResponses()[0];
final DavPropertySet props = response.getProperties(HttpStatus.SC_OK);
if (addEncoding) {
final DavProperty prop = new DefaultDavProperty(RESPONSE_CHARSET, method.getResponseCharSet());
props.add(prop);
}
return props;
}
return new DavPropertySet();
} catch (final FileSystemException fse) {
throw fse;
} catch (final Exception e) {
throw new FileSystemException("vfs.provider.webdav/get-property.error", e, getName(), name, type,
nameSet.getContent(), addEncoding);
}
}
示例23
public static boolean hasNonOK(MultiStatusResponse msr) {
if (msr == null || msr.getStatus() == null) {
return false;
}
for (Status status : msr.getStatus()) {
if (status != null) {
int statusCode = status.getStatusCode();
if (statusCode != 200) {
return true;
}
}
}
return false;
}
示例24
/**
* Build Event instance from response info.
*
* @param multiStatusResponse response
* @throws IOException on error
*/
public Event(MultiStatusResponse multiStatusResponse) throws IOException {
setHref(URIUtil.decode(multiStatusResponse.getHref()));
DavPropertySet properties = multiStatusResponse.getProperties(HttpStatus.SC_OK);
permanentUrl = getURLPropertyIfExists(properties, "permanenturl");
etag = getPropertyIfExists(properties, "etag");
displayName = getPropertyIfExists(properties, "displayname");
subject = getPropertyIfExists(properties, "subject");
instancetype = getPropertyIfExists(properties, "instancetype");
contentClass = getPropertyIfExists(properties, "contentclass");
}
示例25
DavPropertySet getProperties(final GenericURLFileName name, final int type, final DavPropertyNameSet nameSet,
final boolean addEncoding) throws FileSystemException {
try {
final String urlStr = toUrlString(name);
final HttpPropfind request = new HttpPropfind(urlStr, type, nameSet, DavConstants.DEPTH_0);
setupRequest(request);
final HttpResponse res = executeRequest(request);
if (request.succeeded(res)) {
final MultiStatus multiStatus = request.getResponseBodyAsMultiStatus(res);
final MultiStatusResponse response = multiStatus.getResponses()[0];
final DavPropertySet props = response.getProperties(HttpStatus.SC_OK);
if (addEncoding) {
final ContentType resContentType = ContentType.getOrDefault(res.getEntity());
final DavProperty prop = new DefaultDavProperty(RESPONSE_CHARSET,
resContentType.getCharset().name());
props.add(prop);
}
return props;
}
return new DavPropertySet();
} catch (final FileSystemException fse) {
throw fse;
} catch (final Exception e) {
throw new FileSystemException("vfs.provider.webdav/get-property.error", e, getName(), name, type,
nameSet.getContent(), addEncoding);
}
}
示例26
/**
* @inheritDoc
*/
@Override
protected Folder internalGetFolder(String folderPath) throws IOException {
MultiStatus multiStatus = httpClientAdapter.executeDavRequest(new HttpPropfind(
URIUtil.encodePath(getFolderPath(folderPath)),
FOLDER_PROPERTIES_NAME_SET, 0));
MultiStatusResponse[] responses = multiStatus.getResponses();
Folder folder = null;
if (responses.length > 0) {
folder = buildFolder(responses[0]);
folder.folderPath = folderPath;
}
return folder;
}
示例27
protected Message buildMessage(MultiStatusResponse responseEntity) throws IOException {
Message message = new Message();
message.messageUrl = URIUtil.decode(responseEntity.getHref());
DavPropertySet properties = responseEntity.getProperties(HttpStatus.SC_OK);
message.permanentUrl = getURLPropertyIfExists(properties, "permanenturl");
message.size = getIntPropertyIfExists(properties, "messageSize");
message.uid = getPropertyIfExists(properties, "uid");
message.contentClass = getPropertyIfExists(properties, "contentclass");
message.imapUid = getLongPropertyIfExists(properties, "imapUid");
message.read = "1".equals(getPropertyIfExists(properties, "read"));
message.junk = "1".equals(getPropertyIfExists(properties, "junk"));
message.flagged = "2".equals(getPropertyIfExists(properties, "flagStatus"));
message.draft = (getIntPropertyIfExists(properties, "messageFlags") & 8) != 0;
String lastVerbExecuted = getPropertyIfExists(properties, "lastVerbExecuted");
message.answered = "102".equals(lastVerbExecuted) || "103".equals(lastVerbExecuted);
message.forwarded = "104".equals(lastVerbExecuted);
message.date = convertDateFromExchange(getPropertyIfExists(properties, "date"));
message.deleted = "1".equals(getPropertyIfExists(properties, "deleted"));
String lastmodified = convertDateFromExchange(getPropertyIfExists(properties, "lastmodified"));
message.recent = !message.read && lastmodified != null && lastmodified.equals(message.date);
message.keywords = getPropertyIfExists(properties, "keywords");
if (LOGGER.isDebugEnabled()) {
StringBuilder buffer = new StringBuilder();
buffer.append("Message");
if (message.imapUid != 0) {
buffer.append(" IMAP uid: ").append(message.imapUid);
}
if (message.uid != null) {
buffer.append(" uid: ").append(message.uid);
}
buffer.append(" href: ").append(responseEntity.getHref()).append(" permanenturl:").append(message.permanentUrl);
LOGGER.debug(buffer.toString());
}
return message;
}
示例28
@Override
public MessageList searchMessages(String folderPath, Set<String> attributes, Condition condition) throws IOException {
MessageList messages = new MessageList();
int maxCount = Settings.getIntProperty("davmail.folderSizeLimit", 0);
MultiStatusResponse[] responses = searchItems(folderPath, attributes, and(isFalse("isfolder"), isFalse("ishidden"), condition), FolderQueryTraversal.Shallow, maxCount);
for (MultiStatusResponse response : responses) {
Message message = buildMessage(response);
message.messageList = messages;
messages.add(message);
}
Collections.sort(messages);
return messages;
}
示例29
/**
* @inheritDoc
*/
@Override
public List<ExchangeSession.Contact> searchContacts(String folderPath, Set<String> attributes, Condition condition, int maxCount) throws IOException {
List<ExchangeSession.Contact> contacts = new ArrayList<>();
MultiStatusResponse[] responses = searchItems(folderPath, attributes,
and(isEqualTo("outlookmessageclass", "IPM.Contact"), isFalse("isfolder"), isFalse("ishidden"), condition),
FolderQueryTraversal.Shallow, maxCount);
for (MultiStatusResponse response : responses) {
contacts.add(new Contact(response));
}
return contacts;
}
示例30
protected MultiStatusResponse[] searchItems(String folderPath, Set<String> attributes, Condition condition,
FolderQueryTraversal folderQueryTraversal, int maxCount) throws IOException {
String folderUrl;
if (folderPath.startsWith("http")) {
folderUrl = folderPath;
} else {
folderUrl = getFolderPath(folderPath);
}
StringBuilder searchRequest = new StringBuilder();
searchRequest.append("SELECT ")
.append(Field.getRequestPropertyString("permanenturl"));
if (attributes != null) {
for (String attribute : attributes) {
searchRequest.append(',').append(Field.getRequestPropertyString(attribute));
}
}
searchRequest.append(" FROM SCOPE('").append(folderQueryTraversal).append(" TRAVERSAL OF \"").append(folderUrl).append("\"')");
if (condition != null) {
searchRequest.append(" WHERE ");
condition.appendTo(searchRequest);
}
searchRequest.append(" ORDER BY ").append(Field.getRequestPropertyString("imapUid")).append(" DESC");
DavGatewayTray.debug(new BundleMessage("LOG_SEARCH_QUERY", searchRequest));
MultiStatusResponse[] responses = httpClientAdapter.executeSearchRequest(
encodeAndFixUrl(folderUrl), searchRequest.toString(), maxCount);
DavGatewayTray.debug(new BundleMessage("LOG_SEARCH_RESULT", responses.length));
return responses;
}