String ext = null;
if (dot > -1) {
ext = name.substring(dot + 1); // add one for the dot!
}
if (StringUtil.isEmpty(ext)) {
throw new FacesExceptionEx(new NullPointerException(), "Extension of file being uploaded may not be null");
}
if (authBean != null && !authBean.isAuthenticated()) {
authBean.authenticate(false);
}
InputStream is = null;
try {
is = new FileInputStream(serverFile);
ContentStream contentFile = new ContentStream(is,serverFile.length(), name);
SmartCloudService svc = new SmartCloudService(authBean);
svc.post(SERVICE_URL, params, contentFile);
} catch (ClientServicesException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally {
if(is != null)
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} catch (ClientServicesException e) {
throw new FacesExceptionEx(e);
}
}