Skip to content

Oracle ATG powered with a great RESTful Framework Jersey.

Notifications You must be signed in to change notification settings

pmouawad/ATGRESTful

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

ATGRESTfull

Well, in my opinion native Oracle ATG RESTful API is really deprecated, complicated and strange. So, I created this module.

An Oracle ATG powered with a great RESTful Framework Jersey.

How does Oracle ATG RESTful module works? Easy and simple like this:

@Path("/atg-restful")
public class RequestService extends BaseRESTService {

    @Nucleus("/OriginatingRequest")
	private HttpServletRequest request;

	@Nucleus("/atg/userprofiling/Profile")
	private Profile profile;

	@Nucleus("/atg/commerce/catalog/ProductCatalog")
	private Repository repository;

	@GET
	@Path("/test")
	@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN })
	public Response getExample(@PathParam("name") String name) {
		String contextPath = request.getContextPath();
		String profileName = profile.getName();
		String repositoryName = repository.getRepositoryName();

		Map<String, Object> result = createResult();
		result.put("param", name);
		result.put("requestScope", contextPath);
		result.put("sessionScope", profileName);
		result.put("globalScope", repositoryName);

		return Response.ok(result).build();
	}
}

Then, a simple GET on path /atg-restful/test URL, will return a JSON/XML/TXT with a param name value, a request, session ang global scoped component value.

How to use it?

On your MANIFEST.MF just require the module Texelz.RESTful like this:

ATG-Required: ... Texelz.RESTful ...

Then, on your web.xml file place this code:

<servlet>
	<servlet-name>NucleusJerseyREST</servlet-name>
	<servlet-class>com.texelz.atgrestful.NucleusJerseyServlet</servlet-class>
	<init-param>
		<param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>
		<param-value>com.texelz.atgrestful.NucleusResourceConfig</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>NucleusJerseyREST</servlet-name>
	<url-pattern>/r/*</url-pattern>
</servlet-mapping>

Jersey works loading a package with @Path annotated, so, now you just need to configure the component /com/texelz/atgrestful/NucleusRestPackages like this:

packages+=\
  #you packages...
  com.custom.restservices.MyService

P.S.:

It was used some classes and ideas from Stormpath - todos-jersey example :).

Thanks.

About

Oracle ATG powered with a great RESTful Framework Jersey.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%