AbderaClient abderaClient = new AbderaClient(abdera);
final Factory factory = abdera.getFactory();
boolean isCollection = resource instanceof Collection;
ExtensibleElement element;
if (isCollection) {
Feed feed = factory.newFeed();
feed.setId(baseURI + APPConstants.ATOM + encodeURL(suggestedPath));
// feed.setId(encodeURL(suggestedPath));
feed.setTitle(suggestedPath);
feed.setSubtitle(resource.getDescription());
feed.addAuthor(username);
feed.setUpdated(new Date());
element = feed;
} else {
Entry entry = factory.newEntry();
entry.setId(baseURI + APPConstants.ATOM + encodeURL(suggestedPath));
// entry.setId(encodeURL(suggestedPath));
entry.setTitle(suggestedPath);
entry.setSummary(resource.getDescription());
entry.addAuthor(username);
entry.setUpdated(new Date());
Object content = resource.getContent();
if (content != null && content instanceof byte[]) {
ByteArrayInputStream in = new ByteArrayInputStream((byte[]) content);
entry.setContent(in);
} else if (content instanceof InputStream) {
entry.setContent((InputStream) content);
} else {
entry.setContent((String) content);
}
element = entry;
}
java.util.Properties properties = resource.getProperties();
addPropertyExtensionElement(properties, factory, element,
PropertyExtensionFactory.PROPERTIES,
PropertyExtensionFactory.PROPERTY);
final String mediaType = resource.getMediaType();
if (mediaType != null && mediaType.length() > 0) {
element.addSimpleExtension(new QName(APPConstants.NAMESPACE, "mediaType"), mediaType);
}
element.addSimpleExtension(new QName(APPConstants.NAMESPACE, "parentPath"),
resource.getParentPath());
if (((ResourceImpl) resource).isContentModified()) {
element.addSimpleExtension(new QName(APPConstants.NAMESPACE, "contentModified"),
"true");
}
RequestOptions requestOptions = getAuthorization();
requestOptions.setSlug(relativePath);