// If the URL ends with default.aspx, the container type should be SITE.
container.setType(ContainerType.SITE);
} else {
container.setType(ContainerType.LIST);
}
final AuthData authData = new AuthData();
authData.setContainer(container);
boolean isAttachment = false;
try {
Integer.parseInt(DocID);
authData.setType(EntityType.LISTITEM);
} catch (final Exception e) {
if (URL.endsWith(SPConstants.DEFAULT_SITE_LANDING_PAGE)) {
authData.setType(EntityType.SITE);
} else {
if (!URL.endsWith(SPConstants.ASPX)) {
authData.setType(EntityType.LISTITEM);
} else {
authData.setType(EntityType.LIST);
}
}
}
// Fix me: Get the details of Attachments and Alert URLs in case of
// Meta and URL feed mode and find away to get required information
// to authorize.
if (FeedType.CONTENT_FEED == sharepointClientContext.getFeedType()) {
final Matcher match = SPConstants.ATTACHMENT_SUFFIX_PATTERN.matcher(URL);
if (match.find()) {
URL = match.group(2);
isAttachment = true;
} else if (URL.startsWith(SPConstants.ALERT_SUFFIX_IN_DOCID)) {
URL = URL.substring(SPConstants.ALERT_SUFFIX_IN_DOCID.length());
if (URL.endsWith("_" + SPConstants.ALERTS_TYPE)) {
URL = URL.substring(0, URL.length()
- (1 + SPConstants.ALERTS_TYPE.length()));
}
container.setType(ContainerType.SITE);
authData.setType(EntityType.ALERT);
}
} else {
Matcher match = SPConstants.ATTACHMENT_URL_PATTERN.matcher(URL);
if (match.find()) {
isAttachment = true;
DocID = match.group(2);
URL = match.group(1) + "/AllItems.aspx";
container.setType(ContainerType.LIST);
authData.setType(EntityType.LISTITEM);
} else if (complexDocId.contains(SPConstants.ALERTS_EQUALTO)) {
DocID = DocID.substring(4, DocID.indexOf("}"));
URL = URL.substring(0, URL.indexOf("_layouts"));
container.setType(ContainerType.SITE);
authData.setType(EntityType.ALERT);
}
}
container.setUrl(URL);
if (isAttachment) {
AttachmentKey attachmentKey = new AttachmentKey(URL, DocID);
if (attachments.containsKey(attachmentKey)) {
attachments.get(attachmentKey).add(originalComplexDocId);
return null;
} else {
attachments.put(attachmentKey, new LinkedList<String>());
}
}
authData.setItemId(DocID);
authData.setComplexDocId(originalComplexDocId);
return authData;
}