블로그 이미지
윤영식
Full Stacker, Application Architecter, KnowHow Dispenser and Bike Rider

Publication

Category

Recent Post

2014. 5. 27. 09:24 Study Frameworks/Liferay Portal

Template을 공유하는 방법에 대해 알아보자 



Resource Importer App 설치 

  - 템플릿 적용을 위해서는 Template Importer를 사용하는데 이는 Resources Importer App의 일부 기능이다. 

  - Liferay Makketplace 에서 Resources Importer App 다운로드 설치한다. (v2.0.1 CE 버전)

    + 오른쪽의 [Free] 버튼 클릭

    + 가입하고 로그인후 개인적 용도로 사용 선택

    + 구매내역으로 이동하면 [Download] 버튼을 클릭

    + 최종파일 : Resources Importer CE.lpkg

    + 최종파일을 $LIFERAY_PORTAL/deploy 폴더에 넣고 start 하면 tomcat webapps로 자동 배포된다

      

    또는 Control Panel로 이동하여 선택해서 설치할 수도 있다 

     


  - Resource Importer App 개념 

The Resources Importer app allows front-end developers to package web content, portlet configurations, and layouts together in a theme without saving it as a compiled .LAR file thereby allowing for greater flexibility in its usage between Liferay Portal versions. This app will automatically create associated content when other plugins are deployed that are configured to make use of the Resource Importer app.



Sample Template 적용하기

  - mobiconsoft_template 라는 portlet을 eclipse에서 생성한다

    

  - maven 기반이므로 pom.xml을 이전 블로그를 참조하여 수정한다

    

  - liferay-plugin-package.properties 안에 다음을 첨부한다. 또한 기존에 설정된 name 값을 삭제한다  

name=

module-group-id=liferay

module-incremental-version=1

tags=

short-description=

change-log=

page-url=http://www.liferay.com

author=Liferay, Inc.

licenses=LGPL


required-deployment-contexts=resources-importer-web

resources-importer-developer-mode-enabled=true

module-incremental-version=1

  - portlet.xml에서 <display-name> 태그도 삭제한다 

  - WEB-INF/src 밑으로 templates-importer를 만든다. 그러나 지금은 maven 기반이므로 src/main/resources 밑에 templates-importer 폴더를 생성한다 

   


  - samples-template-importer-content.zip 파일을 다운로드 받아 templates-importer 폴더 안에 푼다.  

    


  - 폴더의 구조

  • templates-importer/
    • journal/
      • structures/ - contains structures (XML) and folders of child structures. Each folder name must match the file name of the corresponding parent structure. For example, to include a child structure of parent structure Parent 1.xml, create a folder named Parent 1/ at the same level as the Parent 1.xml file, for holding a child structures.
      • templates/ - groups templates (FTL or VM) into folders by structure. Each folder name must match the file name of the corresponding structure. For example, create folder Structure 1/ to hold a template for structure file Structure 1.xml.
    • templates/
      • application_display/ - contains application display template (ADT) script files written in either the FreeMarker Template Language (.ftl) or Velocity (.vm). The extension of the files, .ftl for FreeMarker or .vm for Velocity must reflect the language that the templates are written in.
        • asset_category/ - contains categories navigation templates
        • asset_entry/ - contains asset publisher templates
        • asset_tag/ - contains tags navigation templates
        • blogs_entry/ - contains blogs templates
        • document_library/ - contains documents and media templates
        • site_map/ - contains site map templates
        • wiki_page/ - contains wiki templates
      • dynamic_data_list/ - contains dynamic data list templates and structures
        • display_template/ - groups templates (FTL or VM) into folders by structure. Each folder name must match the file name of the corresponding structure. For example, create folderStructure 1/ to hold a template for structure file Structure 1.xml.
        • form_template/ - groups templates (FTL or VM) into folders by structure. Each folder name must match the file name of the corresponding structure. For example, create folder Structure 1/ to hold a template for structure file Structure 1.xml.
        • structure/ - contains structures (XML)
      • page/ - contains page templates (JSON)


  - 이제 프로젝트를 선택하고 contentx menu를 통해 mobiconsoft_template 포틀릿을 배포한다. 

   

   배포가 성공하면 deploy 폴더로 자동 복사된다. 

[INFO] --- liferay-maven-plugin:6.2.1:deploy (default-cli) @ mobiconsoft_template ---

[INFO] Deploying mobiconsoft_template-1.0.0-SNAPSHOT.war to /liferay_portal/portal-6.2-ce-ga2/deploy

     [null] Copying 1 file to /liferay_portal/portal-6.2-ce-ga2/deploy

[INFO] ------------------------------------------------------------------------

[INFO] BUILD SUCCESS

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 10.980s

[INFO] Finished at: Tue May 27 08:51:31 KST 2014

[INFO] Final Memory: 34M/525M

[INFO] ------------------------------------------------------------------------

 

   - 로그인후 Admin의 Control Panel을 선택하고 "Site"에서 Global을 선택한다 

   

  - Configuration의 "Application Display Templates"을 선택한다  

   

  - 리스트에 보면 첨부한 내역을 볼 수 있다. 이후 처리에 대한 부분은 to be continue... (문서에 정확히 안나와 있음)

  - template의 layout은 templates/page/*.json 으로 정의한다 

{

"layoutTemplate": {

"columns": [

[

{

"portletId": "58"

}

],

[

{

"portletId": "47"

}

]

],

"friendlyURL": "/page-1",

"name": "Page 1",

"title": "Page 1"

},

"layoutTemplateId": "2_columns_ii"

}


  * ant 기반 해당 포틀릿 소스



<참조>

  - Creating plugin to share template

  - Theme 정의하기

  - Liferay Dev Guide in GitHub

posted by 윤영식
2014. 5. 26. 09:44 Study Frameworks/Liferay Portal

포틀릿에서 Action Phase 수행후 Render Phase로 정보들 어떻게 전달 될 수 있는지 알아보자 



Action 에서 Render Phase로 정보전달 방식

  - render parameters를 통한 정보 전달 : REQUEST SCOPE

> Action Phase

  processAction 안에서 actionResponse.setRenderParameter("parameter-name", "value");  값을 설정


> Render Phase

  renderRequest.getParameter("parameter-name"); 호출하여 값을 얻어옴 


> 단, action phase에서는 only read 이므로 set이 가능하려면 portlet.xml 에 다음 설정을 한다. 해당 설정을 하게되면 action phase parameters 가 render phase parameters로 복사된다. 

<init-param>

    <name>copy-request-parameters</name>

    <value>true</value>

</init-param>


> action parameter를 render parameter로 전달하게 되면 action phase이후 모든 포틀릿의 render phase가 호출되는 것임을 유의 


  - 세션 방식의 전달 : SESSION SCOPE

> actionRequest에 설정하고 JSP가 읽는다. 해당 설정값은 JSP에 딱 한번 사용되고 자동으로 삭제한다 

//SessionMessages 사용 경우 

package com.liferay.samples;


import java.io.IOException;

import javax.portlet.ActionRequest;

import javax.portlet.ActionResponse;

import javax.portlet.PortletException;

import javax.portlet.PortletPreferences;

import com.liferay.portal.kernel.servlet.SessionMessages;

import com.liferay.util.bridges.mvc.MVCPortlet;


public class MyGreetingPortlet extends MVCPortlet {

    public void setGreeting(

            ActionRequest actionRequest, ActionResponse actionResponse)

    throws IOException, PortletException {

        PortletPreferences prefs = actionRequest.getPreferences();

        String greeting = actionRequest.getParameter("greeting");


        if (greeting != null) {

            try {

                prefs.setValue("greeting", greeting);

                prefs.store();

                SessionMessages.add(actionRequest, "success");

            }

            catch(Exception e) {

                SessionErrors.add(actionRequest, "error");

            }

        }

    }

}


// view.jsp 에서 sucess / error 사용 

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>

<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>

<%@ page import="javax.portlet.PortletPreferences" %>


<portlet:defineObjects />


<liferay-ui:success key="success" message="Greeting saved successfully!"/>

<liferay-ui:error key="error" message="Sorry, an error prevented savingyour greeting" />


<% PortletPreferences prefs = renderRequest.getPreferences(); String

greeting = (String)prefs.getValue(

    "greeting", "Hello! Welcome to our portal."); %>


<p><%= greeting %></p>


<portlet:renderURL var="editGreetingURL">

    <portlet:param name="mvcPath" value="/edit.jsp" />

</portlet:renderURL>


<p><a href="<%= editGreetingURL %>">Edit greeting</a></p>


  - Liferay Portal 은 multi parameters들을 포틀릿에 전달하므로 namespace 구분을 하는게 중요하다 

<portlet:namespace />  를 사용하면 포틀릿별 유니크한 네임스페이스를 가질 수 있다 

예) submitForm(document.<portlet:namespace />fm);  form에 대한 것


Liferay는 namespaced 파라미터만 포틀릿에 접근할 수 있다. 그러나 third-part 에서 unamespaced parameter가 존재하면

 liferay-portal.xml 에서 기능을 꺼주어야 한다. 

<requires-namespaced-parameters>false</requires-namespaced-parameters>



Multi Action 추가

  - 포틀릿에 원하는 Action만큼 추가할 수 있다

1) 메소드 명칭은 사용자 정의 & 두개의 파라미터 받음 

    public void setGreeting(ActionRequest actionRequest, ActionResponse actionResponse) 

         throws IOException, PortletException {...

    }


    public void sendEmail(ActionRequest actionRequest, ActionResponse actionResponse) 

        throws IOException, PortletException {

        // Add code here to send an email

    }


2) setGreeting 명칭은 JSP에서 actionURL의 name과 일치해야 한다 

<portlet:actionURL var="editGreetingURL" name="setGreeting">

    <portlet:param name="mvcPath" value="/edit.jsp" />

</portlet:actionURL>



포틀릿 URL Mapping을 친숙한 방법으로 전환

  - v6 부터 human readable 하게 url을 만들 수 있다. 

 > 원래 보이는 형태 

http://localhost:8080/web/guest/home?p_p_id=mygreeting_WAR_mygreetingportlet

    &p_p_lifecycle=0&p_p_state=normal&p_p_mode=view&p_p_col_id=column-1

    &p_p_col_count=2&_mygreeting_WAR_mygreetingportlet_mvcPath=%2Fedit.jsp


 > friendly url 변환 

http://localhost:8080/web/guest/home/-/my-greeting/edit

  - liferay-portlet.xml 에서 </icon> 이후 <instanceable> 바로 전에 하기 설정을 넣음 

1) liferay-portlet.xml 설정 내역 

<liferay-portlet-app>

<portlet>

<portlet-name>mobiconsoft_greeting</portlet-name>

<icon>/icon.png</icon>

<friendly-url-mapper-class>com.liferay.portal.kernel.portlet.DefaultFriendlyURLMapper</friendly-url-mapper-class>

<friendly-url-mapping>mobiconsoft_greeting</friendly-url-mapping>

<friendly-url-routes>mobiconsoft/greeting/mobiconsoft-greeting-friendly-url-routes.xml</friendly-url-routes>

<instanceable>false</instanceable>

<header-portlet-css>/css/main.css</header-portlet-css>

<footer-portlet-javascript>/js/main.js</footer-portlet-javascript>

</portlet>


2) src/main/resources/폴더 밑의 monbiconsoft/greeting/ 폴더 밑으로 mobiconsoft-greeting-friendly-url-routes.xml 생성 및 입력


<?xml version="1.0"?>

<!DOCTYPE routes PUBLIC "-//Liferay//DTD Friendly URL Routes 6.2.0//EN"

"http://www.liferay.com/dtd/liferay-friendly-url-routes_6_2_0.dtd">


<routes>

    <route>

        <pattern>/{mvcPathName}</pattern>

        <generated-parameter name="mvcPath">/{mvcPathName}.jsp</generated-parameter>

    </route>

</routes>


3) eclipse의 context menu에서 "Liferay" -> "Maven" -> "deploy"를 선택하면 war파일 생성됨 


4) eclipse에서 테스트 서버 수행하면 deploy 폴더의 war 파일들이 자동배포된다. test@liferay.com (패스워드 : test) 로그인

    로그인후 우측 상단의 "+" 를 클릭하고 Sample 메뉴에서 mobiconsoft_greeting을 추가하면 하기 무한루프 오류가 발생함

    (추후 오류현상 추적필요)


시도하고 시도해 보고 실패에서 배워보자. 다음엔 포틀릿를 좀 더 고도화 해보자 



<참조> 

  - Action -> Render Phase 정보전달

  - Multi Action 추가하는 방법

posted by 윤영식

포틀릿을 생성하고 세부사항에 대하여 알아보고, 포틀릿의 두가지 Phase를 이해하자. 이를 위해 Maven 기반으로 포틀릿을 생성하고 Java와 JSP를 생성/수정해 보도록 한다. 

완성된 포틀릿의 edit 모습

 


포틀릿 생성

  - 이클립스 IDE를 통한 생성

  - CLI 명령으로 통한 생성

// CLI 생성

// 이름의 뒤에 자동으로 "-portlet"이 붙는다 

$ cd ~/development/liferay_portal/plugins-sdk-6.2/portlets

$ create.sh mobiconsoft-greeting "hi youngsik"

Buildfile: /Users/xxx/development/liferay_portal/plugins-sdk-6.2/portlets/build.xml

.. 중략 ..

BUILD SUCCESSFUL

Total time: 1 second


// 배포

$ ant deploy 

Buildfile: /Users/xxx/development/liferay_portal/plugins-sdk-6.2/portlets/build.xml

deploy:

    .. 중략 ..

     [copy] Copying 1 file to /Users/xxx/development/liferay_portal/portal-6.2-ce-ga2/deploy

BUILD SUCCESSFUL

Total time: 9 seconds


* 만일 tomcat ROOT를 변경하였다면 deploy/*.war는 기본 폴더인 {TOMCAT_HOME}/webapps/ 밑으로 들어간다. 

tomcat을 수행하기전에 deploy/*.war 파일을 변경된 폴더 밑으로 copy한 후 시작한다. (변경된 폴더로 deploy하는 설정을 못 찾겠음)



Portlet 구조이해

  - 톰켓에 배포된 디렉토리 구조

> 자바 소스, 웹 리소스, 환경 설정 3가지로 구성되어있다.

  톰켓의 단일 Context로 운영된다. 즉, J2EE Context 폴더 구조임 


> xml 환경파일들

 portlet.xml : JSR-286 Portlet 스펙에 대한 환경파일

 liferay-display.xml : 화면구성 위저드에서 카테고리 지정 

 liferay-plugin-package.properties : hot deploy 설정

 liferay-portlet.xml : liferay portal server와 특화된 portlet 설정들

 

> 리소스들

 html : 클라이언트에 표현되는 것으로 <html>, <head> 태그는 없어야 함

 css, js : 다른 css와 충돌하지 않도록 namespace를 준다 


  - portlet.xml

    + MVCPortlet : 포틀릿 전체 기능이 내장된 놈. 우리가 만드는 포틀릿은 실제 요것을 상속받아서 구현된다. 

    + portlet-info : 카테고리되었을 때 이름 지정 

<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" version="2.0">

<portlet>

<portlet-name>mobiconsoft-greeting</portlet-name>

<display-name>hi youngsik</display-name>

<portlet-class>com.liferay.util.bridges.mvc.MVCPortlet</portlet-class>

<init-param>

<name>view-template</name>

<value>/view.jsp</value>

</init-param>

<expiration-cache>0</expiration-cache>

<supports>

<mime-type>text/html</mime-type>

</supports>

<portlet-info>

<title>hi youngsik</title>

<short-title>hi youngsik</short-title>

<keywords>hi youngsik</keywords>

</portlet-info>

<security-role-ref>

<role-name>administrator</role-name>

</security-role-ref>

<security-role-ref>

<role-name>guest</role-name>

</security-role-ref>

<security-role-ref>

<role-name>power-user</role-name>

</security-role-ref>

<security-role-ref>

<role-name>user</role-name>

</security-role-ref>

</portlet>

</portlet-app>


  - liferay-portlet.xml 

    + header-portlet-css : <header> 태그에 들어갈 css 

    + footer-portlet-javascripit : </body> 끝에 들어갈 javascript 

    + instanceable : 해당 포틀릿이 한페이지 멀티로 나오는 인스턴스들인지 true / false 설정

<?xml version="1.0"?>

<!DOCTYPE liferay-portlet-app PUBLIC "-//Liferay//DTD Portlet Application 6.2.0//EN" "http://www.liferay.com/dtd/liferay-portlet-app_6_2_0.dtd">


<liferay-portlet-app>

<portlet>

<portlet-name>mobiconsoft-greeting</portlet-name>

<icon>/icon.png</icon>

<header-portlet-css>/css/main.css</header-portlet-css>

<footer-portlet-javascript>/js/main.js</footer-portlet-javascript>

<css-class-wrapper>mobiconsoft-greeting-portlet</css-class-wrapper>

</portlet>

<role-mapper>

<role-name>administrator</role-name>

<role-link>Administrator</role-link>

</role-mapper>

<role-mapper>

<role-name>guest</role-name>

<role-link>Guest</role-link>

</role-mapper>

<role-mapper>

<role-name>power-user</role-name>

<role-link>Power User</role-link>

</role-mapper>

<role-mapper>

<role-name>user</role-name>

<role-link>User</role-link>

</role-mapper>

</liferay-portlet-app>



포틀릿을 수정해 보기 

  - liferay-portal.xml 에서 instanceable=false 추가 

<instanceable>false</instanceable>

  - view.jsp 파일 수정 

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>

<%@ page import="javax.portlet.PortletPreferences" %>


<portlet:defineObjects />


<%

PortletPreferences prefs = renderRequest.getPreferences();

String greeting = (String)prefs.getValue("greeting", "Hello! Welcome to our portal.");

%>


<p><%= greeting %></p>


<portlet:renderURL var="editGreetingURL">

    <portlet:param name="mvcPath" value="/edit.jsp" />

</portlet:renderURL>


<p><a href="<%= editGreetingURL %>">Edit greeting</a></p>

  - edit.jsp 파일 신규 추가

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>

<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui" %>


<%@ page import="javax.portlet.PortletPreferences" %>


<portlet:defineObjects />


<%

PortletPreferences prefs = renderRequest.getPreferences();

String greeting = renderRequest.getParameter("greeting");

if (greeting != null) {

    prefs.setValue("greeting", greeting);

    prefs.store();

%>

    <p>Greeting saved successfully!</p>

<%

}

%>


<%

greeting = (String)prefs.getValue("greeting", "Hello! Welcome to our portal.");

%>


<portlet:renderURL var="editGreetingURL">

    <portlet:param name="mvcPath" value="/edit.jsp" />

</portlet:renderURL>


<aui:form action="<%= editGreetingURL %>" method="post">

    <aui:input label="greeting" name="greeting" type="text" value="<%=greeting %>" />

    <aui:button type="submit" />

</aui:form>


<portlet:renderURL var="viewGreetingURL">

    <portlet:param name="mvcPath" value="/view.jsp" />

</portlet:renderURL>


<p><a href="<%= viewGreetingURL %>">&larr; Back</a></p>

  - {SDK}/portlets 밑에서 수정했으면 다시 deploy를 이미 www 폴더에서 수정했다면 tomcat 다시 restart 한다.

// 수정한 view.jsp 


// 신규 추가한 edit.jsp 



  - *.jsp 에서 중요한 사항

    +  http://java.sun.com/portlet_2_0 에서 정의한 <portlet:renderURL> 태그(taglib)를 사용한다  

    +  edit.jsp에서 aui(AlloyUI == YUI3)를 이용하여 form을 만들고 있다 

    + <portlet:defineObjects/> 를 넣으면 renderRequest, portletConfig, portletPreferences 를 jsp에서 사용할 수 있다. 이것은 jsp에서만 유효하고 여러가지 오브젝트를 사용토록 해준다 

RenderRequest renderRequest: represents the request sent to the portlet to handle a render. renderRequest is only available to a JSP if the JSP was included during the render request phase.


ResourceRequest resourceRequest: represents the request sent to the portlet for rendering resources. resourceRequest is only available to a JSP if the JSP was included during the resource-serving phase.


ActionRequest actionRequest: represents the request sent to the portlet to handle an action. actionRequest is only available to a JSP if the JSP was included during the action-processing phase.


EventRequest eventRequest: represents the request sent to the portlet to handle an event. eventRequest is only available to a JSP if the JSP was included during the event-processing phase.


RenderResponse renderResponse: represents an object that assists the portlet in sending a response to the portal. renderResponse is only available to a JSP if the JSP was included during the render request phase.


ResourceResponse resourceResponse: represents an object that assists the portlet in rendering a resource. resourceResponse is only available to a JSP if the JSP was included in the resource-serving phase.


ActionResponse actionResponse: represents the portlet response to an action request. actionResponse is only available to a JSP if the JSP was included in the action-processing phase.


EventResponse eventResponse: represents the portlet response to an event request. eventResponse is only available to a JSP if the JSP was included in the event-processing phase.


PortletConfig portletConfig: represents the portlet’s configuration including, the portlet’s name, initialization parameters, resource bundle, and application context. portletConfig is always available to a portlet JSP, regardless of the request-processing phase in which it was included.


PortletSession portletSession: provides a way to identify a user across more than one request and to store transient information about a user. A portletSession is created for each user client. portletSession is always available to a portlet JSP, regardless of the request-processing phase in which it was included. portletSession is null if no session exists.


Map<String, Object> portletSessionScope: provides a Map equivalent to the PortletSession.getAtrributeMap() call or an empty Map if no session attributes exist.


PortletPreferences portletPreferences: provides access to a portlet’s preferences. portletPreferences is always available to a portlet JSP, regardless of the request-processing phase in which it was included.


Map<String, String[]> portletPreferencesValues: provides a Map equivalent to the portletPreferences.getMap() call or an empty Map if no portlet preferences exist.



Liferay IDE를 통한 개발 (주의사항)

  - 기본 {TOMCAT_HOME}/webapps/ROOT 를 사용한다. 

  - 기존 ~/liferay_portal/www 에서 다시 원위치로 설정한다.

1) {TOMCAT_HOME}/conf.xml 에서 위치 변경

<Host appBase="/Users/xxx/development/liferay_portal/portal-6.2-ce-ga2/tomcat-7.0.42/webapps" autoDeploy="true" name="localhost" unpackWARs="true">


2) {PLUGIN_SDK}/build.<username>.properties

app.server.tomcat.lib.global.dir = /Users/xxx/development/liferay_portal/portal-6.2-ce-ga2/tomcat-7.0.42/lib/ext

app.server.tomcat.deploy.dir = /Users/xxx/development/liferay_portal/portal-6.2-ce-ga2/tomcat-7.0.42/webapps

app.server.parent.dir = /Users/xxx/development/liferay_portal/portal-6.2-ce-ga2

app.server.tomcat.dir = /Users/xxx/development/liferay_portal/portal-6.2-ce-ga2/tomcat-7.0.42

app.server.type = tomcat

app.server.tomcat.portal.dir = /Users/xxx/development/liferay_portal/portal-6.2-ce-ga2/tomcat-7.0.42/webapps/ROOT

  - 또한 Maven으로 생성시 pom.xml에서 <version> 은 "1.0.0-SNAPSHOT"이 아니라 "portlet" 이라고 준다 



포틀릿의 2 Phase Execution 이해 

  - Action Phase와 Render Phase로 구성된다

  - Action Phase

    + 하나의 포틀릿에서만 유저 인터렉션이 일어날 수있다. 

    + 사용자의 prefereneces는 한번만 변경되고 재변경되지 않는다 

  - Render Phase

    + action phase가 있은 후 모든 포틀릿의 render phase를 호출한다.

1) action phase를 만들기위해서 기존에 Eclipse에서 생성한 "mobiconsoft-sample"에서 자바소스를 추가한다 

    (CLI 방식일 경우 : {SDK}/porlets/mobiconsoft-sample-portlet/WEB-INF/src 밑에 둔다)

     MVCPorlet을 상속받는다 

package com.mobiconsoft.sample;


import java.io.IOException;

import javax.portlet.ActionRequest;

import javax.portlet.ActionResponse;

import javax.portlet.PortletException;

import javax.portlet.PortletPreferences;

import com.liferay.util.bridges.mvc.MVCPortlet;


public class YoungSikGreetingPortlet extends MVCPortlet {

    @Override

    public void processAction(ActionRequest actionRequest, ActionResponse actionResponse)

        throws IOException, PortletException {

        PortletPreferences prefs = actionRequest.getPreferences();

        String greeting = actionRequest.getParameter("greeting");


        if (greeting != null) {

            prefs.setValue("greeting", greeting);

            prefs.store();

        }


        super.processAction(actionRequest, actionResponse);

    }

}


2) portlet.xml 파일의 내용에서 MVCPortlet을 바꾼다 

<portlet-class>com.mobiconsoft.sample.YoungSikGreetingPortlet</portlet-class>


3) edit.jsp 안에 action을 넣어보자 

   - renderURL : render phase에서만 호출 된다 

   - actionURL : 페이지안의 모든 포틀릿을 rendering 하기전에 action phase를 수행한다

   - resourceURL : xml, images, json, AJAX 요청등

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>

<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui" %>


<%@ page import="com.liferay.portal.kernel.util.ParamUtil" %>

<%@ page import="com.liferay.portal.kernel.util.Validator" %>

<%@ page import="javax.portlet.PortletPreferences" %>


<portlet:defineObjects />


<%

    PortletPreferences prefs = renderRequest.getPreferences();

    String greeting = (String)prefs.getValue("greeting", "Hello! Welcome to our portal.");

%>


<portlet:actionURL var="editGreetingURL">

    <portlet:param name="mvcPath" value="/edit.jsp" />

</portlet:actionURL>


<aui:form action="<%= editGreetingURL %>" method="post">

        <aui:input label="greeting" name="greeting" type="text" value="<%=

    greeting %>" />

        <aui:button type="submit" />

</aui:form>


<portlet:renderURL var="viewGreetingURL">

        <portlet:param name="mvcPath" value="/view.jsp" />

</portlet:renderURL>


<p><a href="<%= viewGreetingURL %>">&larr; Back</a></p>


4) deploy 해서 확인해 볼 수 있다. 



<참조>

  - 포틀릿 해부하기 

  - 포틀릿 수정하기 

  - 포틀릿 2 Phase Execution

  - pom.xml 파일 샘플 

pom-userxxx-liferay.xml

posted by 윤영식

Liferay는 기본 Ant 기반으로 되어 있고, Maven 기반으로 변경할 수 있다. 



Maven 및 Nexus OSS 설치

  - Ant는 build.xml에 설정하고 Maven은 pom.xml (Project Object Model)에 설정한다 

  - 예전 Spring+Maven 설정 블로깅을 참조한다.

  - 메이븐은 로컬에 Nexus 서버를 설치하여 프로젝트/사내 시스템 단위로 라이브러리를 관리할 수 있다

   + http://www.sonatype.org/nexus/

   + Nexus 설치 가이드

   + 접속 : http://localhost:8081/nexus  (admin / admin123)

   + Optional Install 사항이다. 굳이 설치하지 않아도 됨

  - Liferay Nexus Repository : https://repository.liferay.com/nexus/index.html



Liferay Maven 설정

  - 다운로드 liferay maven 라이브러리 (liferay-portal-maven-[version]-[date].zip) : CE버전만 해당됨

  - 해당 파일에는 Maven artifact에 대한 파일 뿐만 아니라 스크립트 도구도 포함되어 있다. 적절한 위치에 압축을 해제한다 

1) maven은 liferay-portals 소스를 참조하여 빌드되므로 소스를 다운로드 한다 

$ cd ~/development/liferay_portal/sources

$ git clone https://github.com/liferay/liferay-portal.git 


2) app.server.[user name].properties 파일을 liferay-portal 폴더 밑에 생성한다

$ cd ~/development/liferay_portal/sources/liferay-portal

$ vi app.server.[username].properties

app.server.type=tomcat

app.server.parent.dir=/Users/nulpulum/development/liferay_portal/portal-6.2-ce-ga2

app.server.tomcat.dir=${app.server.parent.dir}/tomcat-7.0.42


3) Local Repository 가 아닌 Liferay Central Repository에서 Artifacts 를 설치할 경우 pom.xml에 들어갈 내용

<repositories>

    <repository>

        <id>liferay-ce</id>

        <name>Liferay CE</name>

        <url>https://repository.liferay.com/nexus/content/groups/liferay-ce</url>

        <releases><enabled>true</enabled></releases>

        <snapshots><enabled>true</enabled></snapshots>

    </repository>

</repositories>


<pluginRepositories>

    <pluginRepository>

        <id>liferay-ce</id>

        <url>https://repository.liferay.com/nexus/content/groups/liferay-ce/</url>

        <releases><enabled>true</enabled></releases>

        <snapshots><enabled>true</enabled></snapshots>

    </pluginRepository>

</pluginRepositories>


  > Central Repository in Nexus


 > CLI 명령을 통해 접근 할 수도 있다

mvn archetype:generate -DarchetypeCatalog=https://repository.liferay.com/nexus/content/groups/liferay-ce

   


Liferay Eclipse IDE에 Maven 설정

  - Liferay IDE 2.0 에서는 Maven project configurator (m2e-liferay) 제공

1) 만일 Meven Integration for Eclipse 1.4가 설치되어 있다면 1.5 버전으로 먼저 업데이트한다. 


2) "Help" -> "Install New Software ..." 에서  Liferay SDK와 m2e-liferay 를 삭제하고-already installed 링크 클릭하여 삭제가능- Liferay IDE의 m2e-liferay 두개를 다시 설치한다.  (mobile SDK는 미선택)

Liferay IDE repository - http://releases.liferay.com/tools/ide/latest/stable/.

 


으악 Liferay Perspective가 동작하질 않는다!!!

3) Liferay Eclipse 4.3 - Kepler로 이동하기 

  - 멘붕이 시작되었다. m2e-liferay를 설치한 후 Liferay perspective가 제대로 동작하질 않아서 SDK, m2e 모두 삭제하고 다양한 방법으로 여러번 reinstall 시도를 하여도 Liferay Perspective가 제대로 동작하지 않아서 Eclipse Kepler(4.3) 최신버전으로 Liferay를 재구성 하였다.

  - 다운로드 Eclipse Kepler 설치 

  - JDK v1.7 기반


  - pom.xm 배포위치 & 저장소 위치 & 의존성 관계 라이브러리 환경 설정

    + Global settings, User settings, Parent Project pom.xml, Project pom.xml 4군데 중 하나에 설정한다. 

    + 다른 프로젝트충돌을 방지할려면 자신의 프로젝트 pom.xml에 설정하는게 좋겠다.

    + Global/User settings 에는 profile에 설정하여 pom.xml에서 profile을 불러와서 사용하면 된다. (pom.xml 마다 설정이 필요없음)

<?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>com.liferay.sample</groupId>

    <artifactId>sample-parent-project</artifactId>

    <version>1.0-SNAPSHOT</version>

    <packaging>pom</packaging>


    <name>sample-parent-project</name>

    <url>http://www.liferay.com</url>


    <!-- START : Maven 방식 Liferay plugin 생성시 추가해야할 내역 --> 

    <properties>

    <liferay.app.server.deploy.dir>/Users/xxx/development/liferay_portal/www</liferay.app.server.deploy.dir>

    <liferay.app.server.lib.global.dir>

/Users/xxx/development/liferay_portal/portal-6.2-ce-ga2/tomcat-7.0.42\lib\ext

    </liferay.app.server.lib.global.dir>

    <liferay.app.server.portal.dir>/Users/xxx/development/liferay_portal/www/ROOT</liferay.app.server.portal.dir>

    <liferay.auto.deploy.dir> /Users/xxx/development/liferay_portal/portal-6.2-ce-ga2/deploy</liferay.auto.deploy.dir>

    <liferay.maven.plugin.version>6.2.1</liferay.maven.plugin.version>

    <liferay.version>6.2.1</liferay.version>

    </properties>


    <repositories>

    <repository>

        <id>liferay-ce</id>

        <name>Liferay CE</name>

        <url>https://repository.liferay.com/nexus/content/groups/liferay-ce</url>

        <releases><enabled>true</enabled></releases>

        <snapshots><enabled>true</enabled></snapshots>

    </repository>

</repositories>


<pluginRepositories>

    <pluginRepository>

        <id>liferay-ce</id>

        <url>https://repository.liferay.com/nexus/content/groups/liferay-ce/</url>

        <releases><enabled>true</enabled></releases>

        <snapshots><enabled>true</enabled></snapshots>

    </pluginRepository>

</pluginRepositories>

     <!-- END : Maven 방식 Liferay plugin 생성시 추가해야할 내역 --> 


   <!-- 이하 자동 생성되는 내역 일부임 --> 

    <dependencies>

       <dependency>

         <groupId>com.liferay.portal</groupId>

         <artifactId>portal-client</artifactId>

         <version>${liferay.version}</version>

       </dependency>

       <dependency>

         <groupId>com.liferay.portal</groupId>

         <artifactId>portal-impl</artifactId>

         <version>${liferay.version}</version>

         <scope>provided</scope>

       </dependency>

       <dependency>

         <groupId>com.liferay.portal</groupId>

         <artifactId>portal-pacl</artifactId>

         <version>${liferay.version}</version>

         <scope>provided</scope>

       </dependency>

       <dependency>

         <groupId>com.liferay.portal</groupId>

         <artifactId>portal-service</artifactId>

         <version>${liferay.version}</version>

         <scope>provided</scope>

       </dependency>

       <dependency>

         <groupId>com.liferay.portal</groupId>

         <artifactId>portal-web</artifactId>

         <version>${liferay.version}</version>

         <type>war</type>

         <scope>provided</scope>

       </dependency>

       <dependency>

         <groupId>com.liferay.portal</groupId>

         <artifactId>util-bridges</artifactId>

         <version>${liferay.version}</version>

       </dependency>

       <dependency>

         <groupId>com.liferay.portal</groupId>

         <artifactId>util-java</artifactId>

         <version>${liferay.version}</version>

       </dependency>

       <dependency>

         <groupId>com.liferay.portal</groupId>

         <artifactId>util-slf4j</artifactId>

         <version>${liferay.version}</version>

       </dependency>

       <dependency>

         <groupId>com.liferay.portal</groupId>

         <artifactId>util-taglib</artifactId>

         <version>${liferay.version}</version>

       </dependency>

    </dependencies>

</project>



Maven 방식 Liferay Plugin 생성

  - Liferay는 플로그인 6가지 방식에 대한 Maven의 archetype을 제공하고 있다 

  - Archetype is Maven’s project templating toolkit

1) Eclipse Liferay IDE에서 "New Liferay Plugin Project" 선택

2) Build type을 Maven으로 선택

다음에서 MVCPortlet 선택


* CLI 명령 생성하기 

- 생성

mvn archetype:generate -DarchetypeCatalog=https://repository.liferay.com/nexus/content/groups/liferay-ce


- 배포 

mvn liferay:deploy


3) IDE로 생성된 pom.xml 에는 오류가 있다. 위의 pom.xml에서 추가해야 할 것들을 추가한다

  - properties : 배포 위치 및 버전 정보

  - repositories : Liferay remote repository 위치 (Nexus OSS로 local proxy server 사용하지 않을 경우)

  - pluginRepositores 


4) Eclipse에서 "mobiconsoft-sample"을 선택하고 컨텍스트메뉴 "Liferay" -> "Maven" -> "liferay:deploy" 를 선택하여 war파일을 만들어 본다 

[INFO] --- liferay-maven-plugin:6.2.1:deploy (default-cli) @ mobiconsoft-sample ---

[INFO] Deploying mobiconsoft-sample-1.0.0-SNAPSHOT.war to /Users/xxx/development/liferay_portal/portal-6.2-ce-ga2/deploy

     [null] Copying 1 file to /Users/xxx/development/liferay_portal/portal-6.2-ce-ga2/deploy

[INFO] ------------------------------------------------------------------------

[INFO] BUILD SUCCESS

[INFO] ------------------------------------------------------------------------


deploy 디렉토리에 생성된 모습


5) Eclipse에서 해당 war를 tomcat 컨텍스트로 추가하고 시작하면 Liferay 화면에서 확인을 할 수 있다


Liferay v6.2 CE Server를 시작하면 Liferay 화면이 뜬다 


  - 그외 Maven 아키타입들 

liferay:portlet, liferay:hook, liferay:ext, liferay:theme, liferay:layout


그외 ...

Liferay ServiceBuilder portlets

Liferay webs

Liferay Ext

JSF Portlet Archetype

ICEFaces Portlet Archetype

PrimeFaces Portlet Archetype

Liferay Faces Alloy Portlet Archetype

Liferay Rich Faces Portlet Archetype

DBBuilder - The build-db goal lets you execute the DBBuilder to generate SQL files.

SassToCSSBuilder - The build-css goal precompiles SASS in your css; this goal has been added to theme archetype.



지금까지 환경설정을 하고 어떻게 Maven으로 빌드하는 과정을 보았다. 다음 블로깅에서는 플로그인 개발 실무를 보도록 한다. 



<참조>

  - Liferay Maven 빌드 환경 구성하기

  - 샘플 pom.xml 파일 

pom-userxxx-liferay.xml

posted by 윤영식

Liferay의 Service Builder 도구는 비즈니스 업무를 만들어내는 도구이다. 그리고 Plugins SDK에 대해서 알아보도록 한다. 



Service Builder 개념  

  - Service Builder 도구는 Model-Driven code generator이다. 

  - WEB-INF/service.xml 안에 entity로 정의되고 이를 참조하여 model, persistence, service 파일이 자동 생성되는 구조이다. 

  - 자동 생성된 내역은 여러다른 포틀릿에서도 공유할 수 있게 구성된다 

 > service.xml 에서 Entity를 추가하고 필드를 정의 할 수 있다


> 각 Entity에 대해서 Column을 정의한다 



> Event와 Location을 추가했는데 두 entity간의 relation을 Diagram에서 맺어 줄 수 있다


  - event-listing 프로젝트를 선택하고 컨텍스트메뉴를 보면 "Liferay" -> "Build Services" 를 선택하여 파일을 자동 생성한다

> WEB-INF/src , sql 밑으로 소스가 자동 생성되었다 



기존에 있는 프로젝트 Import하여 분석하기 

  - "New" -> "New Liferay Project form Existing Source" 로 기존의 플러그인을 Eclipse에 불러서 사용할 수 있다 

  - Plugins SDK 안에 존재하는 플러그인을 불러오고 싶다면 "Import..." -> "Liferay Projects from Plugins SDK"를 선택한다 

> Liferay에서 선택


> SDK를 선택하면 Plugins SDK에 포함된 플러그인을 자동 열거하여 준다. 원하는 것을 선택하고 Runtime을 선택한다 



Plugins SDK 이해하기

  - Plugin SDK 설치는 지난 블로그에서 다루었다. 이제 Plugins SDK의 환경설정은 build.properties에서 한다

> 환경설정 주의

 ~/development/liferay_portal/plugins-sdk-6.2/build.properties 는 절대로 변경하지 말자

 대시 build.<username>.properties 파일을 변경한다. 

  - SDK 디렉토리 구조

clients/ - client applications directory.

dist/ - archived plugins for distribution and deployment.

ext/ - Ext plugins directory. See Advanced Customization with Ext Plugins.

hooks/ - hook plugins directory. See Customizing and Extending Functionality with Hooks.

layouttpl/ - layout templates directory. See Creating Liferay Layout Templates.

lib/ - commonly referenced libraries.

misc/ - development configuration files. Example, a source code formatting specification file.

portlets/ - portlet plugins directory. See Developing Portlet Applications.

themes/ - themes plugins directory. See Creating Liferay Themes and Layout Templates.

tools/ - plugin templates and utilities.

webs/ - web plugins directory.

build.properties - default SDK properties.

build.<username>.properties - (optional) override SDK properties.

build.xml - contains targets to invoke in the SDK.

build-common.xml - contains common targets and properties referenced throughout the SDK.

build-common-plugin.xml - contains common targets and properties referenced by each plugin.

build-common-plugins.xml - contains common targets and properties referenced by each plugin type.



Ant 기반 빌드하기 

  - build.xml은 Ant 빌드 파일이다 

build-service - builds the service layer for a plugin, using Liferay Service Builder.

clean - cleans the residual files created by the invocations of the compilation, archiving, and deployment targets.

compile - compiles the plugin source code.

deploy - builds and deploys the plugin to your application server.

format-source - formats the source code per Liferay’s source code guidelines, informing you of violations that must be addressed. See the Development Sytle community wiki page for details.

format-javadoc - formats the Javadoc per Liferay’s Javadoc guidelines. See the Javadoc Guidelines community wiki page for details.

  - CLI (Command Line Interface) 기반으로 포틀릿 만들기 

> SDK/portlets/ 안에 보면 create.bat/create.sh 파일이 존재한다 

$ cd ~/development/liferay_portal/plugins-sdk-6.2/portlets

$ ./create.sh test-listing "test listing"


> 해당 디렉토리에서 배포하기 

$ ant deploy 


> 배포에 성공하게 되면 하기 디렉토리에 war파일 두개(event-listing-portlet, test-listing-portlet)이 생성된다 

  $PORTAL_HOME/deploy/*.war 파일은 tomcat에 배포된다 


다음 블로그에서는 Maven 기반 빌드를 보도록 하자. 



<참조>

  - Plugins SDK 이해

posted by 윤영식
2014. 4. 30. 17:28 Study Frameworks/Liferay Portal

Liferay 포털의 개발은 결국 기존 플러그인들의 확장 및 신규 개발 관건이다. 툴에 대한 이해를 하고 설치 사용해 보자 



Liferay IDE

  - Eclipse 플러그인으로 Eclipse Market에서 검색하여 설치가능 : "liferay ide"

  - Plugin SDK 또는 Maven과 Liferay runtime 환경과 결합하여 개발한 것을 배포 테스트 가능케 해준다  

  - Eclipse Indigo(3.7.x), Juno(4.2.x), Kepler(4.3.x) 에서 설치가능 

  - Plugin SDK와 Runtime 환경 설정 블로깅 참조 



Liferay Project 생성 

  - Eclipse의 Liferay IDE Perspective를 띄운다 

  - "New" -> "Liferay Plugin Project"를 선택한 후 하기와 같이 입력하고 "Service Builder"를 선택하고 생성한다 

    

  - 프로젝트 생성 내역

> docroot : 실제로 서비스하는 영역이다 

> view.jsp : 포틀릿으로 보여지는 웹 화면

> *xml : 포틀릿 설정 화면 


- liferay-display.xml 

  포틀릿 카테고리로 sample에 해당 포틀릿이 들어간다 

<display>

  <category name="category.sample">

    <portlet id="event-listing" />

  </category>

</display> 


  - 포틀릿 배포하기 

> 포틀릿을 생성하면 위치는 sdk/portlets 폴더밑으로 생성된다 


> Eclipse에서 Tomcat Server를 등록하여 기동한 상태라면 "And and New.." 컨텍스 메뉴를 선택하여 event-listing-porlet을 Add 하면 자동으로 Hot Deploy이 되어 반영된다 


- 포탈 화면에서 확인해 보자 

Sample 밑의 카테고리에 "Event Listing" 포틀릿이 존재하여 드래그앤드롭하여 원하는 위치에 놓을 수 있다


  - 프로젝트를 만든 후 기본 제공하는 항목을 제거하고 플러그인을 만들것이다. 기본 제공 설정내역을 삭제해 보자

1) WEB-INF/liferay-display.xml  에서 <portlet>..</portlet> 부분 제거 

2) WEB-INF/liferay-portlet.xml 에서  <portlet>..</portlet> 부분 제거 

3) WEB-INF/portlet.xml 에서  <portlet>..</portlet> 부분 제거  

4) view.jsp 파일 제거 


삭제까지 진행되었으면 이제 해당 프로젝트에 새로운 플러그인을 만들 준비가 되었다. 



Liferay Plugin 개발 

  - 프로젝트에는 여러개의 플러그인이 포함될 수 있다. 위에 만들어 놓은 "Event Listing" 프로젝트안에 여러개의 플러그인을 넣어본다 

  - Location Listing과 Event Listing 포틀릿 플러그인을 만들어 보자 

  - Location Listing Portlet 생성

1) 프로젝트명을 선택하고 context menu -> New -> "Liferay Portlet"을 선택하고 LocationListing 포틀릿을 입력


2) Next로 이동하여 포틀릿 정보를 입력


3) 카테고리 정보를 입력한다 "MobiconSoft"


  - event-listing 포틀릿을 생성한다 

> location-listing 과 같은 방식으로 생성

  MVCPortlet을 상속 받으면서 같은 java package에 속한다 


> 최종 생성된 Eclipse Project 모습

   + com.mobiconsoft.event의 클래스들은 MVCPortlet을 상속받아서 자동 생성된다 

   + liferay-display.xml, liferay-portlet.xml, portlet.xml 안에 위저드로 설정한 내용이 반영된다 


  - 프로젝트의 컨텍스트가 이미 Server에 반영되어서 위저드로 생성시에 Hot Deploy가 된다. 다음으로 "Mobiconsoft" 카테고리에 EventListing과 LocationListing이 반영되었는지 확인한다. 




다음 블로그에서는 "Service Builder" 도구를 사용하여 어떻게 Model, Persistence, Service Layer를 만들 수 있는지 살펴보도록 한다 


posted by 윤영식
2014. 4. 30. 17:20 Study Frameworks/Liferay Portal

기본 설치할 때 기본데이터를 체크하였다면 "Joe Bloggs" 가 나오고 몇가지 직관적인 메뉴를 통해서 포털의 화면을 구성할 수 있다. 가장 기본적인 것이라서 개발자 입장에서 기존에 제공하는 것의 변경 및 필요한 기능의 개발은 어떻게 하는지 Liferay Developer Guide (v6.2 기준) 를 통해 보도록 하자. 



가이드 내역 

  - Developing Application for Liferay

  - Extending and Customizing Liferay

  - 개발툴 선택하기 



Liferay를 위해 어플리케이션 개발 

  - liferay에서 어플리케이션을 연동하는 두가지 방법

    + Portlets 

    + OpenSocial gadget : 

  - Portlets

    + 자바로 쓰여진 어플리케이션 모듈로 포틀릿 컨테이너안에서 구동됨 

    + liferay 서버에 hot deploy가 가능하여 서버 재기동이 필요없음

    + 하나의 플러그인에 여러개의 포틀릿을 두어서 화면을 구성할 수 있다 

    + Liferay에서 정의한 프레임워크 : MVC 포틀릿, Alloy 포틀릿으로 구현된다 

  - OpenSocial gadget

    + 여러 언어로 개발가능

    + remote / local gadget 으로 구분

  - AlloyUI

    + v6 부터 클라이언트에서 사용

    + YUI3 이용

    + 다른 자바스크립 라이브러리 추가 가능



Liferay 기능 확장 및 커스터마이징

  - 여러 프러그인을 하나로 묶은 WAR로 배포하여 사용할 수 있다

  - Theme 사용자 정의 

    + Look and Feel에 대한 제어가 가능

    + Velocity 또는 FreeMarker와 CSS를 혼용하여 사용

    + 업무로직과 별개의 RWD(Responsive Web Desgin)이 가능

    + AlloyUI를 사용

  - Layout Templates

    + theme과 유사하지만 look and feel이 아니라 화면 페이지에 포틀릿 배치 정의에 대한 것이다 

    + Velocity를 사용하여 hot deploy 된다 

  - Hook Plugin

    + Liferay의 core function에 대하여 hooking 처리 할 수 있는 기능

    + 로그인, 세션관리, 코어 서비스들

  - Ext Plugin

    + Liferay core를 큰규모의 변경을 가하고자 할 때 사용

    + 친숙하고 정말 필요할 때만 사용. 서버 재기동 필요

 


개발 툴 선택 

  - CLI 방식 : ANT + Plugin SDK 

  - GUI 방식 : Eclipse 기반 Liferay IDE + Plugin SDK

  - Maven을 사용할 수 있다 

 

다음 단락에서는 3가지를 통해 개발하는 방법을 알아본다 

 > Developing Apps with Eclipse Liferay IDE

 > Leveraging the Plugins SDK

 > Developing Plugins Using Maven



<참조>

  - Liferay Developer Guide

  - Ext Plugin 개발 가이드

posted by 윤영식
2014. 4. 30. 12:33 Study Frameworks/Liferay Portal

Liferay CE v6.2 GA2 버전을 다운로드 받고 설치하는 과정과 Eclispse ID와 Liferay Plugins SDK도 설치해 보자. 



Liferay 다운로드 

  - JDK : v7.* 버전을 권장하고 없다면 V6.* 도 가능하다

  - 다운로드 파일 :  the liferay + tomcat bundle

  - 다운로드후 적당한 위치에 zip 압축을 푼다. (linux 기준)

// 압축을 풀었을 때 폴더명칭을 portal-6.2-ce-ga2 로 변경하였다 (사용자 정의함)

~/development/liferay_portal/portal-6.2-ce-ga2


  - data : lucene 데이터 파일

  - deploy : 플러그인 배포 .war 파일 놓는곳

  - tomact : 톰캣 위치 


// portal-ide.properties

auto.deploy.tomcat.conf.dir=/Users/xxxx/development/liferay_portal/portal-6.2-ce-ga2/tomcat-7.0.42/conf/Catalina/localhost


// portal-setup-wizard.properties 및 liferay와 mysql 연결 정보 (username : liferay, database : liferaydb)

liferay.home=/Users/xxxx/development/liferay_portal/portal-6.2-ce-ga2
admin.email.from.address=test@liferay.com
jdbc.default.driverClassName=com.mysql.jdbc.Driver
jdbc.default.username=liferay
jdbc.default.url=jdbc:mysql://localhost:3306/liferaydb?autoReconnect=true



Liferay Tomcat 설정

  - tomcat 위치

~/development/liferay_portal/portal-6.2-ce-ga2/tomcat-7.0.42

  - 디폴트 웹 어플리케이션 위치

~/development/liferay_portal/portal-6.2-ce-ga2/tomcat-7.0.42/webapps/ROOT

  - 웹 어플리케이션 위치를 옮길 경우 tomcat의 환경설정

// 변경위치를 www 로 할 경우

~/development/liferay_portal/portal-6.2-ce-ga2/www


// ~/development/liferay_portal/portal-6.2-ce-ga2/tomcat-7.0.42/conf/server.xml 수정

<Host appBase="/Users/xxxx/development/liferay_portal/www" autoDeploy="true" name="localhost" unpackWARs="true">

    <Context docBase="ROOT" path="" reloadable="true"/>

    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t &quot;%r&quot; %s %b" prefix="localhost_access_log." suffix=".txt"/>

</Host>

  - tomcat 시작

~/development/liferay_portal/portal-6.2-ce-ga2/tomcat-7.0.42/bin/startup.sh


몇분을 기다리면 브라우져가 자동 시작하여 http://localhost:8080/ 을 호출하고 초기 셋업페이지가 나온다. 

이때 mysql 연결로 바꾸자 (portal-setup-wizard.properties 참조)



Liferay Plugins SDK 설치 

  - 플러그인 소스 다운로드받자 : 나중에 eclipse ide에서 debugging 하거나 수정할 때 사용

$ cd  ~/development/liferay_portal/

$ mkdir sources && cd sources


// 플러그인 소스 다운로드 

$ git clone https://github.com/liferay/liferay-plugins.git

  - 다운로드 Liferay CE v6.2 ga2 Plugins SDK   

// ~/development/liferay_portal/ 위치에 sdk 압축을 푼다 

~/development/liferay_portal/plugins-sdk-6.2


// 최종 디렉토리 구조

  - ~/development/liferay_portal/plugins-sdk-6.2/build.<사용자명>.properties 내용 수정

app.server.tomcat.lib.global.dir = /Users/nulpulum/development/liferay_portal/portal-6.2-ce-ga2/tomcat-7.0.42/lib/ext

#app.server.tomcat.deploy.dir = /Users/nulpulum/development/liferay_portal/portal-6.2-ce-ga2/tomcat-7.0.42/webapps

app.server.tomcat.deploy.dir = /Users/nulpulum/development/liferay_portal/www

app.server.parent.dir = /Users/nulpulum/development/liferay_portal/portal-6.2-ce-ga2

app.server.tomcat.dir = /Users/nulpulum/development/liferay_portal/portal-6.2-ce-ga2/tomcat-7.0.42

app.server.type = tomcat

#app.server.tomcat.portal.dir = /Users/nulpulum/development/liferay_portal/portal-6.2-ce-ga2/tomcat-7.0.42/webapps/ROOT

app.server.tomcat.portal.dir = /Users/nulpulum/development/liferay_portal/www/ROOT



Eclipse IDE 설치

  - Eclipse Juno 버전 이상에서 "Eclipse Marketplace..." 에 들어가서 "liferay" 검색하면 "liferay IDE" 이클립스 플러그인이 나오면 Install

    


  - Liferay perpective를 띄웠을 때 화면 

    툴바에서 파란색 아이콘 3가지가 Liferay 기능이다. 

    


  - Liferay의 tomcat 서버를 등록한다 

    


  - 다음으로 Plugins SDK를 등록한다 

    



*** Liferay IDE를 통한 개발 (주의사항)

  - 기본 {TOMCAT_HOME}/webapps/ROOT 를 사용한다. 

  - 기존 ~/liferay_portal/www 에서 다시 원위치로 설정한다.

   (단, ant CLI 방식은 괜찮다)

  - 사용자가 xxx 일 경우

1) {TOMCAT_HOME}/conf.xml 에서 위치 변경

<Host appBase="/Users/xxx/development/liferay_portal/portal-6.2-ce-ga2/tomcat-7.0.42/webapps" autoDeploy="true" name="localhost" unpackWARs="true">


2) {PLUGIN_SDK}/build.<username>.properties

app.server.tomcat.lib.global.dir = /Users/xxx/development/liferay_portal/portal-6.2-ce-ga2/tomcat-7.0.42/lib/ext

app.server.tomcat.deploy.dir = /Users/xxx/development/liferay_portal/portal-6.2-ce-ga2/tomcat-7.0.42/webapps

app.server.parent.dir = /Users/xxx/development/liferay_portal/portal-6.2-ce-ga2

app.server.tomcat.dir = /Users/xxx/development/liferay_portal/portal-6.2-ce-ga2/tomcat-7.0.42

app.server.type = tomcat

app.server.tomcat.portal.dir = /Users/xxx/development/liferay_portal/portal-6.2-ce-ga2/tomcat-7.0.42/webapps/ROOT



<참조>

  - Liferay 환경 구성 - 한글

  - Liferay 초기 환경 설정

  - Liferay 개발환경 구성

  - Liferay tomcat 시작하기

  - A to Z Liferay 개발환경 설정하기 (필독)

posted by 윤영식
2014. 4. 30. 12:32 Study Frameworks/Liferay Portal

Liferay는 Enterprise Portal을 만들기 위한 솔루션이다. 커뮤니티 버전(CE)과 엔터프라이즈 버전(EE)이 존재하고, 오픈소스버전은 CE버전을 사용하면 된다. Liferay를 들어가기전에 Portal에 대한 올바른 이해와 설치 및 개발환경 설정 그리고 플로그인 개발을 보고 요즘 가장 핫한 Angular.js와 Node.js를 접목하여 클라이언트단 포틀랫(Portlet) 개발생산성 향상과 Node.js의 Socket.io를 이용한 실시간(Realtime) 구현에 대해서도 연재를 통하여 알아보자.





엔터프라이즈 포탈(EP)이란 무엇인가?

기업이 전술상 또는 전략상으로 필요로 하는 업무용 어플리케이션을 적은 비용으로 빠르게 구현하여 비즈니스 유저들에게 제공함으로써 IT는 업무 어플리케이션 구축 비용 및 시간을 절약하고 비즈니스 유저들은 자신의 업무에 필요한 어플리케이션을 신속히 제공받음으로써 사업의 기회비용을 줄일 수 있도록 지원하는 시스템. -인용-


  - 보다 자세한 이해는 엔터프라이즈 포탈이란 무엇인가? 연재글을 참조한다 

  - EP를 위하여 통합적으로 운영되어야 할 부분

    + 통합 검색 : 문서 검색 뿐만아니라 서비스/애플리케이션 단위의 검색도 가능

    + 콘텐츠 관리 : 디지털 컨텐츠/미디어의 Publish/Delivery 가능

    + 협업 기능 : SNS, 메신저, 게시판과 같은 온라인 소셜활동 가능 

    + 기타 : 다양한 어플리케이션/시스템 통합 프레임워크 제공 (SSO, KMS, BPM, ESB, SNS 등의 연동)



Liferay Portal이 제공하는 기능

  - 메일 : SMS Text Messenger

  - 블로그 : Blog, Asset Publisher (파일공유), RSS, Twitter

  - 위키 : Wiki

  - 문서 관리 : Document Library 문서공유 

  - 일정 관리 : Calendar

  - 게시판 : Message Boards (게시판) 

  - 투표 : Polls

  - 이미지 관리 : Image Gallery

  - 기사 : Journal, News

  - 공지 : Announcements, Alerts



Liferay 기술 스택

  - 서버 : Java(JDK v7 권장), Spring, Hibernate, EJB(optional)

  - 클라이언트 : AlloyUI (YUI3 + Twitter Bootstrap)



Liferay 버전 및 파일 다운로드

  - CE v6.2 GA2 (2014.4월 현재)

  - Portal 과 Plugins 파일로 구성됨

    + Portal은 메인 어플리케이션

    + Plugin은 확장 모듈이며 6가지(theme, portlet, EXT, layout template, hooks, web modules) 타입이 존재

  - GitHub : https://github.com/liferay/



다음글에서는 Liferay를 설치하고 설정하는 방법에 대해 알아보자 



참조

  - 엔터프라이즈 포탈이란 무엇인가?

  - Liferay GitHub Repository

posted by 윤영식
prev 1 next