You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by Guillaume Lucazeau <gl...@gmail.com> on 2016/08/01 14:50:02 UTC
Custom installer: watch for data files to transform them in resources
Hello,
I'm trying to provided a tool to perform bulk updates on our content.
Following the Command pattern, a core bundle would handle commands (delete
nodes, update properties, import content etc.) provided by different
command bundles.
I was thinking I could upload JSON files in a watched folder, containings
information for the command (type, root path, data to update etc.) and that
a service could read them, and create "tasks" resources, that later my
command consumer would handle.
Is extending the OSGIInstaller a good way to achieve that? Are there
somewhere examples of custom installer, beside the Sling site documentation?
Thank you
Regards,
Guillaume
Re: Custom installer: watch for data files to transform them in resources
Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi Guillaume,
On Sun, Aug 14, 2016 at 9:13 PM, Guillaume Lucazeau <gl...@gmail.com> wrote:
> ...FileAlterationObserver was actually a good
> suggestion, very easy to use and did just what I needed,...
Great! Good to know it worked for you and thanks for the feedback.
-Bertrand
Re: Custom installer: watch for data files to transform them in resources
Posted by Guillaume Lucazeau <gl...@gmail.com>.
Hello Bertrand,
Thank you for your reply, FileAlterationObserver was actually a good
suggestion, very easy to use and did just what I needed, I didn't know this
tool.
Thank you again
Best regards,
Guillaume
On Tue, Aug 2, 2016 at 8:50 AM, Bertrand Delacretaz <bd...@apache.org>
wrote:
> Hi Guillaume,
>
> On Mon, Aug 1, 2016 at 4:50 PM, Guillaume Lucazeau <gl...@gmail.com>
> wrote:
> > ...I was thinking I could upload JSON files in a watched folder,
> containings
> > information for the command (type, root path, data to update etc.) and
> that
> > a service could read them, and create "tasks" resources, that later my
> > command consumer would handle....
>
> The OSGi Installer does something similar but it's really about
> installing and removing things, in your case I assume once a command
> is executed you don't want to keep track of it anymore so not sure if
> it's a good model. Writing an adapter (for a specific file extension
> for example) shouldn't be hard however, if you want to try this
> approach.
>
> OTOH the file system provider for the Installer does a lot of what you
> need and you might be able to adapt its code, but in the meantime I
> suspect commons IO's FileAlterationObserver. [1] would work for you
> without having to write much code.
>
> -Bertrand
>
> [1] https://commons.apache.org/proper/commons-io/javadocs/
> api-2.4/org/apache/commons/io/monitor/FileAlterationObserver.html
>
Re: Custom installer: watch for data files to transform them in resources
Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi Guillaume,
On Mon, Aug 1, 2016 at 4:50 PM, Guillaume Lucazeau <gl...@gmail.com> wrote:
> ...I was thinking I could upload JSON files in a watched folder, containings
> information for the command (type, root path, data to update etc.) and that
> a service could read them, and create "tasks" resources, that later my
> command consumer would handle....
The OSGi Installer does something similar but it's really about
installing and removing things, in your case I assume once a command
is executed you don't want to keep track of it anymore so not sure if
it's a good model. Writing an adapter (for a specific file extension
for example) shouldn't be hard however, if you want to try this
approach.
OTOH the file system provider for the Installer does a lot of what you
need and you might be able to adapt its code, but in the meantime I
suspect commons IO's FileAlterationObserver. [1] would work for you
without having to write much code.
-Bertrand
[1] https://commons.apache.org/proper/commons-io/javadocs/api-2.4/org/apache/commons/io/monitor/FileAlterationObserver.html