Skip to content

Commit

Permalink
Updated the code for dotCMS 3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
yasindilekci committed Sep 27, 2016
1 parent f92f76b commit 3b20f0b
Show file tree
Hide file tree
Showing 9 changed files with 628 additions and 145 deletions.
17 changes: 17 additions & 0 deletions conf/web-ext.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<servlet>
<servlet-name>SearchServlet</servlet-name>
<servlet-class>nl.isaac.dotcms.twitter.servlet.SearchServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>SearchServlet</servlet-name>
<url-pattern>/search.json</url-pattern>
</servlet-mapping>

<servlet>
<servlet-name>TimelineServlet</servlet-name>
<servlet-class>nl.isaac.dotcms.twitter.servlet.TimelineServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TimelineServlet</servlet-name>
<url-pattern>/1/statuses/user_timeline.json</url-pattern>
</servlet-mapping>
152 changes: 71 additions & 81 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,26 +1,34 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>nl.isaac.dotcms.plugin.twitter</groupId>
<artifactId>isaac-dotcms-twitter</artifactId>
<version>2.5.0</version>
<version>3.2.0</version>
<packaging>bundle</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>

<prerequisites>
<maven>3.0</maven>
</prerequisites>

<organization>
<name>ISAAC Software Solutions</name>
<url>http://www.isaac.nl</url>
</organization>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<prerequisites>
<maven>3.0</maven>
</prerequisites>
<organization>
<name>ISAAC Software Solutions</name>
<url>http://www.isaac.nl</url>
</organization>
<repositories>
<repository>
<id>dotcms</id>
<name>dotcms Maven Repository</name>
<url>http://repo.dotcms.com/artifactory/repo</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<build>
<plugins>
<plugin>
Expand All @@ -43,110 +51,92 @@
<Bundle-Name>${project.artifactId}</Bundle-Name>
<Bundle-Version>${project.version}</Bundle-Version>
<Bundle-Activator>nl.isaac.dotcms.twitter.osgi.TwitterActivator</Bundle-Activator>
<Import-Package>
org.osgi.framework,
com.dotmarketing.osgi,
com.dotmarketing.beans,
com.dotmarketing.plugin.business,
com.dotmarketing.portlets.fileassets.business,
com.dotmarketing.portlets.languagesmanager.business,
com.dotmarketing.portlets.languagesmanager.model
</Import-Package>
<Import-Package />
<DynamicImport-Package>*</DynamicImport-Package>

<Embed-Dependency>*;scope=compile|runtime;inline=false</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>

<Data-Files>conf</Data-Files>
</instructions>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>com.dotcms</groupId>
<artifactId>dotcms-core</artifactId>
<version>2.3.1</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/dotcms-core-2.3.1.jar</systemPath>
</dependency>
<dependency>
<groupId>org.twitter4j</groupId>
<artifactId>twitter4j-core</artifactId>
<version>3.0.3</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.4</version>
<groupId>org.twitter4j</groupId>
<artifactId>twitter4j-core</artifactId>
<version>3.0.3</version>
</dependency>

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<groupId>com.dotcms</groupId>
<artifactId>dotcms</artifactId>
<version>3.2</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.4</version>
<groupId>com.dotcms.lib</groupId>
<artifactId>dot.commons-io</artifactId>
<version>2.0.1_1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2</version>
<groupId>com.dotcms.lib</groupId>
<artifactId>dot.commons-lang</artifactId>
<version>2.4_1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.0.1</version>
<groupId>com.dotcms.lib</groupId>
<artifactId>dot.felix</artifactId>
<version>4.2.1_1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.main</artifactId>
<version>4.2.1</version>
<groupId>com.dotcms.lib</groupId>
<artifactId>dot.portlet</artifactId>
<version>1.0_1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.http.api</artifactId>
<version>2.2.0</version>
<groupId>com.dotcms.lib</groupId>
<artifactId>dot.org.apache.felix.http.bundle</artifactId>
<version>2.2.0_1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.osgi.compendium</artifactId>
<version>1.4.0</version>
<groupId>com.dotcms.lib</groupId>
<artifactId>dot.urlrewritefilter</artifactId>
<version>4.0.3_1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<version>1.9.13</version>
<scope>provided</scope>
<groupId>com.dotcms.lib</groupId>
<artifactId>dot.tika-app</artifactId>
<version>1.3_1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.13</version>
<scope>provided</scope>
<groupId>com.dotcms.lib</groupId>
<artifactId>dot.jackson-mapper-asl</artifactId>
<version>1.9.2_1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.portlet</groupId>
<artifactId>portlet-api</artifactId>
<version>2.0</version>
<groupId>com.dotcms.lib</groupId>
<artifactId>dot.jackson-core-asl</artifactId>
<version>1.9.2_1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.tuckey</groupId>
<artifactId>urlrewritefilter</artifactId>
<version>3.2.0</version>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
50 changes: 3 additions & 47 deletions src/main/java/nl/isaac/dotcms/twitter/osgi/TwitterActivator.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,14 @@
* @copyright Copyright (c) 2013 ISAAC Software Solutions B.V. (http://www.isaac.nl)
*/

import java.util.Date;

import javax.servlet.ServletException;

import nl.isaac.dotcms.twitter.servlet.SearchServlet;
import nl.isaac.dotcms.twitter.servlet.TimelineServlet;
import nl.isaac.dotcms.twitter.util.TwitterFieldFactory;
import nl.isaac.dotcms.twitter.viewtool.TwitterViewTool;
import nl.isaac.dotcms.util.osgi.ExtendedGenericBundleActivator;
import nl.isaac.dotcms.util.osgi.ViewToolScope;

import org.apache.felix.http.api.ExtHttpService;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.service.http.NamespaceException;
import org.osgi.util.tracker.ServiceTracker;

import com.dotmarketing.filters.CMSFilter;
import com.dotcms.repackage.org.osgi.framework.BundleContext;
import com.dotmarketing.util.Logger;

/**
Expand All @@ -36,10 +26,6 @@
*/
public class TwitterActivator extends ExtendedGenericBundleActivator {

private SearchServlet searchServlet;
private TimelineServlet timelineServlet;
private ServiceTracker<ExtHttpService, ExtHttpService> tracker;

public void start(BundleContext context) throws Exception {
Logger.info(this, "Twitter: Activator.start()");

Expand All @@ -53,31 +39,8 @@ public void start(BundleContext context) throws Exception {
addViewTool(context, TwitterViewTool.class, "isaacTwitterTool", ViewToolScope.REQUEST);

// Register the servlet and filter
tracker = new ServiceTracker<ExtHttpService, ExtHttpService>(context, ExtHttpService.class, null) {
@Override public ExtHttpService addingService(ServiceReference<ExtHttpService> reference) {
ExtHttpService extHttpService = super.addingService(reference);
searchServlet = new SearchServlet();
timelineServlet = new TimelineServlet();
try {
extHttpService.registerServlet("/search.json", searchServlet, null, null);
extHttpService.registerServlet("/1/statuses/user_timeline.json", timelineServlet, null, null);
} catch (ServletException e) {
throw new RuntimeException("Failed to register servlet and filter", e);
} catch (NamespaceException e) {
throw new RuntimeException("Failed to register servlet and filter", e);
}
Logger.info(this, "Registered servlet and filter " + new Date(System.currentTimeMillis()));
return extHttpService;
}
@Override public void removedService(ServiceReference<ExtHttpService> reference, ExtHttpService extHttpService) {
extHttpService.unregisterServlet(searchServlet);
extHttpService.unregisterServlet(timelineServlet);
super.removedService(reference, extHttpService);
}
};
tracker.open();
CMSFilter.addExclude("/search.json");
CMSFilter.addExclude("/1/statuses/user_timeline.json");
addServlet(context, SearchServlet.class, "/search.json");
addServlet(context, TimelineServlet.class, "/1/statuses/user_timeline.json");

addRewriteRule("^/search.json$", "/app/search.json", "forward", "TwitterSearchServlet");
addRewriteRule("^/1/statuses/user_timeline.json$", "/app/1/statuses/user_timeline.json", "forward", "TwitterTimelineServlet");
Expand All @@ -92,13 +55,6 @@ public void start(BundleContext context) throws Exception {

public void stop(BundleContext context) throws Exception {
Logger.info(this, "Twitter: Activator.stop()");

CMSFilter.removeExclude("/1/statuses/user_timeline.json");
CMSFilter.removeExclude("/app/1/statuses/user_timeline.json");
CMSFilter.removeExclude("/search.json");
CMSFilter.removeExclude("/app/search.json");
tracker.close();

unregisterServices(context);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import javax.servlet.http.HttpServletResponse;

import com.google.gson.Gson;
import com.dotcms.repackage.com.google.gson.Gson;

public class JSONResponseWriter {

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/nl/isaac/dotcms/twitter/util/RequestUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

import org.apache.velocity.tools.view.context.ViewContext;
import org.apache.velocity.tools.view.tools.ViewTool;
import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;

import com.dotcms.repackage.org.codehaus.jackson.JsonParseException;
import com.dotcms.repackage.org.codehaus.jackson.map.JsonMappingException;
import com.dotcms.repackage.org.codehaus.jackson.map.ObjectMapper;
import com.dotmarketing.beans.Host;
import com.dotmarketing.business.APILocator;
import com.dotmarketing.business.Role;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
import nl.isaac.dotcms.twitter.util.TwitterSettings;
import nl.isaac.dotcms.twitter.util.TwitterUtil;

import org.apache.commons.lang.StringEscapeUtils;
import org.apache.velocity.context.Context;
import org.apache.velocity.tools.view.context.ViewContext;
import org.apache.velocity.tools.view.tools.ViewTool;

import com.dotcms.repackage.org.apache.commons.lang.StringEscapeUtils;

public class TwitterViewTool implements ViewTool {

/* http://codegolf.stackexchange.com/questions/464/shortest-url-regex-match-in-javascript
Expand Down
Loading

0 comments on commit 3b20f0b

Please sign in to comment.