Published using Google Docs
liferay-tutorial-library-portlet-complete-source-code-1.txt
Updated automatically every 5 minutes

Liferay 6.1 Tutorial - Library
http://notarazi.blogspot.com

zip package:

folder: docroot/WEB-INF/src/com.liferay.training.library.portlet

file: BookPortlet.java

file: BookValidator.java

file: PublisherPortlet.java

file: PublisherValidator.java

folder: docroot/WEB-INF/src/com.liferay.training.library.service.impl

file: PublisherLocalServiceImpl.java

file: BookLocalServiceImpl.java

folder: docroot/WEB-INF/src/content

file:language.properties

folder: docroot/html/book

file: book_actions.jsp

file: edit_book.jsp

file: edit.jsp

file: help.jsp

file: view.jsp

folder: docroot/html/publisher

file: edit_publisher.jsp

file: edit.jsp

file: help.jsp

file: publisher_actions.jsp

file: view.jsp

folder: docroot/html/

init.jsp

folder: WEB-INF/service/com/liferay/training/library/model/

file: Book.java

BookClp.java

BookModel.java

BookSoap.java

BookWrapper.java

Publisher.java

PublisherClp.java

PublisherModel.java

PublisherSoap.java

PublisherWrapper.java

folder: WEB-INF/service/com/liferay/training/library/service/

NoSuchBookException.java

NoSuchPublisherException.java

folder: WEB-INF/sql/

indexes.property

indexes.sql

tables.sql

folder: WEB-INF/

liferay-display.xml

liferay-plugin-package.properties

liferay-portlet.xml

portlet.xml

service.xml

web.xml

zip package:

  1. sample-library-portlet-1
  2. sample-library-portlet-up-to-lesson-16

folder: docroot/WEB-INF/src/com.liferay.training.library.portlet

=============================

file: BookPortlet.java

=============================

package com.liferay.training.library.portlet;

import java.util.ArrayList;

import java.util.Date;

import java.util.Locale;

import java.util.Map;

import javax.portlet.ActionRequest;

import javax.portlet.ActionResponse;

import javax.portlet.PortletPreferences;

import javax.portlet.PortletRequest;

import com.liferay.portal.kernel.log.Log;

import com.liferay.portal.kernel.log.LogFactoryUtil;

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

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

import com.liferay.portal.kernel.util.LocalizationUtil;

import com.liferay.portal.kernel.util.ParamUtil;

import com.liferay.portal.kernel.util.Validator;

import com.liferay.portal.kernel.util.WebKeys;

import com.liferay.portal.theme.ThemeDisplay;

import com.liferay.portal.util.PortalUtil;

import com.liferay.training.library.model.Book;

import com.liferay.training.library.model.impl.BookImpl;

import com.liferay.training.library.service.BookLocalServiceUtil;

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

/**

 * Portlet implementation class BookPortlet

 */

public class BookPortlet extends MVCPortlet {

 

        

        

                /**

         * Adds a new book to the database.

         *

         */

        public void addBook(ActionRequest request, ActionResponse response)

                throws Exception {

                ArrayList<String> errors = new ArrayList<String>();

                Book book = bookFromRequest(request);

                if (BookValidator.validateBook(book, errors)) {

                        BookLocalServiceUtil.addBook(book);

                        SessionMessages.add(request, "book-added");

                        sendRedirect(request, response);

                }

                else {

                        for (String error : errors) {

                                SessionErrors.add(request, error);

                        }

                        PortalUtil.copyRequestParameters(request, response);

                        response.setRenderParameter("jspPage", "/html/book/edit_book.jsp");

                }

        }

        /**

         * Convenience method to create a Book object out of the request. Used

         * by the Add / Edit methods.

         *

         */

        private Book bookFromRequest(PortletRequest request) {

                ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);

                int publicationDateMonth = ParamUtil.getInteger(request, "publicationDateMonth");

                int publicationDateDay = ParamUtil.getInteger(request, "publicationDateDay");

                int publicationDateYear = ParamUtil.getInteger(request, "publicationDateYear");

                Date publicationDate = PortalUtil.getDate(publicationDateMonth, publicationDateDay, publicationDateYear);

                Map<Locale, String> titleMap = LocalizationUtil.getLocalizationMap(request, "title");

                Book book = new BookImpl();

                book.setBookId(ParamUtil.getLong(request, "bookId"));

                book.setTitleMap(titleMap);

                book.setAuthorName(ParamUtil.getString(request, "authorName"));

                book.setPublicationDate(publicationDate);

                book.setPublisherId(ParamUtil.getLong(request, "publisherId"));

                book.setCompanyId(themeDisplay.getCompanyId());

                book.setGroupId(themeDisplay.getScopeGroupId());

                return book;

        }

        

        /**

         * Deletes a book from the database.

         *

         */

        public void deleteBook(ActionRequest request, ActionResponse response)

                throws Exception {

                long bookId = ParamUtil.getLong(request, "bookId");

                if (Validator.isNotNull(bookId)) {

                        BookLocalServiceUtil.deleteBook(bookId);

                        SessionMessages.add(request, "book-deleted");

                        sendRedirect(request, response);

                }

                else {

                        SessionErrors.add(request, "error-deleting");

                }

        }

        /**

         * Updates the database record of an existing book.

         *

         */

        public void updateBook(ActionRequest request, ActionResponse response)

                throws Exception {

                Book book = bookFromRequest(request);

                ArrayList<String> errors = new ArrayList<String>();

                if (BookValidator.validateBook(book, errors)) {

                        BookLocalServiceUtil.updateBook(book);

                        SessionMessages.add(request, "book-updated");

                        sendRedirect(request, response);

                }

                else {

                        for (String error : errors) {

                                SessionErrors.add(request, error);

                        }

                        PortalUtil.copyRequestParameters(request, response);

                        response.setRenderParameter("jspPage", "/html/book/edit_book.jsp");                        

                }

        }

        /**

         * Sets the preferences for how many books can be viewed per

         * page and the format for the date.

         *

         */

        public void setBookPref(ActionRequest request, ActionResponse response)

                throws Exception {

                String rowsPerPage = ParamUtil.getString(request, "rowsPerPage");

                String dateFormat = ParamUtil.getString(request, "dateFormat");

                ArrayList<String> errors = new ArrayList<String>();

                if (BookValidator.validatePreferences(rowsPerPage, dateFormat, errors)) {

                        PortletPreferences prefs = request.getPreferences();

                        prefs.setValue("rowsPerPage", rowsPerPage);

                        prefs.setValue("dateFormat", dateFormat);

                        prefs.store();

                }

                else {

                        for (String error : errors) {

                                SessionErrors.add(request, error);

                        }

                }

        }

        

        

                

        private static Log _log = LogFactoryUtil.getLog(BookPortlet.class);

}

file: BookValidator.java

=============================

package com.liferay.training.library.portlet;

import java.text.SimpleDateFormat;

import com.liferay.portal.kernel.util.Validator;

import com.liferay.training.library.model.Book;

import java.util.List;

public class BookValidator {

        /**

         * Validate book

         *

         * @param book

         *            to be validated

         * @param errors

         *            to populate with any errors

         */

        public static boolean validateBook(Book book, List errors) {

                boolean valid = true;

                if (Validator.isNull(book.getTitle())) {

                        errors.add("booktitle-required");

                        valid = false;

                }

                if (Validator.isNull(book.getAuthorName())) {

                        errors.add("bookauthorname-required");

                        valid = false;

                }

                if (Validator.isNull(book.getPublicationDate())) {

                        errors.add("bookpublicationdate-required");

                        valid = false;

                }

                if (Validator.isNull(book.getPublisherId())) {

                        errors.add("publisher-required");

                        valid = false;

                }

                return valid;

        }

        public static boolean validatePreferences(String rowsPerPage,

                        String dateFormat, List errors) {

                boolean valid = true;

                if (Validator.isNull(rowsPerPage)) {

                        errors.add("rowsperpage-required");

                        valid = false;

                }

                else if (!Validator.isNumber(rowsPerPage)) {

                        errors.add("rowsperpage-invalid");

                        valid = false;

                }

                if (Validator.isNull(dateFormat)) {

                        errors.add("dateformat-required");

                        valid = false;

                }

                else {

                        try {

                                SimpleDateFormat df = new SimpleDateFormat(dateFormat);

                        }

                        catch (Exception e) {

                                errors.add("dateformat-invalid");

                                valid = false;

                        }

                }

                return valid;

        }

}

file: PublisherPortlet.java

=============================

        

package com.liferay.training.library.portlet;

import java.util.ArrayList;

import javax.portlet.ActionRequest;

import javax.portlet.ActionResponse;

import javax.portlet.PortletPreferences;

import javax.portlet.PortletRequest;

import com.liferay.portal.kernel.log.Log;

import com.liferay.portal.kernel.log.LogFactoryUtil;

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

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

import com.liferay.portal.kernel.util.ParamUtil;

import com.liferay.portal.kernel.util.Validator;

import com.liferay.portal.kernel.util.WebKeys;

import com.liferay.portal.theme.ThemeDisplay;

import com.liferay.portal.util.PortalUtil;

import com.liferay.training.library.model.Publisher;

import com.liferay.training.library.model.impl.PublisherImpl;

import com.liferay.training.library.service.PublisherLocalServiceUtil;

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

/**

 * Portlet implementation class PublisherPortlet

 */

public class PublisherPortlet extends MVCPortlet {

 

        /**

         * Adds a new publisher to the database

         *

         */

        public void addPublisher(ActionRequest request, ActionResponse response)

                throws Exception {

                Publisher publisher = publisherFromRequest(request);

                ArrayList<String> errors = new ArrayList<String>();

                if (PublisherValidator.validatePublisher(publisher, errors)) {

                        PublisherLocalServiceUtil.addPublisher(publisher);

                        SessionMessages.add(request, "publisher-added");

                        sendRedirect(request, response);

                }

                else {

                        for (String error : errors) {

                                SessionErrors.add(request, error);

                        }

                        PortalUtil.copyRequestParameters(request, response);

                        response.setRenderParameter("jspPage", "/html/publisher/edit_publisher.jsp");

                }

        }

        /**

         * Convenience method to create a Publisher object out of the request. Used

         * by the Add / Edit methods.

         *

         */

        private Publisher publisherFromRequest(PortletRequest request) {

                ThemeDisplay themeDisplay =

                        (ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);

                PublisherImpl publisher = new PublisherImpl();

                publisher.setPublisherId(ParamUtil.getLong(request, "publisherId"));

                publisher.setName(ParamUtil.getString(request, "name"));

                publisher.setEmailAddress(ParamUtil.getString(request, "emailAddress"));

                publisher.setWebsite(ParamUtil.getString(request, "website"));

                publisher.setPhoneNumber(ParamUtil.getString(request, "phoneNumber"));

                publisher.setCompanyId(themeDisplay.getCompanyId());

                publisher.setGroupId(themeDisplay.getScopeGroupId());

                return publisher;

        }

                /**

         * Updates the database record of an existing publisher.

         *

         */

        public void updatePublisher(ActionRequest request, ActionResponse response)

                throws Exception {

                Publisher publisher = publisherFromRequest(request);

                ArrayList<String> errors = new ArrayList<String>();

                if (PublisherValidator.validatePublisher(publisher, errors)) {

                        PublisherLocalServiceUtil.updatePublisher(publisher);

                        SessionMessages.add(request, "publisher-updated");

                        sendRedirect(request, response);

                }

                else {

                        for (String error : errors) {

                                SessionErrors.add(request, error);

                        }

                        PortalUtil.copyRequestParameters(request, response);

                        response.setRenderParameter("jspPage", "/html/publisher/edit_publisher.jsp");

                }

        }

                /**

         * Deletes a publisher from the database.

         *

         */

        public void deletePublisher(ActionRequest request, ActionResponse response)

                throws Exception {

                long publisherId = ParamUtil.getLong(request, "publisherId");

                ArrayList<String> errors = new ArrayList<String>();

                if (Validator.isNotNull(publisherId)) {

                        PublisherLocalServiceUtil.deletePublisher(publisherId);

                        SessionMessages.add(request, "publisher-deleted");

                        sendRedirect(request, response);

                }

                else {

                        SessionErrors.add(request, "error-deleting");

                }

        }

                

        /**

         * Sets the preferences for how many publishers can be viewed

         * per page and the format for the phone number

         *

         */

        public void setPublisherPref(ActionRequest request, ActionResponse response)

                throws Exception {

                String rowsPerPage = ParamUtil.getString(request, "rowsPerPage");

                String phoneFormat = ParamUtil.getString(request, "phoneFormat");

                PortletPreferences prefs = request.getPreferences();

                prefs.setValue("rowsPerPage", rowsPerPage);

                prefs.setValue("phoneFormat", phoneFormat);

                prefs.store();

        }

        

        private static Log _log = LogFactoryUtil.getLog(PublisherPortlet.class);

}

file: PublisherValidator.java

=============================

package com.liferay.training.library.portlet;

import java.util.List;

import com.liferay.portal.kernel.exception.SystemException;

import com.liferay.portal.kernel.util.Validator;

import com.liferay.training.library.model.Book;

import com.liferay.training.library.model.Publisher;

import com.liferay.training.library.service.BookLocalServiceUtil;

public class PublisherValidator {

        /**

         * Verify publisher

         *

         * @param publisher

         *            to be validated

         * @param errors

         *            to populate with any errors

         */

        public static boolean validatePublisher(Publisher publisher, List errors) {

                boolean valid = true;

                if (Validator.isNull(publisher.getName())) {

                        errors.add("publishername-required");

                        valid = false;

                }

                if (Validator.isNull(publisher.getEmailAddress())) {

                        errors.add("publisheremail-required");

                        valid = false;

                }

                if (!Validator.isEmailAddress(publisher.getEmailAddress())) {

                        errors.add("publisheremail-format-error");

                        valid = false;

                }

                if (Validator.isNull(publisher.getWebsite())) {

                        errors.add("publisherwebsite-required");

                        valid = false;

                }

                

                if (Validator.isNull(publisher.getPhoneNumber())) {

                        errors.add("publisherphonenumber-required");

                        valid = false;

                }

                if (!Validator.isPhoneNumber(publisher.getPhoneNumber())) {

                        errors.add("publisherphonenumber-format-error");

                        valid = false;

                }

                return valid;

        }

}

==============================================

folder: docroot/WEB-INF/src/com.liferay.training.library.service.impl

==============================================

file: PublisherLocalServiceImpl.java

================

/**

 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.

 *

 * This library is free software; you can redistribute it and/or modify it under

 * the terms of the GNU Lesser General Public License as published by the Free

 * Software Foundation; either version 2.1 of the License, or (at your option)

 * any later version.

 *

 * This library is distributed in the hope that it will be useful, but WITHOUT

 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS

 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more

 * details.

 */

package com.liferay.training.library.service.impl;

import java.util.List;

import com.liferay.counter.service.CounterLocalServiceUtil;

import com.liferay.portal.kernel.exception.SystemException;

import com.liferay.training.library.model.Publisher;

import com.liferay.training.library.service.base.PublisherLocalServiceBaseImpl;

/**

 * The implementation of the publisher local service.

 *

 * <p>

 * All custom service methods should be put in this class. Whenever methods are added, rerun ServiceBuilder to copy their definitions into the {@link com.liferay.training.library.service.PublisherLocalService} interface.

 *

 * <p>

 * This is a local service. Methods of this service will not have security checks based on the propagated JAAS credentials because this service can only be accessed from within the same VM.

 * </p>

 *

 * @author ICT

 * @see com.liferay.training.library.service.base.PublisherLocalServiceBaseImpl

 * @see com.liferay.training.library.service.PublisherLocalServiceUtil

 */

public class PublisherLocalServiceImpl extends PublisherLocalServiceBaseImpl {

        /*

         * NOTE FOR DEVELOPERS:

         *

         * Never reference this interface directly. Always use {@link com.liferay.training.library.service.PublisherLocalServiceUtil} to access the publisher local service.

         */

        

        /**

         * Adds the Publisher to the database incrementing the primary key

         *

         */

        public Publisher addPublisher(Publisher publisher) throws SystemException {

                long publisherId = CounterLocalServiceUtil.increment(Publisher.class.getName());

                publisher.setPublisherId(publisherId);

                return super.addPublisher(publisher);

        }

        /**

         * Gets a list with all the Publishers in a group

         *

         */

        public List<Publisher> getPublishersByGroupId(long groupId) throws SystemException {

                return publisherPersistence.findByGroupId(groupId);

        }

        /**

         * Gets a list with a range of Publishers from a group

         *

         */

        public List<Publisher> getPublishersByGroupId(long groupId, int start, int end) throws SystemException {

                return publisherPersistence.findByGroupId(groupId, start, end);

        }

        /**

         * Gets the number of Publishers in a group

         *

         */

        public int getPublishersCountByGroupId(long groupId) throws SystemException {

                return publisherPersistence.countByGroupId(groupId);

        }

        

        

}

file: BookLocalServiceImpl.java

================

/**

 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.

 *

 * This library is free software; you can redistribute it and/or modify it under

 * the terms of the GNU Lesser General Public License as published by the Free

 * Software Foundation; either version 2.1 of the License, or (at your option)

 * any later version.

 *

 * This library is distributed in the hope that it will be useful, but WITHOUT

 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS

 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more

 * details.

 */

package com.liferay.training.library.service.impl;

import java.util.List;

import com.liferay.counter.service.CounterLocalServiceUtil;

import com.liferay.portal.kernel.exception.SystemException;

import com.liferay.training.library.model.Book;

import com.liferay.training.library.service.base.BookLocalServiceBaseImpl;

/**

 * The implementation of the book local service.

 *

 * <p>

 * All custom service methods should be put in this class. Whenever methods are added, rerun ServiceBuilder to copy their definitions into the {@link com.liferay.training.library.service.BookLocalService} interface.

 *

 * <p>

 * This is a local service. Methods of this service will not have security checks based on the propagated JAAS credentials because this service can only be accessed from within the same VM.

 * </p>

 *

 * @author ICT

 * @see com.liferay.training.library.service.base.BookLocalServiceBaseImpl

 * @see com.liferay.training.library.service.BookLocalServiceUtil

 */

public class BookLocalServiceImpl extends BookLocalServiceBaseImpl {

        /*

         * NOTE FOR DEVELOPERS:

         *

         * Never reference this interface directly. Always use {@link com.liferay.training.library.service.BookLocalServiceUtil} to access the book local service.

         */

                /**

         * Adds the Book to the database incrementing the primary key

         *

         */

        public Book addBook(Book book) throws SystemException {

                long bookId = CounterLocalServiceUtil.increment(Book.class.getName());

                book.setBookId(bookId);

                return super.addBook(book);

        }

        /**

         * Gets a list with all the Books in a group

         *

         */

        public List<Book> getBooksByGroupId(long groupId) throws SystemException {

                return bookPersistence.findByGroupId(groupId);

        }

        /**

         * Gets a list with a range of Books from a group

         *

         */

        public List<Book> getBooksByGroupId(long groupId, int start, int end) throws SystemException {

                return bookPersistence.findByGroupId(groupId, start, end);

        }

        /**

         * Gets the number of Books in a group

         *

         */

        public int getBooksCountByGroupId(long groupId) throws SystemException {

                return bookPersistence.countByGroupId(groupId);

        }

        /**

         * Gets a list of Books from a Publisher

         *

         */

        public List<Book> getBooksbyPublisher(long publisherId) throws SystemException {

                return bookPersistence.findByPublisher(publisherId);

        }

}

==============================================

folder: docroot/WEB-INF/src/content

==============================================

file:language.properties

================

#Liferay Display Info

category.training=Training

# Messages

publisher-added-successfully=Publisher was Added Successfully

publisher-deleted-successfully=Publisher was Deleted Successfully

publisher-empty-results-message=There are no publishers to display.

publisher-updated-successfully=Publisher was Updated Successfully

add-publisher-button=Add Publisher Button

publisher-email=Email Address

publisher-name=Publisher Name

publisher-phonenumber=Phone Number

publisher-website=Web Site

publisheremail-format-error=Publisher Email Format Error

publisheremail-required=Publisher Email is Required

publishername-required=Publisher Name is Required

publisherphonenumber-format-error=Publisher Phone Number Format Error

publisherphonenumber-required=Publisher Phone Number is Required

publisherwebsite-required=Publisher Web Site is Required

new-publisher=New Publisher

publisher-emailAddress-lbl=Publisher Email Address

publisher-name-lbl=Publisher Name

publisher-phoneNumber-lbl=Publisher Phone Number

publisher-website-lbl=Publisher Web Site

add-book-button=Add Book Button

book-added-successfully=Book was Added Successfully

book-deleted-successfully=Book was Deleted Successfully

book-empty-results-message=There are no books to display.

book-updated-successfully=Book was Updated Successfully

book-author=Author Name

book-publication-date=Book Publication Date

book-publisher=Book Publisher

book-title=Book Title

bookauthorname-required=Book Author Name is Required

bookpublicationdate-required=Book Publication Date is Required

booktitle-required=Book Title is Required

publisher-required=Publisher ID is Required

bookHelp=This portlet allows users to add view, add, edit, and books from the system.

dateformat-invalid=Dateformat is invalid

dateformat-required=Dateformat is required

rowsperpage-invalid=Rows Per Page Invalid

rowsperpage-required=Rowsperpage is Required

book-authorName-lbl=Book Author Name

book-publicationDate-lbl=Book Publication Date

book-publisherID-lbl=Book Publisher ID

book-title-lbl=Book Title

new-book=New Book

==============================================

folder: docroot/html/book

==============================================

file: book_actions.jsp

================

<%@include file="/html/init.jsp" %>

<%

ResultRow row = (ResultRow)request.getAttribute(WebKeys.SEARCH_CONTAINER_RESULT_ROW);

Book book = (Book)row.getObject();

long groupId = book.getGroupId();

String name = Book.class.getName();

long bookId = book.getBookId();

String redirect = PortalUtil.getCurrentURL(renderRequest);

%>

<liferay-ui:icon-menu >

        <portlet:renderURL var="editURL">

                <portlet:param name="jspPage" value="/html/book/edit_book.jsp" />

                <portlet:param name="bookId" value="<%= String.valueOf(bookId) %>"/>

                <portlet:param name="redirect" value="<%= redirect %>"/>

        </portlet:renderURL>

        <liferay-ui:icon image="edit" url="<%=editURL.toString() %>" />

        <portlet:actionURL name="deleteBook" var="deleteURL">

                <portlet:param name="bookId" value="<%= String.valueOf(bookId) %>" />

                <portlet:param name="redirect" value="<%= PortalUtil.getCurrentURL(renderRequest) %>"/>

        </portlet:actionURL>

                

        <liferay-ui:icon image="delete" url="<%=deleteURL.toString() %>" />

</liferay-ui:icon-menu>

file: edit_book.jsp

==============

<%@include file="/html/init.jsp"%>

<%

Book book = null;

long bookId = ParamUtil.getLong(request, "bookId");

if (bookId > 0) {

        book = BookLocalServiceUtil.getBook(bookId);

}

List<Publisher> publishers = PublisherLocalServiceUtil.getPublishersByGroupId(scopeGroupId);

String redirect = ParamUtil.getString(request, "redirect");

%>

<liferay-ui:header

        backURL="<%= redirect %>"

        title='<%= (book != null) ? book.getTitle(locale) : "new-book" %>'

/>

<aui:model-context bean="<%= book %>" model="<%= Book.class %>" />

<portlet:actionURL name='<%= book == null ? "addBook" : "updateBook" %>' var="editBookURL" />

<aui:form action="<%= editBookURL %>" method="POST" name="fm">

        <aui:fieldset>

                                

                <aui:input type="hidden" name="redirect" value="<%= redirect %>" />

                <aui:input type="hidden" name="bookId" value='<%= book == null ? "" : book.getBookId() %>'/>

                <liferay-ui:error key="booktitle-required" message="booktitle-required"/>

                <aui:input name="title" label="book-title-lbl"/>

                <liferay-ui:error key="bookauthorname-required" message="bookauthorname-required" />

                <aui:input name="authorName" label="book-authorName-lbl"/>

                <liferay-ui:error key="bookpublicationdate-required" message="bookpublicationdate-required" />

                <aui:input name="publicationDate" label="book-publicationDate-lbl"/>

                <liferay-ui:error key="publisher-required" message="publisher-required" />

                <aui:select name="publisherId" label="book-publisherID-lbl" showEmptyOption="<%= true %>">

                                <%

                                for(Publisher publisher: publishers){

                                %>

                                <aui:option value="<%= publisher.getPublisherId() %>" selected="<%= book != null && publisher.getPublisherId() == book.getPublisherId() %>"><%=publisher.getName()%></aui:option>

                                <%

                                }

                                %>

                </aui:select>

                

        </aui:fieldset>

        <aui:button-row>

                <aui:button type="submit" />

                <aui:button type="cancel" onClick="<%= redirect %>" />

        </aui:button-row>

</aui:form>

file: edit.jsp

========

<%--

/**

* Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.

*

* This library is free software; you can redistribute it and/or modify it under

* the terms of the GNU Lesser General Public License as published by the Free

* Software Foundation; either version 2.1 of the License, or (at your option)

* any later version.

*

* This library is distributed in the hope that it will be useful, but WITHOUT

* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS

* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more

* details.

*/

--%>

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

<portlet:defineObjects />

This is the <b>Liferay Book</b> portlet in Edit mode.

file: help.jsp

========

<%--

/**

* Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.

*

* This library is free software; you can redistribute it and/or modify it under

* the terms of the GNU Lesser General Public License as published by the Free

* Software Foundation; either version 2.1 of the License, or (at your option)

* any later version.

*

* This library is distributed in the hope that it will be useful, but WITHOUT

* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS

* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more

* details.

*/

--%>

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

<portlet:defineObjects />

This is the <b>Liferay Book</b> portlet in Help mode.

file: view.jsp

========

<%--

/**

* Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.

*

* This library is free software; you can redistribute it and/or modify it under

* the terms of the GNU Lesser General Public License as published by the Free

* Software Foundation; either version 2.1 of the License, or (at your option)

* any later version.

*

* This library is distributed in the hope that it will be useful, but WITHOUT

* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS

* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more

* details.

*/

--%>

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

<portlet:defineObjects />

This is the <b>Liferay Book</b> portlet in View mode.

<%@include file="/html/init.jsp" %>

<liferay-ui:success key="book-added" message="book-added-successfully" />

<liferay-ui:success key="book-updated" message="book-updated-successfully" />

<liferay-ui:success key="book-deleted" message="book-deleted-successfully" />

<%

String redirect = PortalUtil.getCurrentURL(renderRequest);

%>

<aui:button-row>

        <portlet:renderURL var="addBookURL">

                <portlet:param name="jspPage" value="/html/book/edit_book.jsp" />

                <portlet:param name="redirect" value="<%= redirect %>" />

        </portlet:renderURL>

        <aui:button name="addBookButton" value="add-book-button" onClick="<%=addBookURL %>"/>

</aui:button-row>

<liferay-ui:search-container delta='<%= new Integer(prefs.getValue("rowsPerPage", "5")) %>' emptyResultsMessage="book-empty-results-message">

        <liferay-ui:search-container-results

                results="<%= BookLocalServiceUtil.getBooksByGroupId(scopeGroupId, searchContainer.getStart(), searchContainer.getEnd()) %>"

                total="<%= BookLocalServiceUtil.getBooksCountByGroupId(scopeGroupId) %>"

        />

        <liferay-ui:search-container-row

                className="com.liferay.training.library.model.Book"

                keyProperty="bookId"

                modelVar="book"

        >

                <liferay-ui:search-container-column-text

                        name="book-title"

                        value="<%= book.getTitle(locale) %>"

                />

                <liferay-ui:search-container-column-text

                        name="book-author"

                        property="authorName"

                />

                <%

                SimpleDateFormat dateFormat = new SimpleDateFormat(prefs.getValue("dateFormat", "yyyy/MM/dd"));

                %>

                <liferay-ui:search-container-column-text

                        name="book-publication-date"

                        value="<%= dateFormat.format(book.getPublicationDate()) %>"

                />

                <%

                String publisherName = "";

                try {

                        publisherName =        PublisherLocalServiceUtil.getPublisher(book.getPublisherId()).getName();

                }

                catch (Exception ex) {

                }

                %>

                <liferay-ui:search-container-column-text

                        name="book-publisher"

                        value="<%= publisherName %>"

                />

                <liferay-ui:search-container-column-jsp

                        align="right"

                        path="/html/book/book_actions.jsp"

                />

        </liferay-ui:search-container-row>

        <liferay-ui:search-iterator />

</liferay-ui:search-container>

==============================================

folder: docroot/html/publisher

==============================================

file: edit_publisher.jsp

==================

<%@include file="/html/init.jsp" %>

<%

        Publisher publisher = null;

        long publisherId = ParamUtil.getLong(request, "publisherId");

        if (publisherId > 0) {

                publisher = PublisherLocalServiceUtil.getPublisher(publisherId);

        }

        String redirect = ParamUtil.getString(request, "redirect");

%>

<liferay-ui:header

        backURL="<%= redirect %>"

        title='<%= (publisher != null) ? publisher.getName() : "new-publisher" %>'

/>

<aui:model-context bean="<%= publisher %>" model="<%= Publisher.class %>" />

<portlet:actionURL name='<%= publisher == null ? "addPublisher" : "updatePublisher" %>' var="editPublisherURL" />

<aui:form action="<%= editPublisherURL %>" method="POST" name="fm">

                <aui:input type="hidden" name="redirect" value="<%= redirect %>" />

                <aui:input type="hidden" name="publisherId" value='<%= publisher == null ? "" : publisher.getPublisherId() %>'/>

                <liferay-ui:error key="publishername-required" message="publishername-required" />

                <aui:input name="name" label="publisher-name-lbl"/>

                <liferay-ui:error key="publisheremail-required" message="publisheremail-required" />

                <liferay-ui:error key="publisheremail-format-error"        message="publisheremail-format-error" />

                <aui:input name="emailAddress" label="publisher-emailAddress-lbl"/>

                <liferay-ui:error key="publisherwebsite-required" message="publisherwebsite-required" />

                <aui:input name="website" label="publisher-website-lbl"/>

                <liferay-ui:error key="publisherphonenumber-required" message="publisherphonenumber-required" />

                <liferay-ui:error key="publisherphonenumber-format-error" message="publisherphonenumber-format-error" />

                <aui:input name="phoneNumber" label="publisher-phoneNumber-lbl"/>

                

        <aui:button-row>

                <aui:button type="submit" />

                <aui:button type="cancel"  onClick="<%= redirect %>" />

        </aui:button-row>

</aui:form>

file: edit.jsp

========

<%--

/**

* Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.

*

* This library is free software; you can redistribute it and/or modify it under

* the terms of the GNU Lesser General Public License as published by the Free

* Software Foundation; either version 2.1 of the License, or (at your option)

* any later version.

*

* This library is distributed in the hope that it will be useful, but WITHOUT

* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS

* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more

* details.

*/

--%>

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

<portlet:defineObjects />

This is the <b>Liferay Publisher</b> portlet in Edit mode.

<%@include file="/html/init.jsp" %>

<portlet:actionURL name="setPublisherPref" var="setPublisherPrefUrl" />

<aui:form action="<%= setPublisherPrefUrl %>" method="POST" name="fm" >

        <aui:input name="rowsPerPage" value='<%= prefs.getValue("rowsPerPage","") %>' size="45" type="text" />

        <aui:input name="phoneFormat" value='<%= prefs.getValue("phoneFormat","") %>' size="45" type="text"  />

        <aui:button-row>

                <aui:button type="submit" />

        </aui:button-row>

</aui:form>

file: help.jsp

========

<%--

/**

* Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.

*

* This library is free software; you can redistribute it and/or modify it under

* the terms of the GNU Lesser General Public License as published by the Free

* Software Foundation; either version 2.1 of the License, or (at your option)

* any later version.

*

* This library is distributed in the hope that it will be useful, but WITHOUT

* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS

* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more

* details.

*/

--%>

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

<portlet:defineObjects />

This is the <b>Liferay Publisher</b> portlet in Help mode.

file: publisher_actions.jsp

=====================

<%@include file="/html/init.jsp" %>

<%

ResultRow row = (ResultRow)request.getAttribute(WebKeys.SEARCH_CONTAINER_RESULT_ROW);

Publisher publisher = (Publisher)row.getObject();

long groupId = publisher.getGroupId();

String name = Publisher.class.getName();

long publisherId = publisher.getPublisherId();

String redirect = PortalUtil.getCurrentURL(renderRequest);

%>

<liferay-ui:icon-menu>

        <portlet:renderURL var="editURL">

                <portlet:param name="jspPage" value="/html/publisher/edit_publisher.jsp" />

                <portlet:param name="publisherId" value="<%= String.valueOf(publisherId) %>"/>

                <portlet:param name="redirect" value="<%= redirect %>"/>

        </portlet:renderURL>

        

        <liferay-ui:icon image="edit" url="<%=editURL.toString() %>" />

        <portlet:actionURL name="deletePublisher" var="deleteURL">

                <portlet:param name="publisherId" value="<%= String.valueOf(publisherId) %>" />

                <portlet:param name="redirect" value="<%= redirect %>"/>

        </portlet:actionURL>

                

        <liferay-ui:icon image="delete" url="<%=deleteURL.toString() %>" />

</liferay-ui:icon-menu>

file: view.jsp

========

<%--

/**

* Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.

*

* This library is free software; you can redistribute it and/or modify it under

* the terms of the GNU Lesser General Public License as published by the Free

* Software Foundation; either version 2.1 of the License, or (at your option)

* any later version.

*

* This library is distributed in the hope that it will be useful, but WITHOUT

* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS

* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more

* details.

*/

--%>

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

<portlet:defineObjects />

This is the <b>Liferay Publisher</b> portlet in View mode.

<%@include file="/html/init.jsp" %>

<liferay-ui:success key="publisher-added" message="publisher-added-successfully" />

<liferay-ui:success key="publisher-updated" message="publisher-updated-successfully" />

<liferay-ui:success key="publisher-deleted" message="publisher-deleted-successfully" />

<%

        String redirect = PortalUtil.getCurrentURL(renderRequest);        

%>

<aui:button-row>

        <portlet:renderURL var="addPublisherURL">

                <portlet:param name="jspPage" value="/html/publisher/edit_publisher.jsp" />

                <portlet:param name="redirect" value="<%= redirect %>" />

        </portlet:renderURL>

        <aui:button name="addpublisherbutton" value="add-publisher-button" onClick="<%= addPublisherURL.toString() %>"/>

</aui:button-row>

<liferay-ui:search-container delta='<%= GetterUtil.getInteger(prefs.getValue("rowsPerPage", "5")) %>' emptyResultsMessage="publisher-empty-results-message">

        <liferay-ui:search-container-results

                results="<%= PublisherLocalServiceUtil.getPublishersByGroupId(scopeGroupId, searchContainer.getStart(), searchContainer.getEnd()) %>"

                total="<%= PublisherLocalServiceUtil.getPublishersCountByGroupId(scopeGroupId) %>"

        />

        <liferay-ui:search-container-row

                className="com.liferay.training.library.model.Publisher"

                keyProperty="publisherId"

                modelVar="publisher"

        >

                <liferay-ui:search-container-column-text

                        name="publisher-name"

                        value="<%= publisher.getName() %>"

                />

                <liferay-ui:search-container-column-text

                        name="publisher-email"

                        property="emailAddress"

                />

                <liferay-ui:search-container-column-text

                        name="publisher-phonenumber"

                        property="phoneNumber"

                />

                <liferay-ui:search-container-column-text

                        name="publisher-website"

                        property="website"

                />

                <liferay-ui:search-container-column-jsp

                        align="right"

                        path="/html/publisher/publisher_actions.jsp"

                />

        </liferay-ui:search-container-row>

        <liferay-ui:search-iterator />

</liferay-ui:search-container>

==============================================

folder: docroot/html/

==============================================

init.jsp

========

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

<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>

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

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

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

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

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

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

<%@ page import="java.util.List" %>

<%@ page import="java.text.SimpleDateFormat" %>

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

<%@ page import="com.liferay.portal.kernel.dao.search.ResultRow" %>

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

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

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

<%@ page import="com.liferay.portal.model.Group"%>

<%@ page import="com.liferay.portal.security.permission.ActionKeys"%>

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

<%@ page import="com.liferay.training.library.model.Book"%>

<%@ page import="com.liferay.training.library.model.Publisher"%>

<%@ page import="com.liferay.training.library.service.BookLocalServiceUtil"%>

<%@ page import="com.liferay.training.library.service.PublisherLocalServiceUtil"%>

<liferay-theme:defineObjects />

<portlet:defineObjects />

<%

PortletPreferences prefs = renderRequest.getPreferences();

%>

================================================

folder: WEB-INF/service/com/liferay/training/library/model/

================================================

file: Book.java

=========

/**

 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.

 *

 * This library is free software; you can redistribute it and/or modify it under

 * the terms of the GNU Lesser General Public License as published by the Free

 * Software Foundation; either version 2.1 of the License, or (at your option)

 * any later version.

 *

 * This library is distributed in the hope that it will be useful, but WITHOUT

 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS

 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more

 * details.

 */

package com.liferay.training.library.model;

import com.liferay.portal.model.PersistedModel;

/**

 * The extended model interface for the Book service. Represents a row in the &quot;Library_Book&quot; database table, with each column mapped to a property of this class.

 *

 * @author ICT

 * @see BookModel

 * @see com.liferay.training.library.model.impl.BookImpl

 * @see com.liferay.training.library.model.impl.BookModelImpl

 * @generated

 */

public interface Book extends BookModel, PersistedModel {

        /*

         * NOTE FOR DEVELOPERS:

         *

         * Never modify this interface directly. Add methods to {@link com.liferay.training.library.model.impl.BookImpl} and rerun ServiceBuilder to automatically copy the method declarations to this interface.

         */

}

BookClp.java

============

/**

 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.

 *

 * This library is free software; you can redistribute it and/or modify it under

 * the terms of the GNU Lesser General Public License as published by the Free

 * Software Foundation; either version 2.1 of the License, or (at your option)

 * any later version.

 *

 * This library is distributed in the hope that it will be useful, but WITHOUT

 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS

 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more

 * details.

 */

package com.liferay.training.library.model;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;

import com.liferay.portal.kernel.exception.SystemException;

import com.liferay.portal.kernel.language.LanguageUtil;

import com.liferay.portal.kernel.util.LocaleUtil;

import com.liferay.portal.kernel.util.LocalizationUtil;

import com.liferay.portal.kernel.util.PortalClassLoaderUtil;

import com.liferay.portal.kernel.util.StringBundler;

import com.liferay.portal.kernel.util.Validator;

import com.liferay.portal.model.impl.BaseModelImpl;

import com.liferay.training.library.service.BookLocalServiceUtil;

import java.io.Serializable;

import java.lang.reflect.Proxy;

import java.util.Date;

import java.util.Locale;

import java.util.Map;

/**

 * @author ICT

 */

public class BookClp extends BaseModelImpl<Book> implements Book {

        public BookClp() {

        }

        public Class<?> getModelClass() {

                return Book.class;

        }

        public String getModelClassName() {

                return Book.class.getName();

        }

        public long getPrimaryKey() {

                return _bookId;

        }

        public void setPrimaryKey(long primaryKey) {

                setBookId(primaryKey);

        }

        public Serializable getPrimaryKeyObj() {

                return new Long(_bookId);

        }

        public void setPrimaryKeyObj(Serializable primaryKeyObj) {

                setPrimaryKey(((Long)primaryKeyObj).longValue());

        }

        public long getBookId() {

                return _bookId;

        }

        public void setBookId(long bookId) {

                _bookId = bookId;

        }

        public long getCompanyId() {

                return _companyId;

        }

        public void setCompanyId(long companyId) {

                _companyId = companyId;

        }

        public long getGroupId() {

                return _groupId;

        }

        public void setGroupId(long groupId) {

                _groupId = groupId;

        }

        public long getPublisherId() {

                return _publisherId;

        }

        public void setPublisherId(long publisherId) {

                _publisherId = publisherId;

        }

        public String getTitle() {

                return _title;

        }

        public String getTitle(Locale locale) {

                String languageId = LocaleUtil.toLanguageId(locale);

                return getTitle(languageId);

        }

        public String getTitle(Locale locale, boolean useDefault) {

                String languageId = LocaleUtil.toLanguageId(locale);

                return getTitle(languageId, useDefault);

        }

        public String getTitle(String languageId) {

                return LocalizationUtil.getLocalization(getTitle(), languageId);

        }

        public String getTitle(String languageId, boolean useDefault) {

                return LocalizationUtil.getLocalization(getTitle(), languageId,

                        useDefault);

        }

        public String getTitleCurrentLanguageId() {

                return _titleCurrentLanguageId;

        }

        public String getTitleCurrentValue() {

                Locale locale = getLocale(_titleCurrentLanguageId);

                return getTitle(locale);

        }

        public Map<Locale, String> getTitleMap() {

                return LocalizationUtil.getLocalizationMap(getTitle());

        }

        public void setTitle(String title) {

                _title = title;

        }

        public void setTitle(String title, Locale locale) {

                setTitle(title, locale, LocaleUtil.getDefault());

        }

        public void setTitle(String title, Locale locale, Locale defaultLocale) {

                String languageId = LocaleUtil.toLanguageId(locale);

                String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);

                if (Validator.isNotNull(title)) {

                        setTitle(LocalizationUtil.updateLocalization(getTitle(), "Title",

                                        title, languageId, defaultLanguageId));

                }

                else {

                        setTitle(LocalizationUtil.removeLocalization(getTitle(), "Title",

                                        languageId));

                }

        }

        public void setTitleCurrentLanguageId(String languageId) {

                _titleCurrentLanguageId = languageId;

        }

        public void setTitleMap(Map<Locale, String> titleMap) {

                setTitleMap(titleMap, LocaleUtil.getDefault());

        }

        public void setTitleMap(Map<Locale, String> titleMap, Locale defaultLocale) {

                if (titleMap == null) {

                        return;

                }

                ClassLoader portalClassLoader = PortalClassLoaderUtil.getClassLoader();

                Thread currentThread = Thread.currentThread();

                ClassLoader contextClassLoader = currentThread.getContextClassLoader();

                try {

                        if (contextClassLoader != portalClassLoader) {

                                currentThread.setContextClassLoader(portalClassLoader);

                        }

                        Locale[] locales = LanguageUtil.getAvailableLocales();

                        for (Locale locale : locales) {

                                String title = titleMap.get(locale);

                                setTitle(title, locale, defaultLocale);

                        }

                }

                finally {

                        if (contextClassLoader != portalClassLoader) {

                                currentThread.setContextClassLoader(contextClassLoader);

                        }

                }

        }

        public String getAuthorName() {

                return _authorName;

        }

        public void setAuthorName(String authorName) {

                _authorName = authorName;

        }

        public Date getPublicationDate() {

                return _publicationDate;

        }

        public void setPublicationDate(Date publicationDate) {

                _publicationDate = publicationDate;

        }

        public void persist() throws SystemException {

                if (this.isNew()) {

                        BookLocalServiceUtil.addBook(this);

                }

                else {

                        BookLocalServiceUtil.updateBook(this);

                }

        }

        @Override

        public Book toEscapedModel() {

                return (Book)Proxy.newProxyInstance(Book.class.getClassLoader(),

                        new Class[] { Book.class }, new AutoEscapeBeanHandler(this));

        }

        @Override

        public Object clone() {

                BookClp clone = new BookClp();

                clone.setBookId(getBookId());

                clone.setCompanyId(getCompanyId());

                clone.setGroupId(getGroupId());

                clone.setPublisherId(getPublisherId());

                clone.setTitle(getTitle());

                clone.setAuthorName(getAuthorName());

                clone.setPublicationDate(getPublicationDate());

                return clone;

        }

        public int compareTo(Book book) {

                int value = 0;

                value = getTitle().compareTo(book.getTitle());

                if (value != 0) {

                        return value;

                }

                return 0;

        }

        @Override

        public boolean equals(Object obj) {

                if (obj == null) {

                        return false;

                }

                BookClp book = null;

                try {

                        book = (BookClp)obj;

                }

                catch (ClassCastException cce) {

                        return false;

                }

                long primaryKey = book.getPrimaryKey();

                if (getPrimaryKey() == primaryKey) {

                        return true;

                }

                else {

                        return false;

                }

        }

        @Override

        public int hashCode() {

                return (int)getPrimaryKey();

        }

        @Override

        public String toString() {

                StringBundler sb = new StringBundler(15);

                sb.append("{bookId=");

                sb.append(getBookId());

                sb.append(", companyId=");

                sb.append(getCompanyId());

                sb.append(", groupId=");

                sb.append(getGroupId());

                sb.append(", publisherId=");

                sb.append(getPublisherId());

                sb.append(", title=");

                sb.append(getTitle());

                sb.append(", authorName=");

                sb.append(getAuthorName());

                sb.append(", publicationDate=");

                sb.append(getPublicationDate());

                sb.append("}");

                return sb.toString();

        }

        public String toXmlString() {

                StringBundler sb = new StringBundler(25);

                sb.append("<model><model-name>");

                sb.append("com.liferay.training.library.model.Book");

                sb.append("</model-name>");

                sb.append(

                        "<column><column-name>bookId</column-name><column-value><![CDATA[");

                sb.append(getBookId());

                sb.append("]]></column-value></column>");

                sb.append(

                        "<column><column-name>companyId</column-name><column-value><![CDATA[");

                sb.append(getCompanyId());

                sb.append("]]></column-value></column>");

                sb.append(

                        "<column><column-name>groupId</column-name><column-value><![CDATA[");

                sb.append(getGroupId());

                sb.append("]]></column-value></column>");

                sb.append(

                        "<column><column-name>publisherId</column-name><column-value><![CDATA[");

                sb.append(getPublisherId());

                sb.append("]]></column-value></column>");

                sb.append(

                        "<column><column-name>title</column-name><column-value><![CDATA[");

                sb.append(getTitle());

                sb.append("]]></column-value></column>");

                sb.append(

                        "<column><column-name>authorName</column-name><column-value><![CDATA[");

                sb.append(getAuthorName());

                sb.append("]]></column-value></column>");

                sb.append(

                        "<column><column-name>publicationDate</column-name><column-value><![CDATA[");

                sb.append(getPublicationDate());

                sb.append("]]></column-value></column>");

                sb.append("</model>");

                return sb.toString();

        }

        private long _bookId;

        private long _companyId;

        private long _groupId;

        private long _publisherId;

        private String _title;

        private String _titleCurrentLanguageId;

        private String _authorName;

        private Date _publicationDate;

}

BookModel.java

==============

/**

 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.

 *

 * This library is free software; you can redistribute it and/or modify it under

 * the terms of the GNU Lesser General Public License as published by the Free

 * Software Foundation; either version 2.1 of the License, or (at your option)

 * any later version.

 *

 * This library is distributed in the hope that it will be useful, but WITHOUT

 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS

 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more

 * details.

 */

package com.liferay.training.library.model;

import com.liferay.portal.kernel.bean.AutoEscape;

import com.liferay.portal.model.BaseModel;

import com.liferay.portal.model.CacheModel;

import com.liferay.portal.service.ServiceContext;

import com.liferay.portlet.expando.model.ExpandoBridge;

import java.io.Serializable;

import java.util.Date;

import java.util.Locale;

import java.util.Map;

/**

 * The base model interface for the Book service. Represents a row in the &quot;Library_Book&quot; database table, with each column mapped to a property of this class.

 *

 * <p>

 * This interface and its corresponding implementation {@link com.liferay.training.library.model.impl.BookModelImpl} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link com.liferay.training.library.model.impl.BookImpl}.

 * </p>

 *

 * @author ICT

 * @see Book

 * @see com.liferay.training.library.model.impl.BookImpl

 * @see com.liferay.training.library.model.impl.BookModelImpl

 * @generated

 */

public interface BookModel extends BaseModel<Book> {

        /*

         * NOTE FOR DEVELOPERS:

         *

         * Never modify or reference this interface directly. All methods that expect a book model instance should use the {@link Book} interface instead.

         */

        /**

         * Returns the primary key of this book.

         *

         * @return the primary key of this book

         */

        public long getPrimaryKey();

        /**

         * Sets the primary key of this book.

         *

         * @param primaryKey the primary key of this book

         */

        public void setPrimaryKey(long primaryKey);

        /**

         * Returns the book ID of this book.

         *

         * @return the book ID of this book

         */

        public long getBookId();

        /**

         * Sets the book ID of this book.

         *

         * @param bookId the book ID of this book

         */

        public void setBookId(long bookId);

        /**

         * Returns the company ID of this book.

         *

         * @return the company ID of this book

         */

        public long getCompanyId();

        /**

         * Sets the company ID of this book.

         *

         * @param companyId the company ID of this book

         */

        public void setCompanyId(long companyId);

        /**

         * Returns the group ID of this book.

         *

         * @return the group ID of this book

         */

        public long getGroupId();

        /**

         * Sets the group ID of this book.

         *

         * @param groupId the group ID of this book

         */

        public void setGroupId(long groupId);

        /**

         * Returns the publisher ID of this book.

         *

         * @return the publisher ID of this book

         */

        public long getPublisherId();

        /**

         * Sets the publisher ID of this book.

         *

         * @param publisherId the publisher ID of this book

         */

        public void setPublisherId(long publisherId);

        /**

         * Returns the title of this book.

         *

         * @return the title of this book

         */

        public String getTitle();

        /**

         * Returns the localized title of this book in the language. Uses the default language if no localization exists for the requested language.

         *

         * @param locale the locale of the language

         * @return the localized title of this book

         */

        @AutoEscape

        public String getTitle(Locale locale);

        /**

         * Returns the localized title of this book in the language, optionally using the default language if no localization exists for the requested language.

         *

         * @param locale the local of the language

         * @param useDefault whether to use the default language if no localization exists for the requested language

         * @return the localized title of this book. If <code>useDefault</code> is <code>false</code> and no localization exists for the requested language, an empty string will be returned.

         */

        @AutoEscape

        public String getTitle(Locale locale, boolean useDefault);

        /**

         * Returns the localized title of this book in the language. Uses the default language if no localization exists for the requested language.

         *

         * @param languageId the ID of the language

         * @return the localized title of this book

         */

        @AutoEscape

        public String getTitle(String languageId);

        /**

         * Returns the localized title of this book in the language, optionally using the default language if no localization exists for the requested language.

         *

         * @param languageId the ID of the language

         * @param useDefault whether to use the default language if no localization exists for the requested language

         * @return the localized title of this book

         */

        @AutoEscape

        public String getTitle(String languageId, boolean useDefault);

        @AutoEscape

        public String getTitleCurrentLanguageId();

        @AutoEscape

        public String getTitleCurrentValue();

        /**

         * Returns a map of the locales and localized titles of this book.

         *

         * @return the locales and localized titles of this book

         */

        public Map<Locale, String> getTitleMap();

        /**

         * Sets the title of this book.

         *

         * @param title the title of this book

         */

        public void setTitle(String title);

        /**

         * Sets the localized title of this book in the language.

         *

         * @param title the localized title of this book

         * @param locale the locale of the language

         */

        public void setTitle(String title, Locale locale);

        /**

         * Sets the localized title of this book in the language, and sets the default locale.

         *

         * @param title the localized title of this book

         * @param locale the locale of the language

         * @param defaultLocale the default locale

         */

        public void setTitle(String title, Locale locale, Locale defaultLocale);

        public void setTitleCurrentLanguageId(String languageId);

        /**

         * Sets the localized titles of this book from the map of locales and localized titles.

         *

         * @param titleMap the locales and localized titles of this book

         */

        public void setTitleMap(Map<Locale, String> titleMap);

        /**

         * Sets the localized titles of this book from the map of locales and localized titles, and sets the default locale.

         *

         * @param titleMap the locales and localized titles of this book

         * @param defaultLocale the default locale

         */

        public void setTitleMap(Map<Locale, String> titleMap, Locale defaultLocale);

        /**

         * Returns the author name of this book.

         *

         * @return the author name of this book

         */

        @AutoEscape

        public String getAuthorName();

        /**

         * Sets the author name of this book.

         *

         * @param authorName the author name of this book

         */

        public void setAuthorName(String authorName);

        /**

         * Returns the publication date of this book.

         *

         * @return the publication date of this book

         */

        public Date getPublicationDate();

        /**

         * Sets the publication date of this book.

         *

         * @param publicationDate the publication date of this book

         */

        public void setPublicationDate(Date publicationDate);

        public boolean isNew();

        public void setNew(boolean n);

        public boolean isCachedModel();

        public void setCachedModel(boolean cachedModel);

        public boolean isEscapedModel();

        public Serializable getPrimaryKeyObj();

        public void setPrimaryKeyObj(Serializable primaryKeyObj);

        public ExpandoBridge getExpandoBridge();

        public void setExpandoBridgeAttributes(ServiceContext serviceContext);

        public Object clone();

        public int compareTo(Book book);

        public int hashCode();

        public CacheModel<Book> toCacheModel();

        public Book toEscapedModel();

        public String toString();

        public String toXmlString();

}

BookSoap.java

=============

/**

 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.

 *

 * This library is free software; you can redistribute it and/or modify it under

 * the terms of the GNU Lesser General Public License as published by the Free

 * Software Foundation; either version 2.1 of the License, or (at your option)

 * any later version.

 *

 * This library is distributed in the hope that it will be useful, but WITHOUT

 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS

 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more

 * details.

 */

package com.liferay.training.library.model;

import java.io.Serializable;

import java.util.ArrayList;

import java.util.Date;

import java.util.List;

/**

 * This class is used by SOAP remote services.

 *

 * @author    ICT

 * @generated

 */

public class BookSoap implements Serializable {

        public static BookSoap toSoapModel(Book model) {

                BookSoap soapModel = new BookSoap();

                soapModel.setBookId(model.getBookId());

                soapModel.setCompanyId(model.getCompanyId());

                soapModel.setGroupId(model.getGroupId());

                soapModel.setPublisherId(model.getPublisherId());

                soapModel.setTitle(model.getTitle());

                soapModel.setAuthorName(model.getAuthorName());

                soapModel.setPublicationDate(model.getPublicationDate());

                return soapModel;

        }

        public static BookSoap[] toSoapModels(Book[] models) {

                BookSoap[] soapModels = new BookSoap[models.length];

                for (int i = 0; i < models.length; i++) {

                        soapModels[i] = toSoapModel(models[i]);

                }

                return soapModels;

        }

        public static BookSoap[][] toSoapModels(Book[][] models) {

                BookSoap[][] soapModels = null;

                if (models.length > 0) {

                        soapModels = new BookSoap[models.length][models[0].length];

                }

                else {

                        soapModels = new BookSoap[0][0];

                }

                for (int i = 0; i < models.length; i++) {

                        soapModels[i] = toSoapModels(models[i]);

                }

                return soapModels;

        }

        public static BookSoap[] toSoapModels(List<Book> models) {

                List<BookSoap> soapModels = new ArrayList<BookSoap>(models.size());

                for (Book model : models) {

                        soapModels.add(toSoapModel(model));

                }

                return soapModels.toArray(new BookSoap[soapModels.size()]);

        }

        public BookSoap() {

        }

        public long getPrimaryKey() {

                return _bookId;

        }

        public void setPrimaryKey(long pk) {

                setBookId(pk);

        }

        public long getBookId() {

                return _bookId;

        }

        public void setBookId(long bookId) {

                _bookId = bookId;

        }

        public long getCompanyId() {

                return _companyId;

        }

        public void setCompanyId(long companyId) {

                _companyId = companyId;

        }

        public long getGroupId() {

                return _groupId;

        }

        public void setGroupId(long groupId) {

                _groupId = groupId;

        }

        public long getPublisherId() {

                return _publisherId;

        }

        public void setPublisherId(long publisherId) {

                _publisherId = publisherId;

        }

        public String getTitle() {

                return _title;

        }

        public void setTitle(String title) {

                _title = title;

        }

        public String getAuthorName() {

                return _authorName;

        }

        public void setAuthorName(String authorName) {

                _authorName = authorName;

        }

        public Date getPublicationDate() {

                return _publicationDate;

        }

        public void setPublicationDate(Date publicationDate) {

                _publicationDate = publicationDate;

        }

        private long _bookId;

        private long _companyId;

        private long _groupId;

        private long _publisherId;

        private String _title;

        private String _authorName;

        private Date _publicationDate;

}

BookWrapper.java

================

/**

 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.

 *

 * This library is free software; you can redistribute it and/or modify it under

 * the terms of the GNU Lesser General Public License as published by the Free

 * Software Foundation; either version 2.1 of the License, or (at your option)

 * any later version.

 *

 * This library is distributed in the hope that it will be useful, but WITHOUT

 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS

 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more

 * details.

 */

package com.liferay.training.library.model;

import com.liferay.portal.model.ModelWrapper;

/**

 * <p>

 * This class is a wrapper for {@link Book}.

 * </p>

 *

 * @author    ICT

 * @see       Book

 * @generated

 */

public class BookWrapper implements Book, ModelWrapper<Book> {

        public BookWrapper(Book book) {

                _book = book;

        }

        public Class<?> getModelClass() {

                return Book.class;

        }

        public String getModelClassName() {

                return Book.class.getName();

        }

        /**

        * Returns the primary key of this book.

        *

        * @return the primary key of this book

        */

        public long getPrimaryKey() {

                return _book.getPrimaryKey();

        }

        /**

        * Sets the primary key of this book.

        *

        * @param primaryKey the primary key of this book

        */

        public void setPrimaryKey(long primaryKey) {

                _book.setPrimaryKey(primaryKey);

        }

        /**

        * Returns the book ID of this book.

        *

        * @return the book ID of this book

        */

        public long getBookId() {

                return _book.getBookId();

        }

        /**

        * Sets the book ID of this book.

        *

        * @param bookId the book ID of this book

        */

        public void setBookId(long bookId) {

                _book.setBookId(bookId);

        }

        /**

        * Returns the company ID of this book.

        *

        * @return the company ID of this book

        */

        public long getCompanyId() {

                return _book.getCompanyId();

        }

        /**

        * Sets the company ID of this book.

        *

        * @param companyId the company ID of this book

        */

        public void setCompanyId(long companyId) {

                _book.setCompanyId(companyId);

        }

        /**

        * Returns the group ID of this book.

        *

        * @return the group ID of this book

        */

        public long getGroupId() {

                return _book.getGroupId();

        }

        /**

        * Sets the group ID of this book.

        *

        * @param groupId the group ID of this book

        */

        public void setGroupId(long groupId) {

                _book.setGroupId(groupId);

        }

        /**

        * Returns the publisher ID of this book.

        *

        * @return the publisher ID of this book

        */

        public long getPublisherId() {

                return _book.getPublisherId();

        }

        /**

        * Sets the publisher ID of this book.

        *

        * @param publisherId the publisher ID of this book

        */

        public void setPublisherId(long publisherId) {

                _book.setPublisherId(publisherId);

        }

        /**

        * Returns the title of this book.

        *

        * @return the title of this book

        */

        public java.lang.String getTitle() {

                return _book.getTitle();

        }

        /**

        * Returns the localized title of this book in the language. Uses the default language if no localization exists for the requested language.

        *

        * @param locale the locale of the language

        * @return the localized title of this book

        */

        public java.lang.String getTitle(java.util.Locale locale) {

                return _book.getTitle(locale);

        }

        /**

        * Returns the localized title of this book in the language, optionally using the default language if no localization exists for the requested language.

        *

        * @param locale the local of the language

        * @param useDefault whether to use the default language if no localization exists for the requested language

        * @return the localized title of this book. If <code>useDefault</code> is <code>false</code> and no localization exists for the requested language, an empty string will be returned.

        */

        public java.lang.String getTitle(java.util.Locale locale, boolean useDefault) {

                return _book.getTitle(locale, useDefault);

        }

        /**

        * Returns the localized title of this book in the language. Uses the default language if no localization exists for the requested language.

        *

        * @param languageId the ID of the language

        * @return the localized title of this book

        */

        public java.lang.String getTitle(java.lang.String languageId) {

                return _book.getTitle(languageId);

        }

        /**

        * Returns the localized title of this book in the language, optionally using the default language if no localization exists for the requested language.

        *

        * @param languageId the ID of the language

        * @param useDefault whether to use the default language if no localization exists for the requested language

        * @return the localized title of this book

        */

        public java.lang.String getTitle(java.lang.String languageId,

                boolean useDefault) {

                return _book.getTitle(languageId, useDefault);

        }

        public java.lang.String getTitleCurrentLanguageId() {

                return _book.getTitleCurrentLanguageId();

        }

        public java.lang.String getTitleCurrentValue() {

                return _book.getTitleCurrentValue();

        }

        /**

        * Returns a map of the locales and localized titles of this book.

        *

        * @return the locales and localized titles of this book

        */

        public java.util.Map<java.util.Locale, java.lang.String> getTitleMap() {

                return _book.getTitleMap();

        }

        /**

        * Sets the title of this book.

        *

        * @param title the title of this book

        */

        public void setTitle(java.lang.String title) {

                _book.setTitle(title);

        }

        /**

        * Sets the localized title of this book in the language.

        *

        * @param title the localized title of this book

        * @param locale the locale of the language

        */

        public void setTitle(java.lang.String title, java.util.Locale locale) {

                _book.setTitle(title, locale);

        }

        /**

        * Sets the localized title of this book in the language, and sets the default locale.

        *

        * @param title the localized title of this book

        * @param locale the locale of the language

        * @param defaultLocale the default locale

        */

        public void setTitle(java.lang.String title, java.util.Locale locale,

                java.util.Locale defaultLocale) {

                _book.setTitle(title, locale, defaultLocale);

        }

        public void setTitleCurrentLanguageId(java.lang.String languageId) {

                _book.setTitleCurrentLanguageId(languageId);

        }

        /**

        * Sets the localized titles of this book from the map of locales and localized titles.

        *

        * @param titleMap the locales and localized titles of this book

        */

        public void setTitleMap(

                java.util.Map<java.util.Locale, java.lang.String> titleMap) {

                _book.setTitleMap(titleMap);

        }

        /**

        * Sets the localized titles of this book from the map of locales and localized titles, and sets the default locale.

        *

        * @param titleMap the locales and localized titles of this book

        * @param defaultLocale the default locale

        */

        public void setTitleMap(

                java.util.Map<java.util.Locale, java.lang.String> titleMap,

                java.util.Locale defaultLocale) {

                _book.setTitleMap(titleMap, defaultLocale);

        }

        /**

        * Returns the author name of this book.

        *

        * @return the author name of this book

        */

        public java.lang.String getAuthorName() {

                return _book.getAuthorName();

        }

        /**

        * Sets the author name of this book.

        *

        * @param authorName the author name of this book

        */

        public void setAuthorName(java.lang.String authorName) {

                _book.setAuthorName(authorName);

        }

        /**

        * Returns the publication date of this book.

        *

        * @return the publication date of this book

        */

        public java.util.Date getPublicationDate() {

                return _book.getPublicationDate();

        }

        /**

        * Sets the publication date of this book.

        *

        * @param publicationDate the publication date of this book

        */

        public void setPublicationDate(java.util.Date publicationDate) {

                _book.setPublicationDate(publicationDate);

        }

        public boolean isNew() {

                return _book.isNew();

        }

        public void setNew(boolean n) {

                _book.setNew(n);

        }

        public boolean isCachedModel() {

                return _book.isCachedModel();

        }

        public void setCachedModel(boolean cachedModel) {

                _book.setCachedModel(cachedModel);

        }

        public boolean isEscapedModel() {

                return _book.isEscapedModel();

        }

        public java.io.Serializable getPrimaryKeyObj() {

                return _book.getPrimaryKeyObj();

        }

        public void setPrimaryKeyObj(java.io.Serializable primaryKeyObj) {

                _book.setPrimaryKeyObj(primaryKeyObj);

        }

        public com.liferay.portlet.expando.model.ExpandoBridge getExpandoBridge() {

                return _book.getExpandoBridge();

        }

        public void setExpandoBridgeAttributes(

                com.liferay.portal.service.ServiceContext serviceContext) {

                _book.setExpandoBridgeAttributes(serviceContext);

        }

        @Override

        public java.lang.Object clone() {

                return new BookWrapper((Book)_book.clone());

        }

        public int compareTo(com.liferay.training.library.model.Book book) {

                return _book.compareTo(book);

        }

        @Override

        public int hashCode() {

                return _book.hashCode();

        }

        public com.liferay.portal.model.CacheModel<com.liferay.training.library.model.Book> toCacheModel() {

                return _book.toCacheModel();

        }

        public com.liferay.training.library.model.Book toEscapedModel() {

                return new BookWrapper(_book.toEscapedModel());

        }

        @Override

        public java.lang.String toString() {

                return _book.toString();

        }

        public java.lang.String toXmlString() {

                return _book.toXmlString();

        }

        public void persist()

                throws com.liferay.portal.kernel.exception.SystemException {

                _book.persist();

        }

        /**

         * @deprecated Renamed to {@link #getWrappedModel}

         */

        public Book getWrappedBook() {

                return _book;

        }

        public Book getWrappedModel() {

                return _book;

        }

        public void resetOriginalValues() {

                _book.resetOriginalValues();

        }

        private Book _book;

}

Publisher.java

==============

/**

 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.

 *

 * This library is free software; you can redistribute it and/or modify it under

 * the terms of the GNU Lesser General Public License as published by the Free

 * Software Foundation; either version 2.1 of the License, or (at your option)

 * any later version.

 *

 * This library is distributed in the hope that it will be useful, but WITHOUT

 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS

 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more

 * details.

 */

package com.liferay.training.library.model;

import com.liferay.portal.model.PersistedModel;

/**

 * The extended model interface for the Publisher service. Represents a row in the &quot;Library_Publisher&quot; database table, with each column mapped to a property of this class.

 *

 * @author ICT

 * @see PublisherModel

 * @see com.liferay.training.library.model.impl.PublisherImpl

 * @see com.liferay.training.library.model.impl.PublisherModelImpl

 * @generated

 */

public interface Publisher extends PublisherModel, PersistedModel {

        /*

         * NOTE FOR DEVELOPERS:

         *

         * Never modify this interface directly. Add methods to {@link com.liferay.training.library.model.impl.PublisherImpl} and rerun ServiceBuilder to automatically copy the method declarations to this interface.

         */

}

PublisherClp.java

=================

/**

 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.

 *

 * This library is free software; you can redistribute it and/or modify it under

 * the terms of the GNU Lesser General Public License as published by the Free

 * Software Foundation; either version 2.1 of the License, or (at your option)

 * any later version.

 *

 * This library is distributed in the hope that it will be useful, but WITHOUT

 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS

 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more

 * details.

 */

package com.liferay.training.library.model;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;

import com.liferay.portal.kernel.exception.SystemException;

import com.liferay.portal.kernel.util.StringBundler;

import com.liferay.portal.model.impl.BaseModelImpl;

import com.liferay.training.library.service.PublisherLocalServiceUtil;

import java.io.Serializable;

import java.lang.reflect.Proxy;

/**

 * @author ICT

 */

public class PublisherClp extends BaseModelImpl<Publisher> implements Publisher {

        public PublisherClp() {

        }

        public Class<?> getModelClass() {

                return Publisher.class;

        }

        public String getModelClassName() {

                return Publisher.class.getName();

        }

        public long getPrimaryKey() {

                return _publisherId;

        }

        public void setPrimaryKey(long primaryKey) {

                setPublisherId(primaryKey);

        }

        public Serializable getPrimaryKeyObj() {

                return new Long(_publisherId);

        }

        public void setPrimaryKeyObj(Serializable primaryKeyObj) {

                setPrimaryKey(((Long)primaryKeyObj).longValue());

        }

        public long getPublisherId() {

                return _publisherId;

        }

        public void setPublisherId(long publisherId) {

                _publisherId = publisherId;

        }

        public long getCompanyId() {

                return _companyId;

        }

        public void setCompanyId(long companyId) {

                _companyId = companyId;

        }

        public long getGroupId() {

                return _groupId;

        }

        public void setGroupId(long groupId) {

                _groupId = groupId;

        }

        public String getName() {

                return _name;

        }

        public void setName(String name) {

                _name = name;

        }

        public String getEmailAddress() {

                return _emailAddress;

        }

        public void setEmailAddress(String emailAddress) {

                _emailAddress = emailAddress;

        }

        public String getWebsite() {

                return _website;

        }

        public void setWebsite(String website) {

                _website = website;

        }

        public String getPhoneNumber() {

                return _phoneNumber;

        }

        public void setPhoneNumber(String phoneNumber) {

                _phoneNumber = phoneNumber;

        }

        public void persist() throws SystemException {

                if (this.isNew()) {

                        PublisherLocalServiceUtil.addPublisher(this);

                }

                else {

                        PublisherLocalServiceUtil.updatePublisher(this);

                }

        }

        @Override

        public Publisher toEscapedModel() {

                return (Publisher)Proxy.newProxyInstance(Publisher.class.getClassLoader(),

                        new Class[] { Publisher.class }, new AutoEscapeBeanHandler(this));

        }

        @Override

        public Object clone() {

                PublisherClp clone = new PublisherClp();

                clone.setPublisherId(getPublisherId());

                clone.setCompanyId(getCompanyId());

                clone.setGroupId(getGroupId());

                clone.setName(getName());

                clone.setEmailAddress(getEmailAddress());

                clone.setWebsite(getWebsite());

                clone.setPhoneNumber(getPhoneNumber());

                return clone;

        }

        public int compareTo(Publisher publisher) {

                int value = 0;

                value = getName().compareTo(publisher.getName());

                if (value != 0) {

                        return value;

                }

                return 0;

        }

        @Override

        public boolean equals(Object obj) {

                if (obj == null) {

                        return false;

                }

                PublisherClp publisher = null;

                try {

                        publisher = (PublisherClp)obj;

                }

                catch (ClassCastException cce) {

                        return false;

                }

                long primaryKey = publisher.getPrimaryKey();

                if (getPrimaryKey() == primaryKey) {

                        return true;

                }

                else {

                        return false;

                }

        }

        @Override

        public int hashCode() {

                return (int)getPrimaryKey();

        }

        @Override

        public String toString() {

                StringBundler sb = new StringBundler(15);

                sb.append("{publisherId=");

                sb.append(getPublisherId());

                sb.append(", companyId=");

                sb.append(getCompanyId());

                sb.append(", groupId=");

                sb.append(getGroupId());

                sb.append(", name=");

                sb.append(getName());

                sb.append(", emailAddress=");

                sb.append(getEmailAddress());

                sb.append(", website=");

                sb.append(getWebsite());

                sb.append(", phoneNumber=");

                sb.append(getPhoneNumber());

                sb.append("}");

                return sb.toString();

        }

        public String toXmlString() {

                StringBundler sb = new StringBundler(25);

                sb.append("<model><model-name>");

                sb.append("com.liferay.training.library.model.Publisher");

                sb.append("</model-name>");

                sb.append(

                        "<column><column-name>publisherId</column-name><column-value><![CDATA[");

                sb.append(getPublisherId());

                sb.append("]]></column-value></column>");

                sb.append(

                        "<column><column-name>companyId</column-name><column-value><![CDATA[");

                sb.append(getCompanyId());

                sb.append("]]></column-value></column>");

                sb.append(

                        "<column><column-name>groupId</column-name><column-value><![CDATA[");

                sb.append(getGroupId());

                sb.append("]]></column-value></column>");

                sb.append(

                        "<column><column-name>name</column-name><column-value><![CDATA[");

                sb.append(getName());

                sb.append("]]></column-value></column>");

                sb.append(

                        "<column><column-name>emailAddress</column-name><column-value><![CDATA[");

                sb.append(getEmailAddress());

                sb.append("]]></column-value></column>");

                sb.append(

                        "<column><column-name>website</column-name><column-value><![CDATA[");

                sb.append(getWebsite());

                sb.append("]]></column-value></column>");

                sb.append(

                        "<column><column-name>phoneNumber</column-name><column-value><![CDATA[");

                sb.append(getPhoneNumber());

                sb.append("]]></column-value></column>");

                sb.append("</model>");

                return sb.toString();

        }

        private long _publisherId;

        private long _companyId;

        private long _groupId;

        private String _name;

        private String _emailAddress;

        private String _website;

        private String _phoneNumber;

}

PublisherModel.java

===================

/**

 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.

 *

 * This library is free software; you can redistribute it and/or modify it under

 * the terms of the GNU Lesser General Public License as published by the Free

 * Software Foundation; either version 2.1 of the License, or (at your option)

 * any later version.

 *

 * This library is distributed in the hope that it will be useful, but WITHOUT

 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS

 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more

 * details.

 */

package com.liferay.training.library.model;

import com.liferay.portal.kernel.bean.AutoEscape;

import com.liferay.portal.model.BaseModel;

import com.liferay.portal.model.CacheModel;

import com.liferay.portal.service.ServiceContext;

import com.liferay.portlet.expando.model.ExpandoBridge;

import java.io.Serializable;

/**

 * The base model interface for the Publisher service. Represents a row in the &quot;Library_Publisher&quot; database table, with each column mapped to a property of this class.

 *

 * <p>

 * This interface and its corresponding implementation {@link com.liferay.training.library.model.impl.PublisherModelImpl} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link com.liferay.training.library.model.impl.PublisherImpl}.

 * </p>

 *

 * @author ICT

 * @see Publisher

 * @see com.liferay.training.library.model.impl.PublisherImpl

 * @see com.liferay.training.library.model.impl.PublisherModelImpl

 * @generated

 */

public interface PublisherModel extends BaseModel<Publisher> {

        /*

         * NOTE FOR DEVELOPERS:

         *

         * Never modify or reference this interface directly. All methods that expect a publisher model instance should use the {@link Publisher} interface instead.

         */

        /**

         * Returns the primary key of this publisher.

         *

         * @return the primary key of this publisher

         */

        public long getPrimaryKey();

        /**

         * Sets the primary key of this publisher.

         *

         * @param primaryKey the primary key of this publisher

         */

        public void setPrimaryKey(long primaryKey);

        /**

         * Returns the publisher ID of this publisher.

         *

         * @return the publisher ID of this publisher

         */

        public long getPublisherId();

        /**

         * Sets the publisher ID of this publisher.

         *

         * @param publisherId the publisher ID of this publisher

         */

        public void setPublisherId(long publisherId);

        /**

         * Returns the company ID of this publisher.

         *

         * @return the company ID of this publisher

         */

        public long getCompanyId();

        /**

         * Sets the company ID of this publisher.

         *

         * @param companyId the company ID of this publisher

         */

        public void setCompanyId(long companyId);

        /**

         * Returns the group ID of this publisher.

         *

         * @return the group ID of this publisher

         */

        public long getGroupId();

        /**

         * Sets the group ID of this publisher.

         *

         * @param groupId the group ID of this publisher

         */

        public void setGroupId(long groupId);

        /**

         * Returns the name of this publisher.

         *

         * @return the name of this publisher

         */

        @AutoEscape

        public String getName();

        /**

         * Sets the name of this publisher.

         *

         * @param name the name of this publisher

         */

        public void setName(String name);

        /**

         * Returns the email address of this publisher.

         *

         * @return the email address of this publisher

         */

        @AutoEscape

        public String getEmailAddress();

        /**

         * Sets the email address of this publisher.

         *

         * @param emailAddress the email address of this publisher

         */

        public void setEmailAddress(String emailAddress);

        /**

         * Returns the website of this publisher.

         *

         * @return the website of this publisher

         */

        @AutoEscape

        public String getWebsite();

        /**

         * Sets the website of this publisher.

         *

         * @param website the website of this publisher

         */

        public void setWebsite(String website);

        /**

         * Returns the phone number of this publisher.

         *

         * @return the phone number of this publisher

         */

        @AutoEscape

        public String getPhoneNumber();

        /**

         * Sets the phone number of this publisher.

         *

         * @param phoneNumber the phone number of this publisher

         */

        public void setPhoneNumber(String phoneNumber);

        public boolean isNew();

        public void setNew(boolean n);

        public boolean isCachedModel();

        public void setCachedModel(boolean cachedModel);

        public boolean isEscapedModel();

        public Serializable getPrimaryKeyObj();

        public void setPrimaryKeyObj(Serializable primaryKeyObj);

        public ExpandoBridge getExpandoBridge();

        public void setExpandoBridgeAttributes(ServiceContext serviceContext);

        public Object clone();

        public int compareTo(Publisher publisher);

        public int hashCode();

        public CacheModel<Publisher> toCacheModel();

        public Publisher toEscapedModel();

        public String toString();

        public String toXmlString();

}

PublisherSoap.java

==================

/**

 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.

 *

 * This library is free software; you can redistribute it and/or modify it under

 * the terms of the GNU Lesser General Public License as published by the Free

 * Software Foundation; either version 2.1 of the License, or (at your option)

 * any later version.

 *

 * This library is distributed in the hope that it will be useful, but WITHOUT

 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS

 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more

 * details.

 */

package com.liferay.training.library.model;

import java.io.Serializable;

import java.util.ArrayList;

import java.util.List;

/**

 * This class is used by SOAP remote services.

 *

 * @author    ICT

 * @generated

 */

public class PublisherSoap implements Serializable {

        public static PublisherSoap toSoapModel(Publisher model) {

                PublisherSoap soapModel = new PublisherSoap();

                soapModel.setPublisherId(model.getPublisherId());

                soapModel.setCompanyId(model.getCompanyId());

                soapModel.setGroupId(model.getGroupId());

                soapModel.setName(model.getName());

                soapModel.setEmailAddress(model.getEmailAddress());

                soapModel.setWebsite(model.getWebsite());

                soapModel.setPhoneNumber(model.getPhoneNumber());

                return soapModel;

        }

        public static PublisherSoap[] toSoapModels(Publisher[] models) {

                PublisherSoap[] soapModels = new PublisherSoap[models.length];

                for (int i = 0; i < models.length; i++) {

                        soapModels[i] = toSoapModel(models[i]);

                }

                return soapModels;

        }

        public static PublisherSoap[][] toSoapModels(Publisher[][] models) {

                PublisherSoap[][] soapModels = null;

                if (models.length > 0) {

                        soapModels = new PublisherSoap[models.length][models[0].length];

                }

                else {

                        soapModels = new PublisherSoap[0][0];

                }

                for (int i = 0; i < models.length; i++) {

                        soapModels[i] = toSoapModels(models[i]);

                }

                return soapModels;

        }

        public static PublisherSoap[] toSoapModels(List<Publisher> models) {

                List<PublisherSoap> soapModels = new ArrayList<PublisherSoap>(models.size());

                for (Publisher model : models) {

                        soapModels.add(toSoapModel(model));

                }

                return soapModels.toArray(new PublisherSoap[soapModels.size()]);

        }

        public PublisherSoap() {

        }

        public long getPrimaryKey() {

                return _publisherId;

        }

        public void setPrimaryKey(long pk) {

                setPublisherId(pk);

        }

        public long getPublisherId() {

                return _publisherId;

        }

        public void setPublisherId(long publisherId) {

                _publisherId = publisherId;

        }

        public long getCompanyId() {

                return _companyId;

        }

        public void setCompanyId(long companyId) {

                _companyId = companyId;

        }

        public long getGroupId() {

                return _groupId;

        }

        public void setGroupId(long groupId) {

                _groupId = groupId;

        }

        public String getName() {

                return _name;

        }

        public void setName(String name) {

                _name = name;

        }

        public String getEmailAddress() {

                return _emailAddress;

        }

        public void setEmailAddress(String emailAddress) {

                _emailAddress = emailAddress;

        }

        public String getWebsite() {

                return _website;

        }

        public void setWebsite(String website) {

                _website = website;

        }

        public String getPhoneNumber() {

                return _phoneNumber;

        }

        public void setPhoneNumber(String phoneNumber) {

                _phoneNumber = phoneNumber;

        }

        private long _publisherId;

        private long _companyId;

        private long _groupId;

        private String _name;

        private String _emailAddress;

        private String _website;

        private String _phoneNumber;

}

PublisherWrapper.java

=====================

/**

 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.

 *

 * This library is free software; you can redistribute it and/or modify it under

 * the terms of the GNU Lesser General Public License as published by the Free

 * Software Foundation; either version 2.1 of the License, or (at your option)

 * any later version.

 *

 * This library is distributed in the hope that it will be useful, but WITHOUT

 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS

 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more

 * details.

 */

package com.liferay.training.library.model;

import com.liferay.portal.model.ModelWrapper;

/**

 * <p>

 * This class is a wrapper for {@link Publisher}.

 * </p>

 *

 * @author    ICT

 * @see       Publisher

 * @generated

 */

public class PublisherWrapper implements Publisher, ModelWrapper<Publisher> {

        public PublisherWrapper(Publisher publisher) {

                _publisher = publisher;

        }

        public Class<?> getModelClass() {

                return Publisher.class;

        }

        public String getModelClassName() {

                return Publisher.class.getName();

        }

        /**

        * Returns the primary key of this publisher.

        *

        * @return the primary key of this publisher

        */

        public long getPrimaryKey() {

                return _publisher.getPrimaryKey();

        }

        /**

        * Sets the primary key of this publisher.

        *

        * @param primaryKey the primary key of this publisher

        */

        public void setPrimaryKey(long primaryKey) {

                _publisher.setPrimaryKey(primaryKey);

        }

        /**

        * Returns the publisher ID of this publisher.

        *

        * @return the publisher ID of this publisher

        */

        public long getPublisherId() {

                return _publisher.getPublisherId();

        }

        /**

        * Sets the publisher ID of this publisher.

        *

        * @param publisherId the publisher ID of this publisher

        */

        public void setPublisherId(long publisherId) {

                _publisher.setPublisherId(publisherId);

        }

        /**

        * Returns the company ID of this publisher.

        *

        * @return the company ID of this publisher

        */

        public long getCompanyId() {

                return _publisher.getCompanyId();

        }

        /**

        * Sets the company ID of this publisher.

        *

        * @param companyId the company ID of this publisher

        */

        public void setCompanyId(long companyId) {

                _publisher.setCompanyId(companyId);

        }

        /**

        * Returns the group ID of this publisher.

        *

        * @return the group ID of this publisher

        */

        public long getGroupId() {

                return _publisher.getGroupId();

        }

        /**

        * Sets the group ID of this publisher.

        *

        * @param groupId the group ID of this publisher

        */

        public void setGroupId(long groupId) {

                _publisher.setGroupId(groupId);

        }

        /**

        * Returns the name of this publisher.

        *

        * @return the name of this publisher

        */

        public java.lang.String getName() {

                return _publisher.getName();

        }

        /**

        * Sets the name of this publisher.

        *

        * @param name the name of this publisher

        */

        public void setName(java.lang.String name) {

                _publisher.setName(name);

        }

        /**

        * Returns the email address of this publisher.

        *

        * @return the email address of this publisher

        */

        public java.lang.String getEmailAddress() {

                return _publisher.getEmailAddress();

        }

        /**

        * Sets the email address of this publisher.

        *

        * @param emailAddress the email address of this publisher

        */

        public void setEmailAddress(java.lang.String emailAddress) {

                _publisher.setEmailAddress(emailAddress);

        }

        /**

        * Returns the website of this publisher.

        *

        * @return the website of this publisher

        */

        public java.lang.String getWebsite() {

                return _publisher.getWebsite();

        }

        /**

        * Sets the website of this publisher.

        *

        * @param website the website of this publisher

        */

        public void setWebsite(java.lang.String website) {

                _publisher.setWebsite(website);

        }

        /**

        * Returns the phone number of this publisher.

        *

        * @return the phone number of this publisher

        */

        public java.lang.String getPhoneNumber() {

                return _publisher.getPhoneNumber();

        }

        /**

        * Sets the phone number of this publisher.

        *

        * @param phoneNumber the phone number of this publisher

        */

        public void setPhoneNumber(java.lang.String phoneNumber) {

                _publisher.setPhoneNumber(phoneNumber);

        }

        public boolean isNew() {

                return _publisher.isNew();

        }

        public void setNew(boolean n) {

                _publisher.setNew(n);

        }

        public boolean isCachedModel() {

                return _publisher.isCachedModel();

        }

        public void setCachedModel(boolean cachedModel) {

                _publisher.setCachedModel(cachedModel);

        }

        public boolean isEscapedModel() {

                return _publisher.isEscapedModel();

        }

        public java.io.Serializable getPrimaryKeyObj() {

                return _publisher.getPrimaryKeyObj();

        }

        public void setPrimaryKeyObj(java.io.Serializable primaryKeyObj) {

                _publisher.setPrimaryKeyObj(primaryKeyObj);

        }

        public com.liferay.portlet.expando.model.ExpandoBridge getExpandoBridge() {

                return _publisher.getExpandoBridge();

        }

        public void setExpandoBridgeAttributes(

                com.liferay.portal.service.ServiceContext serviceContext) {

                _publisher.setExpandoBridgeAttributes(serviceContext);

        }

        @Override

        public java.lang.Object clone() {

                return new PublisherWrapper((Publisher)_publisher.clone());

        }

        public int compareTo(com.liferay.training.library.model.Publisher publisher) {

                return _publisher.compareTo(publisher);

        }

        @Override

        public int hashCode() {

                return _publisher.hashCode();

        }

        public com.liferay.portal.model.CacheModel<com.liferay.training.library.model.Publisher> toCacheModel() {

                return _publisher.toCacheModel();

        }

        public com.liferay.training.library.model.Publisher toEscapedModel() {

                return new PublisherWrapper(_publisher.toEscapedModel());

        }

        @Override

        public java.lang.String toString() {

                return _publisher.toString();

        }

        public java.lang.String toXmlString() {

                return _publisher.toXmlString();

        }

        public void persist()

                throws com.liferay.portal.kernel.exception.SystemException {

                _publisher.persist();

        }

        /**

         * @deprecated Renamed to {@link #getWrappedModel}

         */

        public Publisher getWrappedPublisher() {

                return _publisher;

        }

        public Publisher getWrappedModel() {

                return _publisher;

        }

        public void resetOriginalValues() {

                _publisher.resetOriginalValues();

        }

        private Publisher _publisher;

}

================================================

folder: WEB-INF/service/com/liferay/training/library/service/

================================================

NoSuchBookException.java

========================

/**

 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.

 *

 * This library is free software; you can redistribute it and/or modify it under

 * the terms of the GNU Lesser General Public License as published by the Free

 * Software Foundation; either version 2.1 of the License, or (at your option)

 * any later version.

 *

 * This library is distributed in the hope that it will be useful, but WITHOUT

 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS

 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more

 * details.

 */

package com.liferay.training.library;

import com.liferay.portal.NoSuchModelException;

/**

 * @author ICT

 */

public class NoSuchBookException extends NoSuchModelException {

        public NoSuchBookException() {

                super();

        }

        public NoSuchBookException(String msg) {

                super(msg);

        }

        public NoSuchBookException(String msg, Throwable cause) {

                super(msg, cause);

        }

        public NoSuchBookException(Throwable cause) {

                super(cause);

        }

}

NoSuchPublisherException.java

=============================

/**

 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.

 *

 * This library is free software; you can redistribute it and/or modify it under

 * the terms of the GNU Lesser General Public License as published by the Free

 * Software Foundation; either version 2.1 of the License, or (at your option)

 * any later version.

 *

 * This library is distributed in the hope that it will be useful, but WITHOUT

 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS

 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more

 * details.

 */

package com.liferay.training.library;

import com.liferay.portal.NoSuchModelException;

/**

 * @author ICT

 */

public class NoSuchPublisherException extends NoSuchModelException {

        public NoSuchPublisherException() {

                super();

        }

        public NoSuchPublisherException(String msg) {

                super(msg);

        }

        public NoSuchPublisherException(String msg, Throwable cause) {

                super(msg, cause);

        }

        public NoSuchPublisherException(Throwable cause) {

                super(cause);

        }

}

================================================

folder: WEB-INF/sql/

================================================

indexes.property

================

IX_A3958D57=Library_Book.GroupId

IX_2686E4D4=Library_Book.Publisher

IX_9F8DE96C=Library_Publisher.GroupId

indexes.sql

===========

create index IX_A3958D57 on Library_Book (groupId);

create index IX_2686E4D4 on Library_Book (publisherId);

create index IX_9F8DE96C on Library_Publisher (groupId);

tables.sql

==========

create table Library_Book (

        bookId LONG not null primary key,

        companyId LONG,

        groupId LONG,

        publisherId LONG,

        title STRING null,

        authorName VARCHAR(75) null,

        publicationDate DATE null

);

create table Library_Publisher (

        publisherId LONG not null primary key,

        companyId LONG,

        groupId LONG,

        name VARCHAR(75) null,

        emailAddress VARCHAR(75) null,

        website VARCHAR(75) null,

        phoneNumber VARCHAR(75) null

);

================================================

folder: WEB-INF/

================================================

liferay-display.xml

===================

<?xml version="1.0"?>

<!DOCTYPE display PUBLIC "-//Liferay//DTD Display 6.1.0//EN" "http://www.liferay.com/dtd/liferay-display_6_1_0.dtd">

<display>

        

        <category name="category.training">

                <portlet id="liferay-publisher"></portlet>

                <portlet id="liferay-book"></portlet>

        </category>

</display>

liferay-plugin-package.properties

=================================

name=Library

module-group-id=liferay

module-incremental-version=1

tags=

short-description=

change-log=

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

author=Liferay, Inc.

licenses=LGPL

portal-dependency-jars=\

    jstl-api.jar,\

    jstl-impl.jar

portal-dependency-tlds=c.tld

liferay-portlet.xml

===================

<?xml version="1.0"?>

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

<liferay-portlet-app>

        

        <portlet>

                <portlet-name>liferay-publisher</portlet-name>

                <icon>/icon.png</icon>

                <instanceable>false</instanceable>

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

                <footer-portlet-javascript>

                        /js/main.js

                </footer-portlet-javascript>

                <css-class-wrapper>liferay-publisher-portlet</css-class-wrapper>

        </portlet>

        <portlet>

                <portlet-name>liferay-book</portlet-name>

                <icon>/icon.png</icon>

                <instanceable>false</instanceable>

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

                <footer-portlet-javascript>

                        /js/main.js

                </footer-portlet-javascript>

                <css-class-wrapper>liferay-book-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>

portlet.xml

===========

<?xml version="1.0"?>

<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>liferay-publisher</portlet-name>

                <display-name>Liferay Publisher</display-name>

                <portlet-class>

                        com.liferay.training.library.portlet.PublisherPortlet

                </portlet-class>

                <init-param>

                        <name>view-jsp</name>

                        <value>/html/publisher/view.jsp</value>

                </init-param>

                <init-param>

                        <name>edit-jsp</name>

                        <value>/html/publisher/edit.jsp</value>

                </init-param>

                <init-param>

                        <name>help-jsp</name>

                        <value>/html/publisher/help.jsp</value>

                </init-param>

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

                <supports>

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

                        <portlet-mode>view</portlet-mode>

                        <portlet-mode>edit</portlet-mode>

                        <portlet-mode>help</portlet-mode>

                </supports>

                <resource-bundle>content/Language</resource-bundle>

                <portlet-info>

                        <title>Liferay Publisher</title>

                        <short-title>PublisherPortlet</short-title>

                        <keywords></keywords>

                </portlet-info>

                

                <!-- Portlet preferences (configurable by user in portlet EDIT mode) -->

                <portlet-preferences>

                        <preference>

                                <name>rowsPerPage</name>

                                <value>5</value>

                        </preference>

                        <preference>

                                <name>phoneFormat</name>

                                <value>###-###-####</value>

                        </preference>

                </portlet-preferences>

                

                <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>

                <portlet-name>liferay-book</portlet-name>

                <display-name>Liferay Book</display-name>

                <portlet-class>

                        com.liferay.training.library.portlet.BookPortlet

                </portlet-class>

                <init-param>

                        <name>view-jsp</name>

                        <value>/html/book/view.jsp</value>

                </init-param>

                <init-param>

                        <name>edit-jsp</name>

                        <value>/html/book/edit.jsp</value>

                </init-param>

                <init-param>

                        <name>help-jsp</name>

                        <value>/html/book/help.jsp</value>

                </init-param>

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

                <supports>

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

                        <portlet-mode>view</portlet-mode>

                        <portlet-mode>edit</portlet-mode>

                        <portlet-mode>help</portlet-mode>

                </supports>

                <resource-bundle>content/Language</resource-bundle>

                <portlet-info>

                        <title>Liferay Book</title>

                        <short-title>BookPortlet</short-title>

                        <keywords></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>

portlet.xml

===========

<?xml version="1.0"?>

<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>liferay-publisher</portlet-name>

                <display-name>Liferay Publisher</display-name>

                <portlet-class>

                        com.liferay.training.library.portlet.PublisherPortlet

                </portlet-class>

                <init-param>

                        <name>view-jsp</name>

                        <value>/html/publisher/view.jsp</value>

                </init-param>

                <init-param>

                        <name>edit-jsp</name>

                        <value>/html/publisher/edit.jsp</value>

                </init-param>

                <init-param>

                        <name>help-jsp</name>

                        <value>/html/publisher/help.jsp</value>

                </init-param>

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

                <supports>

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

                        <portlet-mode>view</portlet-mode>

                        <portlet-mode>edit</portlet-mode>

                        <portlet-mode>help</portlet-mode>

                </supports>

                <resource-bundle>content/Language</resource-bundle>

                <portlet-info>

                        <title>Liferay Publisher</title>

                        <short-title>PublisherPortlet</short-title>

                        <keywords></keywords>

                </portlet-info>

                

                <!-- Portlet preferences (configurable by user in portlet EDIT mode) -->

                <portlet-preferences>

                        <preference>

                                <name>rowsPerPage</name>

                                <value>5</value>

                        </preference>

                        <preference>

                                <name>phoneFormat</name>

                                <value>###-###-####</value>

                        </preference>

                </portlet-preferences>

                

                <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>

                <portlet-name>liferay-book</portlet-name>

                <display-name>Liferay Book</display-name>

                <portlet-class>

                        com.liferay.training.library.portlet.BookPortlet

                </portlet-class>

                <init-param>

                        <name>view-jsp</name>

                        <value>/html/book/view.jsp</value>

                </init-param>

                <init-param>

                        <name>edit-jsp</name>

                        <value>/html/book/edit.jsp</value>

                </init-param>

                <init-param>

                        <name>help-jsp</name>

                        <value>/html/book/help.jsp</value>

                </init-param>

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

                <supports>

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

                        <portlet-mode>view</portlet-mode>

                        <portlet-mode>edit</portlet-mode>

                        <portlet-mode>help</portlet-mode>

                </supports>

                <resource-bundle>content/Language</resource-bundle>

                <portlet-info>

                        <title>Liferay Book</title>

                        <short-title>BookPortlet</short-title>

                        <keywords></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>

service.xml

===========

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 6.0.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_6_0_0.dtd">

<service-builder package-path="com.liferay.training.library">

        <author>ICT</author>

        <namespace>Library</namespace>

                <!-- Define the entity for the Library_Publisher table -->

        <entity name="Publisher" local-service="true" remote-service="false">

                <!-- Primary key column -->

                <column name="publisherId" type="long" primary="true" />

                <!-- Foreign key columns -->

                <column name="companyId" type="long" />

                <column name="groupId" type="long" />

                <!-- Other columns -->

                <column name="name" type="String" />

                <column name="emailAddress" type="String" />

                <column name="website" type="String" />

                <column name="phoneNumber" type="String" />

                <!-- Sort order -->

                <order by="asc">

                        <order-column name="name" />

                </order>

                <!-- Finder Methods -->

                <finder name="GroupId" return-type="Collection">

                        <finder-column name="groupId" />

                </finder>

        </entity>

        

                <!-- Define the entity for the Library_Book table -->

        <entity name="Book" local-service="true" remote-service="false">

                <!-- Primary key column -->

                <column name="bookId" type="long" primary="true" />

                <!-- Foreign key columns -->

                <column name="companyId" type="long" />

                <column name="groupId" type="long" />

                <column name="publisherId" type="long" />

                <!-- Other columns -->

                <column name="title" type="String" localized="true" />

                <column name="authorName" type="String" />

                <column name="publicationDate" type="Date" />

                <!-- Sort order -->

                <order by="asc">

                        <order-column name="title" />

                </order>

                <!-- Finder Methods -->

                <finder name="GroupId" return-type="Collection">

                        <finder-column name="groupId" />

                </finder>

                <finder name="Publisher" return-type="Collection">

                        <finder-column name="publisherId" />

                </finder>

        </entity>

</service-builder>

web.xml

=======

<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">

  <display-name>library-portlet</display-name>

  <welcome-file-list>

    <welcome-file>index.html</welcome-file>

    <welcome-file>index.htm</welcome-file>

    <welcome-file>index.jsp</welcome-file>

    <welcome-file>default.html</welcome-file>

    <welcome-file>default.htm</welcome-file>

    <welcome-file>default.jsp</welcome-file>

  </welcome-file-list>

  <jsp-config>

          <taglib>

                  <taglib-uri>http://java.sun.com/portlet_2_0</taglib-uri>

                  <taglib-location>

                          /WEB-INF/tld/liferay-portlet.tld

                  </taglib-location>

          </taglib>

          

          <taglib>

     <taglib-uri>http://java.sun.com/jstl/core_rt</taglib-uri>

     <taglib-location>/WEB-INF/tld/c.tld</taglib-location>

</taglib>

          

  </jsp-config>

</web-app>