}
try {
jcrTemplate.doExecuteWithSystemSession(new JCRCallback<Object>() {
public Object doInJCR(JCRSessionWrapper session) throws RepositoryException {
JCRNodeWrapper file = session.getNode(sourcePath);
JCRFileContent fileContent = file.getFileContent();
Node n = file.getRealNode().getNode(Constants.JCR_CONTENT);
String type = fileContent.getContentType();
// jcr:encoding is not mandatory
String encoding = fileContent.getEncoding();
InputStream stream = fileContent.downloadFile();
try {
Metadata metadata = new Metadata();
metadata.set(Metadata.CONTENT_TYPE, type);
if (encoding != null) {
metadata.set(Metadata.CONTENT_ENCODING, encoding);