camel-dropbox - Handle whitespace in dynamic remotePath - apache-camel

I've a problem with a quite simple use case.
search for files in dropbox folder
Choose files to load
load files from dropbox
This is how I tried it:
from("timer:start?period=60m")
//Load list of files
.to("dropbox://search?accessToken={{accessToken}}&clientIdentifier={{clientIdentifier}}&remotePath={{remotePath}}")
//Create list of files to load
.bean(FileHandlerBean.class, "prepareOperations")
.split(simple("${body}"))
//Load file from dropbox
.recipientList(simple("dropbox://get?accessToken={{accessToken}}&clientIdentifier={{clientIdentifier}}&remotePath=${body.dropBoxFilePath}"))
[...]
Normally this should work, but when the remotePath contains a filename with whitespaces like 2015-05-16 18.43.56.jpg the DropboxConfigurationValidator throws an Exception.
I tried to use the URLEncoder:
URLEncoder.encode(dbxEntry.path, "UTF-8")
But this doesn't help.
I debug the component and can see, when the DropBoxComponent get the parameters the "+" was translated back to a whitespace.
Any ideas how I can handle this?
Using the Camel Version 2.17.1

There will be a bugfix for this problem in one of the next camel releases.
Here is the Link for the Jira Ticket: [CAMEL-10334]
Then it's possible to use whitespaces in the remotePath attribute.

Related

File Polling using Pattern match in Azure Logic Apps

Using Azure Logic apps, I have a requirement to poll a network file system folder for 3 files and my processing logic should start after receiving all 3 files in the file system.
I tried recurrence with List files in folder action and checking filenames one by one in a loop, but not working properly.
Is there a file poller trigger that checks a folder for file pattern match(Ex: abc*.csv, ghi*.csv) in Logic Apps?
Suggest how to implement this scenario.
Thanks,
Sunil
I test with the inline code with a test RegExp /^test.*.txt$/g, this check if the file start with test and end with .txt. The below is my code and I test with blob action.
var text = workflowContext.actions.Get_Blob_Metadata_using_path.outputs.body.DisplayName
var regexpattern=new RegExp(/^test.*.txt$/g);
return regexpattern.exec(text)[0]
If your file name match the regexp it will return the filename.

How I can get real img file name by src in Selenium?

Using LogoImg.GetAttribute("src") I get the following scr:
https://scol.stage-next.sc.local/lspprofile/5a2e7338d6e9a927741175e2/image?id=5a2fbc98d6e9a9177c8c1592
But the real name of the file is: TestImage - 9fb0c49d-69b1-49ed-8c63-4283e405b781.jpg
If i enter the src in my browser i got the file with real name downloaded.
How can I get the real name of the file in selenium as I need it for test.
Well the task is solved by other means, i just compared the differences in src. But the responce to the question would be yet interesting.
As you are able to retrieve the src attribute as follows :
https://scol.stage-next.sc.local/lspprofile/5a2e7338d6e9a927741175e2/image?id=5a2fbc98d6e9a9177c8c1592
This is the reference to the resource stored in the Database. So it wouldn't be possible to retrive the name 9fb0c49d-69b1-49ed-8c63-4283e405b781.jpg before the file gets downloaded.
To ensure the download is completed and then to read the filename you will need to use either of the following :
glob.glob() or fnmatch :
https://stackoverflow.com/a/4296148/771848
Watchdog module to monitor changes with in a directory:
python selenium, find out when a download has completed?

SharePoint GetFolderByServerRelativeUrl /Files API not returning list of files as expected

I'm new to SharePoint and I'm having trouble with a few of the simple examples I've found and I'm not sure if there's a permission I don't have correct or if I'm not understanding this properly.
when I use a browser to access my URL:
https://mysite.com/_api/web/GetFolderByServerRelativeUrl('/SCF/Shared%20Documents/FY%202014%20Memos')
part of the return xml says there are 87 items <d:ItemCount m:type="Edm.Int32">87</d:ItemCount>, which does correctly correlate to the number of files inside this folder.
Here's where I get confused. When I use the following to show the contents of the folder, I don't get any of the file information listed in the result xml like I would expect:
https://mysite.com/_api/web/GetFolderByServerRelativeUrl('/SCF/Shared%20Documents/FY%202014%20Memos')/Files
I've also tried the following to get specific file info, but I get a file not found message:
https://mysite.com/_api/web/GetFolderByServerRelativeUrl('/SCF/Shared%20Documents/FY%202014%20Memos/096.pdf')
Am I missing something simple?
This behavior occurs since the incorrect context of web for SP.Web.getFolderByServerRelativeUrl Method is specified in REST query:
https://[server]/[web]/_api/web/GetFolderByServerRelativeUrl('/[web]/[library]/[folder]')
|
web site from which Folder/Files are retrieved
Assume the following site structure:
/ News web (root)
|
Archive sub web
|
Documents library
|
2008 Folder
Then the following REST query:
https://[server]/archive/_api/web/GetFolderByServerRelativeUrl('/archive/Documents/2008')/Files
or
https://[server]/archive/_api/web/GetFolderByServerRelativeUrl('Documents/2008')/Files
will return the files located in 2008 folder of Documents library under Archive sub site.
believe it or not, my problem was sending the parameter with double quote instead of single quote
good:
https://[server]/[web]/_api/web/GetFolderByServerRelativeUrl('/[web]/[library]/[folder]')
bad:
https://[server]/[web]/_api/web/GetFolderByServerRelativeUrl("/[web]/[library]/[folder]")

Loading uncompressed js file in debug mode

Joomla has a feature where it loads the a minified javascript file and the uncompressed version when the site is in debug mode.
I have named both my files correctly and am include it as follows:
JHtml::_('script', JUri::root() . 'path_to_file/jquery-sortable.js');
When I put the site in debug mode, it does not load the uncompressed file.
However, If I use the following instead, it works fine:
JHtml::_('script', 'path_to_file/jquery-sortable.js');
Now I'm not sure whether this is a bug in Joomla or not, but I cannot find any information online regarding this. I would like to use JURI::root() in the path.
Does anyone have any information on this?
Indeed, if the script URL begins with http, the code that is responsible for including the uncompressed version (i.e, remove the min. segment if such exists or add -uncompressed otherwise) is ignored.
The source for this behavior:
JHtml::includeRelativeFiles() in libraries/cms/html/html.php:298
protected static function includeRelativeFiles($folder, $file, $relative, $detect_browser, $detect_debug)
{
// If http is present in filename
if (strpos($file, 'http') === 0)
{
$includes = array($file);
}
else
//process the script sourch.
}
...
}
Most of the script files, including frameworks, are included as relative paths. I guess that this behavior is meant to prevent remote resources from getting 404ed.

Correct way in CakePHP 1.3 to create zip file and download without leaving view

I just upgraded from cakephp 1.1 to 1.3. I have everything on the site updated and working great, except for creating and downloading zip files.
Here is the code in my accounts_controller.php:
function zip() {
$this->checkSession();
$this->checkUpgradedAccount();
$files = array();
$this->layout="zip";
/*
code where I locate the files to zip, combine them, etc
*/
$tmp_file = "/home/[userdirectory]/tmp/".md5(mktime()).".zip"; //directory name edited
$command = "/usr/bin/zip -j $tmp_file ".implode(" ",$zip_files);
exec($command);
foreach($zip_files as $zf) {
unlink($zf);
}
$file_path = $tmp_file;
$this->set("path",$file_path);
$this->render();
}
When I call this action, however, I get an error:
Error: The requested address '/accounts/zip' was not found on this
server.
It worked just like this in version 1.1. I'm assuming something has changed, but I'm not sure what, and was unable to find anything pertinent in the documentation.
The zip.ctp view file does exists, but it has nothing in it other than: <?php ?>
I suspect something is different with layouts. There is NO "zip.ctp" in the /layouts directory. However, I have changed that line to $this->layout('default'); and it renders a blank page with NO ERROR, but also with no download.
Please direct me on the proper way to download my zip file in cake 1.3. Thanks in advance.
You have two different problems here. That error you're getting is because you don't have a zip layout file. As for your problem with getting the zip file, you should be using the media view class - http://book.cakephp.org/1.3/en/The-Manual/Developing-with-CakePHP/Views.html#media-views

Resources