• Post Reply Bookmark Topic Watch Topic
  • New Topic

modeshape  RSS feed

 
Dass Leyo Antoniraj
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
I'm new to modeshape and i try to use the web service api proposed by this tool.
i could not interpret the syntax.

i need help
https://docs.jboss.org/author/display/MODE40/Using+Repositories+with+WebDAV+in+EAP#UsingRepositorieswithWebDAVinEAP-ConfiguringtheModeShapeWebDAVServer


regards,
Antoni
 
Stephan van Hulst
Saloon Keeper
Posts: 7964
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Antoni,

This is not really telling us much. What API are you trying to use? What about it exactly don't you understand? What exactly is it that you're trying to do in your application?

TellTheDetails.
 
Dass Leyo Antoniraj
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello Stephan,

First of all i would like to know whether an API exists to Retrieve a list of available nodes in a give workspace?

Second how to interpret the syntax: http://<host>:<port>/<context>;
What is <context>?
In the documentation they mention a Reponse format: Does this mean I should change the config.json file ?

Similarly to create a node: http://<host>:<port>/<context>/<repository_name>/<workspace_name>/items/<node_path>;
"http://localhost:8080/modeshape-rest/Persisted_Repository" this is my uri !!!

What does the URI parameters stands for:
<context>
<workspace_name>
<node_path>

Here is the link for the URL syntax.

Is there any example for each of above cases?

badly needing help on create ; delete update and query ?

my config json :
{
"name" : "Persisted_Repository",
"workspaces" : {
"predefined" : ["otherWorkspace"],
"default" : "default",
"allowCreation" : true
},
"security" : {
"anonymous" : {
"roles" : ["readonly","readwrite","admin"],
"useOnFailedLogin" : false
}
},
"storage" : {
"cacheConfiguration" : "infinispan_configuration.xml",
"cacheName" : "Persisted_Repository",
"binaryStorage" : {
"type" : "file",
"directory": "target/content/binaries",
"minimumBinarySizeInBytes" : 4096
}
},

"query":{
"enabled":true,
"rebuildUponStartup":"if_missing",
"indexStorage": {
"type":"filesystem",
"location":"target/content/index",
"lockingStrategy":"simple",
"fileSystemAccessType":"auto"
}

},

}


advanve thanks !!!
 
Dass Leyo Antoniraj
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello stephan,
i try to produce a frontend. like a directory in windows
so i create a node of type nt:folder and add childe nodes of type nt:file and attach the contents to nt;files.

i dont know to do it

advance thanks !!!

regards
Antoni
 
Stephan van Hulst
Saloon Keeper
Posts: 7964
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, if you're going to write a client, you need a server to send the requests to. ModeShape comes with a war that you can deploy in a servlet container, such as TomCat. Java web applications have a context, which essentially is the configuration of your application.

Another way to understand this is that since a server can host multiple web applications, the context path can be used to specify what web application you want to use. In your case, modeshape-rest is how you're reaching your REST API, as opposed to another web application that might be running on your system.

Workspace name refers to the workspace within your repository, from where you want to get items. I don't know exactly what this entails, you should look up what ModeShape means by a workspace.

Node path would be the path to whatever directory or file you want to access. In a file system, files are nodes, directories are nodes, symbolic links are nodes, etc.

You can find the API here: https://docs.jboss.org/author/display/MODE/REST+Service+3.x

To get a file or directory, you would use method 3: http://<host>:<port>/<context>/<repository_name>/<workspace_name>/items/<item_path>;

Here's an example: http://localhost:8080/modeshape-rest/my-repository/my-workspace/items/c/users/antoni?depth=-1

If it works, you will get a HTTP response saying 200 OK, and the response body will contain a JSON string with some properties of the node you requested, including the JCR type of the node, and possible the children of the node (the amount of levels you can specify with depth).

You can then parse the JSON in the front end to display the results.

I suggest you read up on RESTful services.
 
Dass Leyo Antoniraj
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply.

itz not easy to understand his syntax https://docs.jboss.org/author/display/MODE/REST+Service+3.x
I use a maven project in eclipse kepler ide.



the standard syntx of web service is :
http://your_domain:port/display-name/url-pattern/path_from_rest_class


My uri :
http://localhost:8080/modeshape-rest(url-pattern)/Persisted_Repository(name of the repository)"


I suppose that "context" are optional ; ; am i correct ???

ModeShape comes with a war that you can deploy in a servlet container

how to deploy this war in my application by depencies ???


this is my web.xml

<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app>
<display-name>ModeShapeFrontEnd</display-name>
<servlet>
<servlet-name>rest-servlet</servlet-name>
<servlet-class>
com.sun.jersey.spi.container.servlet.ServletContainer
</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.evolutionenegy.server</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>rest-servlet</servlet-name>
<url-pattern>/modeshape-rest/*</url-pattern>
</servlet-mapping>

<welcome-file-list>
<welcome-file>Portail.html</welcome-file>
<!-- <welcome-file>index.jsp</welcome-file>-->
</welcome-file-list>
</web-app>


advance thanks
 
Stephan van Hulst
Saloon Keeper
Posts: 7964
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Context is not optional. You can specify it in the context.xml file of your application, in META-INF. It's essentially the name of your web application.

You should create a new maven web application with the sole purpose of running the ModeShape REST API war. Simply add the following to your dependencies:
You don't need a web.xml, it's already provided in the modeshape war. To deploy the API correctly, you need to add a "connect" role to your server's user. For Tomcat, you can find it in <Tomcat>/conf/tomcat-users.xml. Simply add "connect" to your user's roles.

Then you can create your own web application that displays the front end. It will run on the server side by side with the ModeShape REST API, and it can then send REST requests to it, and display the results.
 
Dass Leyo Antoniraj
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,
sorry to ask like this is there any zip which contains the project(just one action creation of nodes) ; to be sure for pom files etc....
i just came to know from you that we dont need a web.xml, i did not see anywhere in modeshape document.
advance thanks .
cordially
 
Dass Leyo Antoniraj
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,

you need to add a "connect" role to your server's user. For Tomcat, you can find it in <Tomcat>/conf/tomcat-users.xml. Simply add "connect" to your user's roles.
how to do it ???
i tried to create a content.xml ?

<application xmlns="http://java.sun.com/xml/ns/j2ee" version="1.4"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com /xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
<display-name>ModeShapeFrontEnd</display-name>

<module>
<web>
<web-uri> ??? </web-uri>
<context-root>bank</context-root>
</web>
</module>

</application>

advance thanks. need badly help
 
Stephan van Hulst
Saloon Keeper
Posts: 7964
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You won't find it in ModeShape's docs, because it depends on the way you set up their REST API. I recommend doing it in a separate web project, because ModeShape uses RestEasy in such a way that it doesn't leave any URLs for your own web application.

For instance, let's say you want the url http://localhost:8080/myapplication/index.jsp to go to your home page. If you use the REST API in the same context (application), this won't work because ModeShape will complain that index.jsp doesn't refer to a valid repository. So you need to make one application with a context such as "modeshape-rest" and one with "myapplication". For myapplication you need your own web.xml, but not for modeshape-rest, because the war you depend on already has it.

I only have two files in the modeshape-rest project, and nothing else:

ModeShapeRest/pom.xml:
ModeShapeRest/src/main/webapp/META-INF/context.xml:
Finally, I don't know what you're using as a server, but I'm using Tomcat, and this is what the users file looks like.

C:\Program Files\Apache\Tomcat 7.0.52\conf\tomcat-users.xml:
Obviously, you should change myUserName and myPassword to whatever you want to use.

Now, when I run the application, it first asks me for my credentials, and then it shows me the JSON response of querying the default repo. You can use the configuration xml for ModeShape to setup a custom repository.

When this works, you can build a *separate* web application that uses your modeshape-rest application through REST requests.
 
Dass Leyo Antoniraj
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for your detailled answere.
Could you please tell me how do i link the 2 projects.


please find the project layout in jpg format
this will be a great help

advance thanks
cordially
Antoniraj


project_layout.jpg
[Thumbnail for project_layout.jpg]
project lay out
 
Dass Leyo Antoniraj
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a lot once again
As per your advise i have created another maven web based project.
i have put the contents in the pom file and created a content xml in web-inf

modeshape-rest\src\main\webapp\WEB-INF\context.xml(i dont find meta-inf)

once i excute i have error HTTP ERROR: 503

No LoginService for org.eclipse.jetty.security.authentication.BasicAuthenticator@4bdc0bc7

i really struggle .
advance thanks

cordially
Antoniraj
webproject.jpg
[Thumbnail for webproject.jpg]
 
Stephan van Hulst
Saloon Keeper
Posts: 7964
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like you are mixing things up a bit. Here's what you should do:

1) User clicks on a directory or file node in the web page. This links to a REST method of your controller.
2) The controller forwards the request to the modeshape-rest context.
3) The controller interprets the response JSON as JCR objects.
4) The controller finds the applicable JSP and serves a page that shows the content of the directory or file node.

It's probably easiest if the controller is a RESTful resource itself. You can use Jersey for this. Maybe you can even use JAXB to convert the JSON to JCR objects.

I don't really see why you would need classes such as ModeShape, ModeShapeBean and ModeShapeClient. Just use a single class ModeShapeResource which is contained by org.glassfish.jersey.servlet.ServletContainer.

An alternative is to completely do away with your own server side code, and do all the work in JavaScript, which can interpret the JSON directly. Most of the server stuff is handled in modeshape-rest application anyway.
 
Stephan van Hulst
Saloon Keeper
Posts: 7964
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dass Leyo Antoniraj wrote:thanks a lot once again
As per your advise i have created another maven web based project.
i have put the contents in the pom file and created a content xml in web-inf

modeshape-rest\src\main\webapp\WEB-INF\context.xml(i dont find meta-inf)


No. A Tomcat context file goes in META-INF. If you don't have it, create it. It won't work if you put it in another directory.

However, you are using Jetty, so you should do it differently anyway. You should add the following plugin to your build:
 
Stephan van Hulst
Saloon Keeper
Posts: 7964
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should also configure Jetty so that the user has "connect" role.
 
Dass Leyo Antoniraj
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I'm new to webservice and modeshape.

You told :
i recommend doing it in a separate web project, because ModeShape uses RestEasy in such a way that it doesn't leave any URLs for your own web application.


My plan ;
on the left hand side i would like to have nodes type nt: fiolder adn at the right hand side nodes of type nt:files

so i the user clicks on folder at the left hand side we should have the files at the right hand side (i have attached an image output.jpg)


i'm supposed to use mvc ; thats why i have client (as shown in the previous picture) which is called by my html file and i have server where i construct my json format (@Produces(MediaType.APPLICATION_JSON)) :
and i have a class that works with engine and nodes. I use this class

so i thought one application i will use the modshape war and in another i have web.xml(and i dont know how to link these 2 apps)
And i'm supposed to use angularjs (no jsp) which provides the mvc pattern on the client side.

i send you the image of my expected output sorry to disturb you
thanks

cordialement
Antoni
output.jpg
[Thumbnail for output.jpg]
 
Dass Leyo Antoniraj
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
any help
 
Stephan van Hulst
Saloon Keeper
Posts: 7964
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't you first tell us first what exactly it is that you want to application to do, and don't use terms such as nt:folder etc. Are you trying to build a online filesystem, or what?

Why do you need ModeShape? Why do you need AngularJS?

It occurs to me that since you seem to be going to work mostly on the client side anyway, you might as well do away with the Java classes completely, and simply perform Ajax calls to your filesystem's REST resources.

You don't need to "link" your application. They run separately, and you communicate between them via the REST API. Like I said before, you should probably study REST a little bit.
 
Dass Leyo Antoniraj
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i'm doing a java course in which i have to a small project. the examiners have put a condition that the project should be in mvc pattern.
the company in which i'm doing the internship wants (forces me to it with modeshape). modeshape as the backend and in the front end he wants me to do with angularjs which proposes mvc on client side.
i got exemples with easy restful standard api with a maven web application. since modeshape proposes itz own service i'm oblieged to use it.
to summarise he wants to a webexplorer for modehape(ie the folders at left hand side and the files at the right hand side) with the option of adding and deleting.
since the node types of modeshape is nt:folder and nt:file ; i indicated it in my diagram.
that i have to finish it in 1 month.
really hectic
if you want i can send the zip of my project///
thanks a lot..............




 
Stephan van Hulst
Saloon Keeper
Posts: 7964
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alright. So what happens is that the server side is completely handled by ModeShape. You should only need to run the ModeShape application in your application server (Jetty or Tomcat or JBoss or GlassFish or whatever).

Next, your own web application should probably only consist of AngularJS, because that completely handles the MVC and the dynamic pages. There's no need to write any Java in this project.

Your client (written in AngularJS) then communicates with the server (your ModeShape application) through Ajax, calling the REST methods.

Note that if you're still planning on writing some Java in between, the GitHub project has a lot of example code. It even has a JSONClient that interacts with the server through the REST API.

https://github.com/ModeShape
 
Dass Leyo Antoniraj
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!