How do I browse a jackrabbit repository using a spring-mvc webapp?
How do I map incoming URL requests in the spring web controllers to nodes in the repository? I'd like the users to be able to open a word document in OpenOffice or Word by opening a URL like the following and save back to it via webdav.
http://localhost:8080/my-app/my-doc.doc
Thanks in advance for any ideas.
Éamonn
the Jackrabbit Repository and the associated JSR standard for Java Content Repositories alone provides a fairly low level persistency API, which you could probably use to build Repositories for Domain objects, mapping the data to repository structures such as JCR nodes/properties. You will use the JCR API located at the javax.jcr.* package to manipulate the repository (and for maximum portability). In a sentence, you can use Jackrabbit to replace your database.
A quick google search showed that there are indeed projects that aim to provide similar convenience wrappers to the ones you probably know and love for JDBC and Hibernate, only for JCRs. I found for example the Spring Modules project: http://java.net/projects/springmodules/ which was unfortunately last updated about two years ago, so it is still on JCR 1.0. For sample usage take a look at http://java.net/projects/springmodules/sources/svn/content/trunk/samples/jcr/src/org/springmodules/examples/jcr/JcrService.java?rev=2110
Still, you could probably write your own JCR2Template without a lot of effort, and encapsulate the repetitive tasks such as connection and exception handing by using the Template Method pattern.
So as for the request mapping, you can run the JCR on a separate server, just like you would with a relational database, and connect to it via RMI. Here's an example: http://dev.day.com/content/docs/en/crx/current/developing/accessing_jcr_connectors.html
I would consider this the "clean" way to use a JCR in Spring MVC applications.
As for the WebDAV saving part... I know Jackrabbit does indeed support the mounting of Repositories as WebDAV drives, but I don't really have any experience with it and I honestly can't imagine a way to tell Word to upload a file upon edit somewhere... But I am not a Word expert at all, sorry....
Now ... the Apache Sling Framework on the other hand provides an interesting approach to build RESTful applications, that integrate well with the repository model and some higher level abstractions of the Repository structure. The way Servlets are resolved in Sling, however is completely different from plain Spring MVC (see http://dev.day.com/content/ddc/blog/2008/07/cheatsheet/_jcr_content/par/download/file), so it would a bit of work to reconcile both approaches.
Hope there's some info in there you can use.
Cheers,
Johannes
Related
I want to share the pact file from consumer to bitbucket and then provider can use from the same location.
Does anybody implemented this?
Thanks in advance.
It's worth noting that it's very much a non-standard way of doing it and I would highly recommend you don't do it this way (see https://docs.pact.io/pact_nirvana/step_4/). You're going to have to build a lot of the workflows again, and that will require investment in building tooling and coming up with ideas to evolve the contract. At some point, you'll be rebuilding key features the Pact Broker already has and would be better off just running that or using a hosted service like pactflow.io.
So, without a pact broker, you don't get the can-i-deploy tool, versioning, environment management and all of these powerful workflows.
With that said - if you do want to use bitbucket:
you'll need to create a manual process (i.e. script) to upload (from consumer) and download (provider) from bitbucket
You'll only want to upload from CI, so that's easier to control
For provider verification, you really want to do this on a laptop, so you'll need a standard approach for pulling down the correct contract to verify there and on CI. Every team member will need credentials to read from that repo
Pact doesn't have a mechanism to pull from git protocols, but you could potentially add that feature to the languages you need them for
can any one explain java callout a little help will do.Actually i am having several doubts regarding where to add the expressions and message flow jar and where to add my custom jar.
Can i access the resources/java folder directly and can i use it to store my data?
First, check the docs on apigee at
Customize an API using Java
http://apigee.com/docs/api-services/content/customize-api-using-java
Keep in mind Java Callouts are only supported in the paid, Apigee Edge product, not the free Developer platform.
As you decide how to use Java, you should consider this basic hierarchy of policy management:
Policy Configuration First: Apigee policy configurations are in broad use and therefore tested daily by clients and most performant.
Javascript Callout: For stuff you can't do in a standard policy there is Javascript -- keep in mind this is "Compiled Javascript" which means at the time you deploy your project the JS gets interpreted by the Java Rhino engine and then runs like native code. Very fast, very scalable, and very easy to manage as your code is all in plain text files.
Java: You have to have a pretty compelling reason to use Java. Most common cases are where you have some complex connection that needs to be negotiated with custom encryption schemas or manipulating binary content. While perfomant, it's the most difficult code to manage (you upload compiled jars, so if someone takes over your work, the source code is in a separate place than your deployment bundle), and it's the most difficult to debug in the event of a failure.
To your specific question: All Apigee variables are available in Java and Java gives you pretty much god-like powers on the local server where the code is executed. Keep in mind, Apigee's physical architecture is distributed -- your jar may run on different servers for different API calls, so any persistent data (that you might want to store locally) should really be put into Key Value Map and read as needed. Keep your API development as stateless as possible.
Hope that helps.
I am new to Alfresco.
Am working for a project which uses Alfresco as the document repository.
There is a requirement to create some approval workflow for the documents.
We are still in doubt on using the Activiti in Alfresco for implementation
If you guys can help me out with the following questions, it will be very much helpful in making the decision
1) The rules for approval will be changing dynamically. Could the rule engine like drools be integrated with Activiti in alfresco?
And if yes , then how?
2) The task created has to be shown in an external application.
How feasible it is to query the alfresco database from an external application? Could SQL be used for it, or we need to relay on API's for this.??
3) How could I check the database schema of the Activiti in Alfresco?
4) If the rules file could be used for decision making, could these rules file be changed dynamically from the external application. And if yes, how?
These questions may sound very silly but they are eating my head out.
Please help
Thanks,
Abhishek
If you want to write some applications using Activiti also outside of Alfresco, I think you should go toward using Activiti standalone, and probably integrate it with Alfresco just when you need to upload documents to repository or things like that. Level of Alfresco and Activiti integration is quite deep.
AD 2,3) If you really want to access Activiti tables not using Alfresco API's, yes, it's possible. The tables in database are just the same as mentioned in Activiti documentation (http://www.activiti.org/userguide/#database.tables.explained)
1) Although the bpm is a fork of drools, I don't think Alfresco has native support to that. But still, I'm not quite sure about that. We always used jbpm or activiti.
2) You should use Alfresco workflow API's to achieve what you want. At least is the correct and highly recommended way in developing workflows in Alfresco.
3) You could do that by opening the activit-engine in the Alfresco package. Inside you should find a file named activiti.mysql.create.sql. That could help you somehow. If you follow this link you could also find some interesting commands to debug Alfreco and Activiti tables
4) Define rules file, please. If you're talking about modifying activiti workflow files, no, that is should't be done once deployed. If you're talking about ending tasks or taking actions in workflow, you should use API's for that.
Not sure about embedding drools, but you have two types of code based tasks in Activiti - a script task and a service task. Script tasks are probably easier as they are javascript by default but you can also load other script engines like groovy if you need to. Service tasks are java classes that need to be deployed into the Alfresco classpath to be used.
I would definitely stick to the APIs as was mentioned
Alch3mi5t answered this, but again I would steer clear
I would use a service task for this as you could call out from your java code into another system.
If you use Activiti explorer to add a service task to a diagram, you'll notice a property called 'Service class' which is relevant when the selected type is 'java class'. You would put here the fully qualified class name, e.g. org.example.activiti.CustomLogic This has to implement one of a couple of interfaces, such as ActivityBehavior, ActivityExecution or DelegateExecution. This interface requires you to create an execute() method in which you can put your logic and any external callouts.
To deploy, compile it into a jar (in eclipse, 'Create deployment artefacts') and deploy the jar to Alfresco's classpath, e.g. webapps/alfresco/WEB-INF/lib then restart alfresco
According to the Activiti documentation you can use drools rules on a "Business Rule" task
A Business Rule task is used to synchronously execute one or more rules. Activiti uses Drools Expert, the Drools rule engine to execute business rules. Currently, the .drl files containing the business rules have to be deployed together with the process definition that defines a business rule task to execute those rules. This means that all .drl files that are used in a process have to be packaged in the process BAR file like for example the task forms
We are going to build custom workflow solution to our clients and most of the time we need to integrate it to their existing system predominately using Microsoft technologies e.g. Exchange Server and SharePoint.
Clients are expecting use workflow to computerize tasks from HR processes, product inventory management. They may or may not have their own CRM but some of them may already using Sharepoint for some processes and they are willing to move away if we can offer a more robust, flexible and economical solution.
I found Alfresco and Activiti very promising but not sure which should I adopt. From my research Alfresco is a full blown CRM with Cloud and workflow (using Activiti as engine) whereas Activiti is the engine on its own.
How should I judge when to go for Alfresco and likewise for Activiti?
TIA
Alfresco is, first and foremost, a repository. If you need a place to store files (either end-users storing files or applications storing files) you should consider using Alfresco as your repository for those files.
As you point out, Alfresco has embedded the Activiti workflow engine. This includes an abstracted service layer that wraps the engine so that, for many operations, when working with Java or server-side JavaScript, you don't need to know much about Activiti. (Obviously you do need to know how to define BPMN 2.0 process definitions to create the workflow).
So if you need to store files and you need to route those files in a business process, Alfresco's embedded workflow engine makes it very easy to do that.
If your primary use case is more general than that (ie, you don't always need to route files in a business process) then you may want to consider a standalone workflow engine. Alfresco can still participate in those workflows, of course, but if your primary use case isn't about files, why go to the trouble of setting up and maintaining a document repository?
In the end, there is no hard and fast rule here. The beauty is that both Alfresco and Activiti are open source. You can try them out, dig into the details, and decide for yourself what is the best fit.
Let me start off by stating that I am a novice developer, so please excuse the elementary nature of my question(s).
I am currently working on a Flex Application, and am getting more and more confused about when to use server side scripting, and when to develop web services. For most of the functionality I am working on, I am taking various files from the user (client), uploading to the server for processing/conversion, then sending back to client in new format.
I am accomplishing most of this using asp.net generic handlers (ashx) files, but not very confident this is best practice. But at the same time, does making web services make any more sense? What would be considered best practice for this? Any suggestions would be greatly appreciated.
The way I look at it is as follows:
Web Services mean Established Best Practice.
For most of our development, we don't need to create "Web Services", or what I'm thinking when I think REST, SOAP, and the Twitter API. You only need to start doing that once you've got something you're going to be using every day for years.
Clean and DRY code will Lead you to Creating a Web Service
If you spend the time to clearly define the parts of your upload-process-render Architecture, and you find that it can be applied to almost everything you are doing, then all you need to do to make it a Web Service is define a clear, 1-2-3 set of rules for using the system (GET/POST data, etc.). As long as you are consciously building an architecture the whole way, you'll end up creating a Web Service if it's worthy. Otherwise there's no need.
It sounds like you have a clear workflow going, I don't know anything about asp.net though.
As far as it being confusing sometimes, and best practices, I suggest the following:
Create a Flex Library Project for your "generic ashx file handling" Flex classes. Give it a cool, simple name.
Create a .NET Library Project that encapsulates all the logic for your server-side file processing. Host it online and make it open source. I recommend github. Test it as you go, and document it, its purpose and the theory behind it.
If you don't have to do anymore work at this point, and it's just plug and chug, then you've probably arrived at something that might become a Web Service, though that's probably a few years down the road.
I don't think you should try to create a Web Service right off the bat. Just make some clean and reusable code, make a few examples, get it online and open source, have others contribute and give feedback, and if it solves a specific problem, then make it a web service. You can just use REST for now probably, and build your system around that. RestfulX is a great library for that.
Best,
Lance
making web services without any sense make no sense ;)
Now in the world of FLEX as3 with flash version 10, you can easily read local files, modify them with whatever modifcation algorithm and save local files without pinging server.
You only have to use webservices if you want to get some server data or to send some data to server. that's all.
RSTanvir
Flash / Flex uses a simple HTTP POST approach for file uploads, so trying to do that using SOAP web services will be problematic. Your approach of using ASHX here sounds reasonable to me.
To send / receive data that isn't file based (e.g. a list of files the user has uploaded previously), I would recommend looking at the open source Fluorine FX library. Fluorine uses AMF which is a highly performant way of doing data transfer with Flash. It's also purely configuration-based, which means you don't need to code against any of its APIs, just configure Fluorine to expose your .NET service classes. You could easily add attributes to those same classes to expose them as SOAP web services via WCF if you need that in the future. I would not recommend using SOAP with Flex however, due to the performance losses and also because the Flex implementation of SOAP has a history of bugs and interoperability problems.