Changing directory from home to root in camel-ftp - apache-camel

I am using the following in my Apache Camel configuration:
<camel:route errorHandlerRef="loggingErrorHandler" id="ROUTE_ICL">
<camel:from uri="file:{{camel.route.icl.from.file.path}}?filter=#fileFilterMAVRO&initialDelay={{camel.route.from.file.initialDelay}}&delay={{camel.route.from.file.delay}}&useFixedDelay=true&runLoggingLevel=TRACE&startingDirectoryMustExist={{camel.route.from.file.startingDirectoryMustExist}}&autoCreate={{camel.route.from.file.autoCreate}}&maxMessagesPerPoll={{camel.route.from.file.maxMessagesPerPoll}}&eagerMaxMessagesPerPoll=true&delete=false&readLock=idempotent&readLockLoggingLevel=OFF&readLockRemoveOnRollback=false&readLockRemoveOnCommit=false&idempotent=true&idempotentKey=${file:onlyname}&idempotentRepository=#iclMessageIdRepository&recursive=false&move={{camel.route.icl.complete.file.path}}&moveFailed={{camel.route.icl.failed.file.path}}" />
<camel:to uri="sftp://user1#ecomt199.qintra.com:22/nas/tst2/inputfiles?password=Pass1234&runLoggingLevel=TRACE"/>
</camel:route>
Now, this is working. It is able to sftp my file.
Problem is I want my file to be at: /nas/tst2/inputfiles. But it is going at: /home/user1/nas/tst2/inputfiles
Now, how can I make it for going it at /nas/tst2/inputfiles? /nas/ and /home/ both are on <root>/.
The problem is changing this default /home/.
Which attribute can I use? I am not able to find or understand how to do it in Camel DSL.

Camel indeed doesn't allow fully qualified paths in the current version. However, as long as the user has the privileges, you could use a path like this as a workaround:
../../../../../../../../this_is_the_root_folder/usr/....
You basically start with the user's directory and then go up in the tree until you reach root. You only need to make sure that you added enough ../../ to get to the root.
It is not the nicest solution, but it is simple and worked for me.

You can't. The current camel-ftp implementation specifically does not allow fully qualified paths. All paths are relative to the user's home directory.
To get around this for my project I forked the component and removed the code that strips the leading path separator character.

I don't think the best solution is in the Camel DSL. The user you use for SFTP has its root in the home directory.
I think a good solution is to configure another user in the FTP server with the correct root directory, where you want to put your files.

Related

How to configure retrieving folder once when camel start?

My requirement as below,
Starting camel,then processing all of the files with file component ,which is located some folder once.this route is just used once.
So how to configure with spring DSL?
Thanks advance.
Split your requirement as follow
Starting camel
Your research item, cover this will be off-topic in stackoverflow
processing all of the files with file component
Use file component by from, i.e. from("file://...")
is located some folder once
Set a proper parent directory and then use recursive option in file component to enable sub-directories lookup. For further control, you may check following options minDepth, maxDepth, filterDirectory, filter
this route is just used once
Use repeatCount option in file component to control fire count, i.e. repeatCount=1
Combine them together, you have
from("file://path/to/parent/directory?repeatCount=1&recursive=true")
... // follow by your route logic

Hosting Apple verification file with NextJS

I'm using NextJS.
As per here, I need to host a file on my app.
Specifically, it needs to be hosted at:
https://app.blah.com/.well-known/apple-developer-merchantid-domain-association
What is the best way to serve this file from that folder? The URL has to be exactly as above.
When I try and put it in a folder at top level called .well-known, it doesn't work. I suspect because it's not being served when the app is actually built.
Conversely, localhost/static/apple-developer-merchantid-domain-association works fine if I put the file in there.
So, how can I do what I need to do here?
Anything in Next.js public folder will become accessible at root. So put the file in /public/.well-known/apple-developer-merchantid-domain-association and it will be accessible at yourdomain.com/.well-known/apple-developer-merchantid-domain-association.

Apache Camel File component base path

How do I manage to configure the File component of my Camel Context, so that all directory paths provided to its endpoints are prepended with some base path?
For example, if someone writes
file:input/customer12?include=.*\.csv
it will effectively be
file:/usr/local/share/app/exchange/input/customer12?include=.*\.csv
For example, I get the component during the Camel Context initialization like this:
FileComponent file = CAMELCONTEXT.getComponent("file", FileComponent.class);
What do I do next? createComponentConfiguration()?
addition: It's a standalone cli app which I want to be runnable from any directory
The easiest solution is start your app under folder /usr/local/share/app/exchange , but this is not an option as state in addition requirement
If you have a layer between your user input and your code, then you could inject the path. For example, Java DSL with RouteBuilder.
The last solution is override Camel's file component in component class before it create the actual endpoint.

Getting Filename without extension : camel

I have header with filename with extension like this
<setHeader>
<simple>Test.txt</simple>
</setHeader>
I need to fetch only filename ie. Test alone in another header. Can anyone help me to achieve this.
Thanks.
You have multiple options. The examples take the full filename from a header and write the filename without extension into another header.
You write a Java Bean to use full Java power (for example Apache Commons FilenameUtils.getBaseName) and call it from your route. See this Camel documentation how to inject header values into your bean methods. In the route you call the bean like this
.setHeader("filename", method(beanReference, "methodName"))
Or you add camel-groovy to your dependencies to get more scripting power than with Camel Simple. Then you can do it directly in the Camel route
setHeader("filename").groovy("request.headers.get('fullFilename')
.take(request.headers.get('fullFilename').lastIndexOf('.'))")

cakephp alias url

The url structure of my cakephp based site is mysite/cakephp/myapp/index.php/controller/action/input_paramaters
I cannot remove index.php from my url, as I dont have access to httpd.conf file.
Anyways, my question is that I just need to change the url of my homepage to something like http://mysite or mysite/myapp
How would I do that?
Thanks a lot!!
The problem sounds to me that you don't have mod_rewrite enabled or Apache AllowOverwrite is not set properly.
If you don't have mod_rewrite then you cannot change the urls with the pretty ones (provided from CakePHP).
If the AllowOverwrite is not set to On. Then even if you have mod_rewrite enabled, the .htaccess files in your directories doesn't take effect.
I don't know which is worst. Speak with your hosting provider and ask for help.
It is not really clear to me which part of the URL changes. CakePHP routing applies only relative from the cake directory. So if you move from http://example.com/foo to http://www.example.org/bar nothing needs to be changed in Cake.
However you might have hardcoded some img/CSS/JS URL-s that needs some work now. I also use the HTML base tag so my app works perfectly fine under various base URL-s.

Resources