Skip to content

Commit 750b926

Browse files
committed
init
1 parent 8f1939c commit 750b926

17 files changed

+220
-0
lines changed

landing-hook/.classpath

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="docroot/WEB-INF/src"/>
4+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.7.0_71">
5+
<attributes>
6+
<attribute name="owner.project.facets" value="java"/>
7+
</attributes>
8+
</classpathentry>
9+
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/com.liferay.ide.eclipse.server.tomcat.runtimeClasspathProvider/Liferay v6.2 CE (Tomcat 7)">
10+
<attributes>
11+
<attribute name="owner.project.facets" value="jst.web"/>
12+
</attributes>
13+
</classpathentry>
14+
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
15+
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
16+
<classpathentry kind="con" path="com.liferay.ide.eclipse.server.plugin.container/hook">
17+
<attributes>
18+
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
19+
</attributes>
20+
</classpathentry>
21+
<classpathentry kind="output" path="docroot/WEB-INF/classes"/>
22+
</classpath>

landing-hook/.project

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>landing-hook</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.jdt.core.javabuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
<buildCommand>
19+
<name>org.eclipse.wst.common.project.facet.core.builder</name>
20+
<arguments>
21+
</arguments>
22+
</buildCommand>
23+
<buildCommand>
24+
<name>org.eclipse.wst.validation.validationbuilder</name>
25+
<arguments>
26+
</arguments>
27+
</buildCommand>
28+
</buildSpec>
29+
<natures>
30+
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
31+
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
32+
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
33+
<nature>org.eclipse.jdt.core.javanature</nature>
34+
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
35+
</natures>
36+
</projectDescription>

landing-hook/.settings/.jsdtscope

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="docroot"/>
4+
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
5+
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
6+
<attributes>
7+
<attribute name="hide" value="true"/>
8+
</attributes>
9+
</classpathentry>
10+
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
11+
<classpathentry kind="output" path=""/>
12+
</classpath>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
4+
org.eclipse.jdt.core.compiler.compliance=1.7
5+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
7+
org.eclipse.jdt.core.compiler.source=1.7
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
2+
<wb-module deploy-name="landing-hook">
3+
<wb-resource deploy-path="/" source-path="/docroot" tag="defaultRootSource"/>
4+
<wb-resource deploy-path="/WEB-INF/classes" source-path="/docroot/WEB-INF/src"/>
5+
<property name="context-root" value="landing-hook"/>
6+
<property name="java-output-path" value="/landing-hook/docroot/WEB-INF/classes"/>
7+
</wb-module>
8+
</project-modules>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<root>
2+
<facet id="liferay.hook">
3+
<node name="libprov">
4+
<attribute name="provider-id" value="com.liferay.ide.eclipse.plugin.hook.libraryProvider"/>
5+
</node>
6+
</facet>
7+
</root>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<faceted-project>
3+
<runtime name="Liferay v6.2 CE (Tomcat 7)"/>
4+
<fixed facet="jst.web"/>
5+
<fixed facet="wst.jsdt.web"/>
6+
<fixed facet="java"/>
7+
<installed facet="java" version="1.7"/>
8+
<installed facet="jst.web" version="3.0"/>
9+
<installed facet="liferay.hook" version="6.0"/>
10+
<installed facet="wst.jsdt.web" version="1.0"/>
11+
</faceted-project>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.eclipse.wst.jsdt.launching.baseBrowserLibrary
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Window

landing-hook/build.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE project>
3+
4+
<project name="landing-hook" basedir="." default="deploy">
5+
<import file="../build-common-hook.xml" />
6+
</project>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Manifest-Version: 1.0
2+
Class-Path:
3+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/com/
2+
/portal.properties
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE hook PUBLIC "-//Liferay//DTD Hook 6.2.0//EN" "http://www.liferay.com/dtd/liferay-hook_6_2_0.dtd">
3+
4+
<hook>
5+
<portal-properties>portal.properties</portal-properties>
6+
</hook>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name=Landing
2+
module-group-id=liferay
3+
module-incremental-version=1
4+
tags=
5+
short-description=
6+
long-description=
7+
change-log=
8+
page-url=http://www.liferay.com
9+
author=Liferay, Inc.
10+
licenses=LGPL
11+
liferay-versions=6.2.0+
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/**
2+
* Copyright 2015 Chi Ngo ([email protected], chingovan.blogspot.com)
3+
*/
4+
package com.blogspot.chingovan.tutorial.hook.events;
5+
6+
import java.util.List;
7+
8+
import javax.servlet.http.HttpServletRequest;
9+
import javax.servlet.http.HttpServletResponse;
10+
import javax.servlet.http.HttpSession;
11+
12+
import com.liferay.portal.kernel.events.Action;
13+
import com.liferay.portal.kernel.events.ActionException;
14+
import com.liferay.portal.kernel.exception.PortalException;
15+
import com.liferay.portal.kernel.exception.SystemException;
16+
import com.liferay.portal.kernel.struts.LastPath;
17+
import com.liferay.portal.kernel.util.StringPool;
18+
import com.liferay.portal.kernel.util.WebKeys;
19+
import com.liferay.portal.model.Group;
20+
import com.liferay.portal.model.User;
21+
import com.liferay.portal.service.GroupLocalServiceUtil;
22+
import com.liferay.portal.util.PortalUtil;
23+
24+
/**
25+
* @author chinv
26+
*
27+
*/
28+
public class CustomLoginAction extends Action {
29+
30+
/*
31+
* (non-Javadoc)
32+
*
33+
* @see com.liferay.portal.kernel.events.Action#run(javax.servlet.http.
34+
* HttpServletRequest, javax.servlet.http.HttpServletResponse)
35+
*/
36+
@Override
37+
public void run(HttpServletRequest request, HttpServletResponse response) throws ActionException {
38+
39+
String defaultPath = "/web/guest/welcome";
40+
String defaultPage = "/welcome";
41+
42+
String path = "";
43+
44+
try {
45+
46+
// Get logined user
47+
User user = PortalUtil.getUser(request);
48+
49+
// Get all group of user
50+
List<Group> groups = GroupLocalServiceUtil.getUserGroups(user.getUserId());
51+
52+
if (groups != null && groups.size() > 0) {
53+
54+
// Select a group which matches with your business
55+
// In this introduce, because each user belong a group, I will
56+
// select first group
57+
Group group = groups.get(0);
58+
59+
path = "/web" + group.getFriendlyURL() + defaultPage;
60+
}
61+
62+
} catch (PortalException e) {
63+
64+
e.printStackTrace();
65+
} catch (SystemException e) {
66+
67+
e.printStackTrace();
68+
}
69+
70+
if (path == null || path.isEmpty()) {
71+
72+
path = defaultPath;
73+
}
74+
75+
// Navigate to path
76+
LastPath lastPath = new LastPath(StringPool.BLANK, path);
77+
HttpSession session = request.getSession();
78+
session.setAttribute(WebKeys.LAST_PATH, lastPath);
79+
}
80+
81+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#
2+
#Thu Jul 16 00:31:22 ICT 2015
3+
login.events.post=com.blogspot.chingovan.tutorial.hook.events.CustomLoginAction

landing-hook/docroot/WEB-INF/web.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<web-app id="WebApp_ID" version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
3+
</web-app>

0 commit comments

Comments
 (0)