--------------------------------------------------------------------------------
/wars/books-catalog-portlet/portlet-build.js:
--------------------------------------------------------------------------------
1 | const fs = require('fs-extra');
2 | const concat = require('concat');
3 |
4 | (async function build() {
5 | const files = [
6 | './target/dist/portlet/runtime-es5.js',
7 | './target/dist/portlet/polyfills-es5.js',
8 | './target/dist/portlet/scripts.js',
9 | ];
10 |
11 | await concat(files, './src/main/webapp/js/runtime.js');
12 | await fs.copyFile('./target/dist/portlet/styles.css', './src/main/webapp/css/books-catalog.css');
13 | await fs.copyFile('./target/dist/portlet/main-es5.js', './src/main/webapp/js/books-catalog.js');
14 | })();
15 |
--------------------------------------------------------------------------------
/wars/books-catalog-portlet/src/main/java/com/wordpress/kkaravitis/modules/books/catalog/service/BookService.java:
--------------------------------------------------------------------------------
1 | package com.wordpress.kkaravitis.modules.books.catalog.service;
2 |
3 | import com.wordpress.kkaravitis.modules.books.catalog.exception.ApplicationException;
4 | import com.wordpress.kkaravitis.modules.books.catalog.model.BookDTO;
5 |
6 | import java.util.List;
7 |
8 | /**
9 | * @author Konstantinos Karavitis
10 | **/
11 | public interface BookService {
12 | public List getBooks();
13 |
14 | public void saveOrUpdateBook(BookDTO bookDTO);
15 |
16 | public void deleteBook(String isbn) throws ApplicationException;
17 | }
18 |
--------------------------------------------------------------------------------
/wars/books-catalog-portlet/src/main/angular/app/test/test.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';;
2 | import { BooksService } from '../books-catalog/books.service';
3 | import { MessageService } from '../messages/message.service';
4 | import { httpInterceptorProviders } from '../http-interceptors';
5 |
6 | @Component({
7 | selector: 'app-test',
8 | templateUrl: './test.component.html',
9 | styleUrls: ['./test.component.css']
10 | })
11 | export class TestComponent implements OnInit {
12 |
13 | public config:string = `{
14 | "apiUrl": "assets/books.json",
15 | "messages": {}
16 | }`;
17 |
18 | constructor() { }
19 |
20 | ngOnInit() {
21 | }
22 | }
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/modules/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 | com.wordpress.kkaravitis.modules
6 | com-wordpress-kkaravitis-portal
7 | 1.0.0
8 | ../pom.xml
9 |
10 | com-wordpress-kkaravitis-portal-modules
11 | com-wordpress-kkaravitis-portal Modules
12 | pom
13 |
14 | book
15 |
16 |
--------------------------------------------------------------------------------
/wars/books-catalog-portlet/src/main/java/com/wordpress/kkaravitis/modules/books/catalog/BooksCatalogPortlet.java:
--------------------------------------------------------------------------------
1 | package com.wordpress.kkaravitis.modules.books.catalog;
2 |
3 | import com.wordpress.kkaravitis.modules.books.catalog.exception.ApplicationException;
4 |
5 | import javax.portlet.RenderRequest;
6 | import javax.portlet.RenderResponse;
7 |
8 | /**
9 | * @author Konstantinos Karavitis
10 | **/
11 | public class BooksCatalogPortlet extends AbstractAngularPortlet {
12 | @Override
13 | protected AngularPortletConfig createAngularPortletConfiguration(String apiUrl, RenderRequest request, RenderResponse response) throws ApplicationException {
14 | return new AngularPortletConfig(apiUrl, getResourceBundle(request.getLocale()));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/wars/books-catalog-portlet/src/main/angular/test.ts:
--------------------------------------------------------------------------------
1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2 |
3 | import 'zone.js/dist/zone-testing';
4 | import { getTestBed } from '@angular/core/testing';
5 | import {
6 | BrowserDynamicTestingModule,
7 | platformBrowserDynamicTesting
8 | } from '@angular/platform-browser-dynamic/testing';
9 |
10 | declare const require: any;
11 |
12 | // First, initialize the Angular testing environment.
13 | getTestBed().initTestEnvironment(
14 | BrowserDynamicTestingModule,
15 | platformBrowserDynamicTesting()
16 | );
17 | // Then we find all the tests.
18 | const context = require.context('./', true, /\.spec\.ts$/);
19 | // And load the modules.
20 | context.keys().map(context);
21 |
--------------------------------------------------------------------------------
/wars/books-catalog-portlet/src/main/angular/environments/environment.ts:
--------------------------------------------------------------------------------
1 | // This file can be replaced during build by using the `fileReplacements` array.
2 | // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
3 | // The list of file replacements can be found in `angular.json`.
4 |
5 | export const environment = {
6 | production: false
7 | };
8 |
9 | /*
10 | * For easier debugging in development mode, you can import the following file
11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
12 | *
13 | * This import should be commented out in production mode because it will have a negative impact
14 | * on performance if an error is thrown.
15 | */
16 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI.
17 |
--------------------------------------------------------------------------------
/wars/books-catalog-portlet/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compileOnSave": false,
3 | "compilerOptions": {
4 | "baseUrl": "./",
5 | "outDir": "./target/dist/out-tsc",
6 | "sourceMap": true,
7 | "declaration": false,
8 | "module": "esnext",
9 | "moduleResolution": "node",
10 | "emitDecoratorMetadata": true,
11 | "experimentalDecorators": true,
12 | "target": "es2015",
13 | "typeRoots": [
14 | "node_modules/@types"
15 | ],
16 | "lib": [
17 | "es2018",
18 | "dom"
19 | ],
20 | "paths": {
21 | "core-js/es6/reflect": [
22 | "node_modules/core-js/proposals/reflect-metadata"
23 | ],
24 | "core-js/es7/reflect": [
25 | "node_modules/core-js/proposals/reflect-metadata"
26 | ]
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/wars/books-catalog-portlet/src/main/java/com/wordpress/kkaravitis/modules/books/catalog/model/Success.java:
--------------------------------------------------------------------------------
1 | package com.wordpress.kkaravitis.modules.books.catalog.model;
2 |
3 | import java.io.Serializable;
4 |
5 | /**
6 | * @author Konstantinos Karavitis
7 | **/
8 | public class Success implements Serializable {
9 | private static final long serialVersionUID = 1L;
10 |
11 | private String message;
12 |
13 | public Success(String messageKey) {
14 | super();
15 | this.message = messageKey;
16 | }
17 |
18 | public String getMessage() {
19 | return message;
20 | }
21 |
22 | public void setMessage(String message) {
23 | this.message = message;
24 | }
25 |
26 | @Override
27 | public String toString() {
28 | return "Success{" +
29 | "message='" + message + '\'' +
30 | '}';
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/wars/books-catalog-portlet/src/main/resources/portletContext.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/wars/books-catalog-portlet/src/main/angular/styles.css:
--------------------------------------------------------------------------------
1 | /* Uncomment when you bootstrap TestComponent */
2 |
3 | /* @import url( 'https://fonts.googleapis.com/css?family=Roboto:400,700|Material+Icons');
4 | @import "~@angular/material/prebuilt-themes/deeppurple-amber.css"; */
5 |
6 | .spinner-container {
7 | position: fixed;
8 | display: block;
9 | width: 100%;
10 | height: 100%;
11 | top: 0;
12 | left: 0;
13 | right: 0;
14 | bottom: 0;
15 | background-color: rgba(0, 0, 0, 0.5);
16 | z-index: 2;
17 | cursor: pointer; }
18 |
19 | mat-spinner {
20 | position: absolute;
21 | top: 50%;
22 | left: 50%; }
23 |
24 |
25 | .portlet-style-error {
26 | color: red;
27 | font-family: Roboto,sans-serif;
28 | font-weight: lighter; }
29 |
30 | .portlet-style-success {
31 | color: green;
32 | font-family: Roboto,sans-serif;
33 | font-weight: lighter; }
--------------------------------------------------------------------------------
/modules/book/book-service/service.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | BOOK
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/wars/books-catalog-portlet/src/main/angular/app/messages/message.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 |
3 | @Injectable()
4 | export class MessageService {
5 | messages: string[] = [];
6 | errors: string[] = [];
7 | successMsg: string;
8 |
9 | add(message: string) {
10 | this.messages.push(message);
11 | }
12 |
13 | clear() {
14 | this.messages = [];
15 | this.successMsg = null;
16 | this.errors = [];
17 | }
18 |
19 | clearInfo() {
20 | this.messages = [];
21 | }
22 |
23 | success(message:string) {
24 | this.clear();
25 | this.successMsg = message;
26 | }
27 |
28 | error(message:string) {
29 | this.errors.push(message);
30 | }
31 |
32 | info(message:string) {
33 | this.messages.push(message);
34 | }
35 |
36 | getMessage(map:any, key:string) : string {
37 | return map ? (map[key] ? map[key] : key) : key;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/wars/books-catalog-portlet/src/main/java/com/wordpress/kkaravitis/modules/books/catalog/Constants.java:
--------------------------------------------------------------------------------
1 | package com.wordpress.kkaravitis.modules.books.catalog;
2 |
3 | public class Constants {
4 | public static final String APPLICATION_ERROR = "application.error.";
5 |
6 | public static final String SYSTEM_ERROR = "application.error.fatal";
7 |
8 | public static final String APPLICATION_ERROR_UNAUTHORIZED = "application.error.unauthorized";
9 |
10 | public static final String VIEW_TEMPLATE = "view-template";
11 |
12 | public static final String PORTLET_XML_APPLICATION_CONTEXT = "portletContext.xml";
13 |
14 | public static final String CONFIG = "config";
15 |
16 | public static final String URI_PATTERN = "/rest";
17 |
18 | public static final String REST_PATH = "rest_path";
19 |
20 | public static final String REST_METHOD = "rest_method";
21 |
22 | public static final String JAVAX_PORTLET_REQUEST = "javax.portlet.request";
23 | }
24 |
--------------------------------------------------------------------------------
/wars/books-catalog-portlet/src/main/java/com/wordpress/kkaravitis/modules/books/catalog/model/ErrorResponse.java:
--------------------------------------------------------------------------------
1 | package com.wordpress.kkaravitis.modules.books.catalog.model;
2 |
3 | import java.io.Serializable;
4 |
5 | /**
6 | * Error response on resource request (ajax) error.
7 | *
8 | * @author Konstantinos Karavitis
9 | **/
10 | public class ErrorResponse implements Serializable {
11 | private static final long serialVersionUID = 1L;
12 | private Integer errorCode;
13 | private String message;
14 |
15 | public Integer getErrorCode() {
16 | return errorCode;
17 | }
18 |
19 | public void setErrorCode(Integer errorCode) {
20 | this.errorCode = errorCode;
21 | }
22 |
23 | public String getMessage() {
24 | return message;
25 | }
26 |
27 | public void setMessage(String message) {
28 | this.message = message;
29 | }
30 |
31 | @Override
32 | public String toString() {
33 | return "ErrorResponse{" +
34 | "errorCode=" + errorCode +
35 | ", message='" + message + '\'' +
36 | '}';
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/modules/book/book-service/src/main/resources/META-INF/module-hbm.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/wars/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 | com.wordpress.kkaravitis.modules
6 | com-wordpress-kkaravitis-portal
7 | 1.0.0
8 | ../pom.xml
9 |
10 | com-wordpress-kkaravitis-portal-wars
11 | com-wordpress-kkaravitis-portal Wars
12 | pom
13 |
14 |
15 |
16 | org.springframework.boot
17 | spring-boot-dependencies
18 | 2.1.9.RELEASE
19 | pom
20 | import
21 |
22 |
23 |
24 |
25 | books-catalog-portlet
26 |
27 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Konstantinos Karavitis
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/wars/books-catalog-portlet/src/main/angular/app/http-interceptors/PortletInterceptor.ts:
--------------------------------------------------------------------------------
1 | import { HttpInterceptor, HttpRequest, HttpHandler, HttpEvent } from "@angular/common/http";
2 | import { Observable } from "rxjs";
3 | import { Injectable } from "@angular/core";
4 | import { ConfigurationService } from "../configuration.service";
5 |
6 | export const REST_PATH = "rest_path";
7 |
8 | const REST_METHOD = "rest_method";
9 |
10 | const METHOD_MAP = {
11 | "PUT" : "POST",
12 | "DELETE": "POST",
13 | "GET" : "GET",
14 | "POST": "POST"
15 | };
16 |
17 | @Injectable()
18 | export class PortletInterceptor implements HttpInterceptor {
19 | public constructor(private configurationService: ConfigurationService) {
20 | }
21 |
22 | intercept(req: HttpRequest, next: HttpHandler) : Observable> {
23 | const portletReq = req.clone({
24 | url: this.configurationService.getConfig().apiUrl,
25 | method: METHOD_MAP[req.method.toUpperCase()],
26 | params: req.params.set(REST_PATH, req.url).set(REST_METHOD, req.method)
27 | });
28 | return next.handle(portletReq);
29 | }
30 | }
--------------------------------------------------------------------------------
/wars/books-catalog-portlet/src/main/angular/karma.conf.js:
--------------------------------------------------------------------------------
1 | // Karma configuration file, see link for more information
2 | // https://karma-runner.github.io/1.0/config/configuration-file.html
3 |
4 | module.exports = function (config) {
5 | config.set({
6 | basePath: '',
7 | frameworks: ['jasmine', '@angular-devkit/build-angular'],
8 | plugins: [
9 | require('karma-jasmine'),
10 | require('karma-chrome-launcher'),
11 | require('karma-jasmine-html-reporter'),
12 | require('karma-coverage-istanbul-reporter'),
13 | require('@angular-devkit/build-angular/plugins/karma')
14 | ],
15 | client: {
16 | clearContext: false // leave Jasmine Spec Runner output visible in browser
17 | },
18 | coverageIstanbulReporter: {
19 | dir: require('path').join(__dirname, '../coverage'),
20 | reports: ['html', 'lcovonly'],
21 | fixWebpackSourcePaths: true
22 | },
23 | reporters: ['progress', 'kjhtml'],
24 | port: 9876,
25 | colors: true,
26 | logLevel: config.LOG_INFO,
27 | autoWatch: true,
28 | browsers: ['Chrome'],
29 | singleRun: false
30 | });
31 | };
--------------------------------------------------------------------------------
/wars/books-catalog-portlet/src/main/java/com/wordpress/kkaravitis/modules/books/catalog/AngularPortletConfig.java:
--------------------------------------------------------------------------------
1 | package com.wordpress.kkaravitis.modules.books.catalog;
2 |
3 | import java.io.Serializable;
4 | import java.util.Enumeration;
5 | import java.util.HashMap;
6 | import java.util.Map;
7 | import java.util.ResourceBundle;
8 |
9 | /**
10 | * @author Konstantinos Karavitis
11 | **/
12 | public class AngularPortletConfig implements Serializable {
13 | private static final long serialVersionUID = 1L;
14 |
15 | private String apiUrl;
16 | private Map messages;
17 |
18 | public AngularPortletConfig() {}
19 |
20 | public AngularPortletConfig(String apiUrl, ResourceBundle resourceBundle) {
21 | this.apiUrl = apiUrl;
22 |
23 | this.messages = new HashMap<>();
24 | Enumeration keys = resourceBundle.getKeys();
25 | while (keys.hasMoreElements()) {
26 | String key = keys.nextElement();
27 | messages.put(key, resourceBundle.getString(key));
28 | }
29 | }
30 |
31 | public String getApiUrl() {
32 | return apiUrl;
33 | }
34 |
35 | public Map getMessages() {
36 | return messages;
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/wars/books-catalog-portlet/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Konstantinos Karavitis
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/wars/books-catalog-portlet/src/main/webapp/WEB-INF/liferay-portlet.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | books-catalog
7 | /icon.png
8 | true
9 | /css/deeppurple-amber.css
10 | /css/books-catalog.css
11 | /js/runtime.js
12 | /js/books-catalog.js
13 |
14 |
15 | administrator
16 | Administrator
17 |
18 |
19 | guest
20 | Guest
21 |
22 |
23 | power-user
24 | Power User
25 |
26 |
27 | user
28 | User
29 |
30 |
--------------------------------------------------------------------------------
/wars/books-catalog-portlet/src/main/java/com/wordpress/kkaravitis/modules/books/catalog/exception/ApplicationException.java:
--------------------------------------------------------------------------------
1 | package com.wordpress.kkaravitis.modules.books.catalog.exception;
2 |
3 | /**
4 | * The application's error exception. Every application exception has a code
5 | * which is used for retrieving the message of the error that will be displayed
6 | * to the user from the localized messages.properties.
7 | *
8 | * @author Konstantinos Karavitis
9 | **/
10 | public class ApplicationException extends Exception {
11 | private static final long serialVersionUID = 1L;
12 |
13 | public ApplicationException(Integer code) {
14 | super();
15 | this.code = code;
16 | }
17 |
18 | public ApplicationException(Integer code, Throwable cause) {
19 | super(cause);
20 | this.code = code;
21 | }
22 |
23 | public ApplicationException(Throwable throwable) {
24 | super(throwable);
25 | }
26 |
27 | private Integer code;
28 |
29 | /**
30 | * Returns the code of application exception
31 | **/
32 | public Integer getCode() {
33 | return code;
34 | }
35 |
36 | /**
37 | * Sets the code of application exception
38 | **/
39 | public void setCode(Integer code) {
40 | this.code = code;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/modules/book/book-api/src/main/java/book/exception/NoSuchBookException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or modify it under
5 | * the terms of the GNU Lesser General Public License as published by the Free
6 | * Software Foundation; either version 2.1 of the License, or (at your option)
7 | * any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 | * details.
13 | */
14 | package book.exception;
15 |
16 | import org.osgi.annotation.versioning.ProviderType;
17 |
18 | import com.liferay.portal.kernel.exception.NoSuchModelException;
19 |
20 | /**
21 | * @author Brian Wing Shun Chan
22 | */
23 | @ProviderType
24 | public class NoSuchBookException extends NoSuchModelException {
25 |
26 | public NoSuchBookException() {
27 | }
28 |
29 | public NoSuchBookException(String msg) {
30 | super(msg);
31 | }
32 |
33 | public NoSuchBookException(String msg, Throwable cause) {
34 | super(msg, cause);
35 | }
36 |
37 | public NoSuchBookException(Throwable cause) {
38 | super(cause);
39 | }
40 |
41 | }
--------------------------------------------------------------------------------
/modules/book/book-api/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 | 4.0.0
9 | book-api
10 | 1.0.0
11 |
12 | book
13 | book
14 | 1.0.0
15 |
16 |
17 |
18 | com.liferay.portal
19 | com.liferay.portal.kernel
20 | 4.4.0
21 | provided
22 |
23 |
24 | org.osgi
25 | org.osgi.annotation.versioning
26 | 1.1.0
27 | provided
28 |
29 |
30 | org.osgi
31 | org.osgi.core
32 | 6.0.0
33 | provided
34 |
35 |
36 | org.osgi
37 | org.osgi.service.component.annotations
38 | 1.3.0
39 | provided
40 |
41 |
42 |
--------------------------------------------------------------------------------
/wars/books-catalog-portlet/src/main/angular/app/books-catalog/books.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 | import { MessageService } from '../messages/message.service';
3 | import { HttpClient, HttpParams } from '@angular/common/http';
4 | import { Book } from './Book';
5 | import { Observable, of } from 'rxjs';
6 | import { catchError } from 'rxjs/operators';
7 |
8 | export interface Success {
9 | message:string;
10 | }
11 |
12 | @Injectable()
13 | export class BooksService {
14 |
15 | constructor(private http: HttpClient, private messageService:MessageService) { }
16 |
17 | public listBooks(): Observable {
18 | return this.http.get(`/books`).pipe(
19 | catchError(error => {
20 | this.messageService.error(error.error["message"]);
21 | return of([]);
22 | })
23 | );
24 | }
25 |
26 | public putBook(book: Book): Observable {
27 | return this.http.put(`/book/${book.isbn}`, book).pipe(
28 | catchError(error => {
29 | this.messageService.error(error.error["message"]);
30 | return of(null);
31 | })
32 | );
33 | }
34 |
35 | public deleteBook(isbn:string) : Observable {
36 | return this.http.delete(`/book/${isbn}`).pipe(
37 | catchError(error => {
38 | this.messageService.error(error.error["message"]);
39 | return of(null);
40 | })
41 | );
42 | }
43 | }
44 |
45 |
--------------------------------------------------------------------------------
/wars/books-catalog-portlet/src/main/webapp/WEB-INF/portlet.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 | books-catalog
9 | books-catalog
10 | com.wordpress.kkaravitis.modules.books.catalog.BooksCatalogPortlet
11 |
12 | view-template
13 | /view/books-catalog.jsp
14 |
15 | 0
16 |
17 | text/html
18 |
19 | messages
20 |
21 | Books Catalog
22 | Books Catalog
23 | Books Catalog Angular 8 CRUD Example
24 |
25 |
26 | administrator
27 |
28 |
29 | guest
30 |
31 |
32 | power-user
33 |
34 |
35 | user
36 |
37 |
38 |
--------------------------------------------------------------------------------
/wars/books-catalog-portlet/src/main/webapp/WEB-INF/restful-servlet.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
14 |
15 |
16 |
17 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/wars/books-catalog-portlet/src/main/webapp/WEB-INF/web.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | portalListenerClasses
4 | com.liferay.portal.kernel.servlet.SerializableSessionAttributeListener,org.springframework.web.context.ContextLoaderListener
5 |
6 |
7 |
8 | restFilter
9 | com.wordpress.kkaravitis.modules.books.catalog.rest.RestFilter
10 |
11 |
12 | restFilter
13 | /rest/*
14 | REQUEST
15 | FORWARD
16 |
17 |
18 |
19 | restful
20 |
21 | org.springframework.web.servlet.DispatcherServlet
22 |
23 |
24 | contextConfigLocation
25 | /WEB-INF/restful-servlet.xml
26 |
27 |
28 | throwExceptionIfNoHandlerFound
29 | true
30 |
31 | 1
32 |
33 |
34 | restful
35 | /rest/*
36 |
37 |
--------------------------------------------------------------------------------
/modules/book/book-service/src/main/java/book/model/impl/BookImpl.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or modify it under
5 | * the terms of the GNU Lesser General Public License as published by the Free
6 | * Software Foundation; either version 2.1 of the License, or (at your option)
7 | * any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 | * details.
13 | */
14 |
15 | package book.model.impl;
16 |
17 | import org.osgi.annotation.versioning.ProviderType;
18 |
19 | /**
20 | * The extended model implementation for the Book service. Represents a row in the "BOOK_Book" database table, with each column mapped to a property of this class.
21 | *
22 | *
23 | * Helper methods and all application logic should be put in this class. Whenever methods are added, rerun ServiceBuilder to copy their definitions into the book.model.Book interface.
24 | *
25 | *
26 | * @author Brian Wing Shun Chan
27 | */
28 | @ProviderType
29 | public class BookImpl extends BookBaseImpl {
30 |
31 | /*
32 | * NOTE FOR DEVELOPERS:
33 | *
34 | * Never reference this class directly. All methods that expect a book model instance should use the {@link book.model.Book} interface instead.
35 | */
36 | public BookImpl() {
37 | }
38 |
39 | }
--------------------------------------------------------------------------------
/wars/books-catalog-portlet/src/main/java/com/wordpress/kkaravitis/modules/books/catalog/rest/BookController.java:
--------------------------------------------------------------------------------
1 | package com.wordpress.kkaravitis.modules.books.catalog.rest;
2 |
3 | import com.wordpress.kkaravitis.modules.books.catalog.exception.ApplicationException;
4 | import com.wordpress.kkaravitis.modules.books.catalog.model.BookDTO;
5 | import com.wordpress.kkaravitis.modules.books.catalog.model.Success;
6 | import com.wordpress.kkaravitis.modules.books.catalog.service.BookService;
7 | import org.springframework.beans.factory.annotation.Autowired;
8 | import org.springframework.http.HttpStatus;
9 | import org.springframework.http.ResponseEntity;
10 | import org.springframework.web.bind.annotation.*;
11 |
12 | import java.util.List;
13 |
14 | /**
15 | * @author Konstantinos Karavitis
16 | **/
17 | @RestController
18 | public class BookController {
19 | @Autowired
20 | BookService service;
21 |
22 | @GetMapping("/books")
23 | public ResponseEntity> getBooks() throws ApplicationException {
24 | return new ResponseEntity>(service.getBooks(), HttpStatus.OK);
25 | }
26 |
27 | @PutMapping ("/book/{isbn}")
28 | public ResponseEntity updateBook(@RequestBody BookDTO book) throws ApplicationException {
29 | service.saveOrUpdateBook(book);
30 | return new ResponseEntity(new Success("Saved succesfully"), HttpStatus.OK);
31 | }
32 |
33 | @DeleteMapping("/book/{isbn}")
34 | public ResponseEntity deleteBook(@PathVariable(name="isbn") String isbn) throws ApplicationException {
35 | service.deleteBook(isbn);
36 | return new ResponseEntity(new Success("Deleted succesfully"), HttpStatus.ACCEPTED);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/wars/books-catalog-portlet/src/main/java/com/wordpress/kkaravitis/modules/books/catalog/model/BookDTO.java:
--------------------------------------------------------------------------------
1 | package com.wordpress.kkaravitis.modules.books.catalog.model;
2 |
3 | import java.io.Serializable;
4 | import java.util.Objects;
5 |
6 | /**
7 | * @author Konstantinos Karavitis
8 | **/
9 | public class BookDTO implements Serializable {
10 | private String isbn;
11 | private String title;
12 | private String author;
13 |
14 | public String getTitle() {
15 | return title;
16 | }
17 |
18 | public void setTitle(String title) {
19 | this.title = title;
20 | }
21 |
22 | public String getIsbn() {
23 | return isbn;
24 | }
25 |
26 | public void setIsbn(String isbn) {
27 | this.isbn = isbn;
28 | }
29 |
30 | public String getAuthor() {
31 | return author;
32 | }
33 |
34 | public void setAuthor(String author) {
35 | this.author = author;
36 | }
37 |
38 | @Override
39 | public boolean equals(Object o) {
40 | if (this == o) return true;
41 | if (o == null || getClass() != o.getClass()) return false;
42 | BookDTO bookDTO = (BookDTO) o;
43 | return Objects.equals(isbn, bookDTO.isbn) &&
44 | Objects.equals(title, bookDTO.title) &&
45 | Objects.equals(author, bookDTO.author);
46 | }
47 |
48 | @Override
49 | public int hashCode() {
50 | return Objects.hash(isbn, title, author);
51 | }
52 |
53 | @Override
54 | public String toString() {
55 | return "BookDTO{" +
56 | "isbn='" + isbn + '\'' +
57 | ", title='" + title + '\'' +
58 | ", author='" + author + '\'' +
59 | '}';
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Angular 8 with Spring boot 2 portlets on Liferay 7.2
2 | Examples for creating secure jsr286 or jsr362 portlets on liferay 7.2 with angular 8 and Spring boot 2.
3 | Every portlet is in wars folder and in modules folder there are the services apis produced by service builder.
4 |
5 | ## Books catalog example
6 | A basic crud application where only authenticated users of portal can view the stored books on database and can add, update or delete a book of them.
7 |
8 | This portlet leverages the power of angular custom elements and the powerful capabilities of Spring Boot with respect on liferay service builder as regards the persistence layer.
9 |
10 |
11 |
12 | ## Download and install the Liferay Portal 7.2 server.
13 | After you have cloned the project, open a terminal to the angular-spring-boot-portlets folder and run
14 |
15 | mvn bundle-support:init
16 |
17 | The above command downloads the Liferay Portal specified in pom.xml version (7.2) from the specified repository
18 |
19 | (https://releases-cdn.liferay.com/portal/7.2.0-ga1/liferay-ce-portal-tomcat-7.2.0-ga1-20190531153709761.tar.gz).
20 |
21 | Now you have a complete development environment to play with this project.
22 |
23 | For more information about setting up a liferay development environment refer to the following links
24 |
25 | https://portal.liferay.dev/docs/7-0/reference/-/knowledge_base/r/bundle-support-plugin
26 |
27 | https://portal.liferay.dev/docs/7-0/tutorials/-/knowledge_base/t/tooling
28 |
29 | ## How to build and deploy the modules
30 | 1) Install the npm dependencies to angular app by running
31 | npm install --prefix wars/books-catalog-portlet
32 |
33 | 2) Run npm run build:portlet --prefix wars/books-catalog-portlet
34 |
35 | 3) Run mvn install
36 |
37 | 4) Run mvn verify
38 |
--------------------------------------------------------------------------------
/modules/book/book-service/src/main/java/book/service/persistence/impl/constants/BOOKPersistenceConstants.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or modify it under
5 | * the terms of the GNU Lesser General Public License as published by the Free
6 | * Software Foundation; either version 2.1 of the License, or (at your option)
7 | * any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 | * details.
13 | */
14 |
15 | package book.service.persistence.impl.constants;
16 |
17 | import com.liferay.petra.string.StringBundler;
18 |
19 | import org.osgi.framework.Bundle;
20 | import org.osgi.framework.BundleContext;
21 | import org.osgi.framework.Constants;
22 | import org.osgi.service.component.annotations.Activate;
23 | import org.osgi.service.component.annotations.Component;
24 |
25 | /**
26 | * @author Brian Wing Shun Chan
27 | * @generated
28 | */
29 | @Component(immediate = true, service = {})
30 | public class BOOKPersistenceConstants {
31 |
32 | public static final String BUNDLE_SYMBOLIC_NAME = "book.service";
33 |
34 | public static final String ORIGIN_BUNDLE_SYMBOLIC_NAME_FILTER =
35 | "(origin.bundle.symbolic.name=" + BUNDLE_SYMBOLIC_NAME + ")";
36 |
37 | @Activate
38 | protected void activate(BundleContext bundleContext) {
39 | Bundle bundle = bundleContext.getBundle();
40 |
41 | if (!BUNDLE_SYMBOLIC_NAME.equals(bundle.getSymbolicName())) {
42 | throw new IllegalStateException(
43 | StringBundler.concat(
44 | "Incorrect ", Constants.BUNDLE_SYMBOLICNAME, " for bundle ",
45 | bundle.getSymbolicName()));
46 | }
47 | }
48 |
49 | }
--------------------------------------------------------------------------------
/wars/books-catalog-portlet/src/main/java/com/wordpress/kkaravitis/modules/books/catalog/rest/SecureRequestHandlerInterceptor.java:
--------------------------------------------------------------------------------
1 | package com.wordpress.kkaravitis.modules.books.catalog.rest;
2 |
3 | import javax.servlet.http.HttpServletRequest;
4 | import javax.servlet.http.HttpServletResponse;
5 |
6 | import com.fasterxml.jackson.databind.ObjectMapper;
7 | import com.liferay.portal.kernel.model.User;
8 | import com.wordpress.kkaravitis.modules.books.catalog.Constants;
9 | import com.wordpress.kkaravitis.modules.books.catalog.model.ErrorResponse;
10 | import org.slf4j.Logger;
11 | import org.slf4j.LoggerFactory;
12 | import org.springframework.beans.factory.annotation.Autowired;
13 | import org.springframework.context.MessageSource;
14 | import org.springframework.http.HttpStatus;
15 | import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
16 |
17 | import com.liferay.portal.kernel.util.WebKeys;
18 |
19 | /**
20 | * @author Konstantinos Karavitis
21 | **/
22 | public class SecureRequestHandlerInterceptor extends HandlerInterceptorAdapter {
23 | @Autowired
24 | MessageSource messageSource;
25 |
26 | Logger logger = LoggerFactory.getLogger(SecureRequestHandlerInterceptor.class);
27 | @Override
28 | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
29 | User user = (User) request.getAttribute(WebKeys.USER);
30 | if (user == null) {
31 | response.setStatus(HttpStatus.UNAUTHORIZED.value());
32 | ErrorResponse error = new ErrorResponse();
33 | error.setErrorCode(HttpStatus.UNAUTHORIZED.value());
34 | error.setMessage(messageSource.getMessage(Constants.APPLICATION_ERROR_UNAUTHORIZED, null, request.getLocale()));
35 | response.getWriter().write(new ObjectMapper().writeValueAsString(error));
36 | return false;
37 | }
38 |
39 | return true;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/modules/book/book-service/src/main/java/book/model/impl/BookBaseImpl.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or modify it under
5 | * the terms of the GNU Lesser General Public License as published by the Free
6 | * Software Foundation; either version 2.1 of the License, or (at your option)
7 | * any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 | * details.
13 | */
14 |
15 | package book.model.impl;
16 |
17 | import book.model.Book;
18 |
19 | import book.service.BookLocalServiceUtil;
20 |
21 | import org.osgi.annotation.versioning.ProviderType;
22 |
23 | /**
24 | * The extended model base implementation for the Book service. Represents a row in the "BOOK_Book" database table, with each column mapped to a property of this class.
25 | *
26 | *
27 | * This class exists only as a container for the default extended model level methods generated by ServiceBuilder. Helper methods and all application logic should be put in {@link BookImpl}.
28 | *
29 | *
30 | * @author Brian Wing Shun Chan
31 | * @see BookImpl
32 | * @see Book
33 | * @generated
34 | */
35 | @ProviderType
36 | public abstract class BookBaseImpl extends BookModelImpl implements Book {
37 |
38 | /*
39 | * NOTE FOR DEVELOPERS:
40 | *
41 | * Never modify or reference this class directly. All methods that expect a book model instance should use the Book interface instead.
42 | */
43 | @Override
44 | public void persist() {
45 | if (this.isNew()) {
46 | BookLocalServiceUtil.addBook(this);
47 | }
48 | else {
49 | BookLocalServiceUtil.updateBook(this);
50 | }
51 | }
52 |
53 | }
--------------------------------------------------------------------------------
/modules/book/book-service/src/main/java/book/service/impl/BookLocalServiceImpl.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or modify it under
5 | * the terms of the GNU Lesser General Public License as published by the Free
6 | * Software Foundation; either version 2.1 of the License, or (at your option)
7 | * any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 | * details.
13 | */
14 |
15 | package book.service.impl;
16 |
17 | import book.service.base.BookLocalServiceBaseImpl;
18 |
19 | import com.liferay.portal.aop.AopService;
20 |
21 | import org.osgi.service.component.annotations.Component;
22 |
23 | /**
24 | * The implementation of the book local service.
25 | *
26 | *
27 | * All custom service methods should be put in this class. Whenever methods are added, rerun ServiceBuilder to copy their definitions into the book.service.BookLocalService interface.
28 | *
29 | *
30 | * 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.
31 | *
32 | *
33 | * @author Brian Wing Shun Chan
34 | * @see BookLocalServiceBaseImpl
35 | */
36 | @Component(
37 | property = "model.class.name=book.model.Book", service = AopService.class
38 | )
39 | public class BookLocalServiceImpl extends BookLocalServiceBaseImpl {
40 |
41 | /*
42 | * NOTE FOR DEVELOPERS:
43 | *
44 | * Never reference this class directly. Use book.service.BookLocalService via injection or a org.osgi.util.tracker.ServiceTracker or use book.service.BookLocalServiceUtil.
45 | */
46 | }
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 | 4.0.0
9 | com.wordpress.kkaravitis.modules
10 | com-wordpress-kkaravitis-portal
11 | pom
12 | 1.0.0
13 | com-wordpress-kkaravitis-portal
14 |
15 | UTF-8
16 | https://releases-cdn.liferay.com/portal/7.2.0-ga1/liferay-ce-portal-tomcat-7.2.0-ga1-20190531153709761.tar.gz
17 |
18 |
19 |
20 |
21 | com.liferay
22 | com.liferay.portal.tools.bundle.support
23 | 3.4.3
24 |
25 |
26 | clean
27 |
28 | clean
29 |
30 | clean
31 |
32 |
33 |
42 |
43 |
44 | deploy
45 |
46 | deploy
47 |
48 | pre-integration-test
49 |
50 |
51 |
60 |
61 |
62 |
63 |
64 |
65 |
66 | modules
67 | wars
68 |
69 |
--------------------------------------------------------------------------------
/modules/book/book-api/src/main/java/book/model/Book.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or modify it under
5 | * the terms of the GNU Lesser General Public License as published by the Free
6 | * Software Foundation; either version 2.1 of the License, or (at your option)
7 | * any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 | * details.
13 | */
14 |
15 | package book.model;
16 |
17 | import com.liferay.portal.kernel.annotation.ImplementationClassName;
18 | import com.liferay.portal.kernel.model.PersistedModel;
19 | import com.liferay.portal.kernel.util.Accessor;
20 |
21 | import org.osgi.annotation.versioning.ProviderType;
22 |
23 | /**
24 | * The extended model interface for the Book service. Represents a row in the "BOOK_Book" database table, with each column mapped to a property of this class.
25 | *
26 | * @author Brian Wing Shun Chan
27 | * @see BookModel
28 | * @generated
29 | */
30 | @ImplementationClassName("book.model.impl.BookImpl")
31 | @ProviderType
32 | public interface Book extends BookModel, PersistedModel {
33 |
34 | /*
35 | * NOTE FOR DEVELOPERS:
36 | *
37 | * Never modify this interface directly. Add methods to book.model.impl.BookImpl and rerun ServiceBuilder to automatically copy the method declarations to this interface.
38 | */
39 | public static final Accessor ISBN_ACCESSOR =
40 | new Accessor() {
41 |
42 | @Override
43 | public String get(Book book) {
44 | return book.getIsbn();
45 | }
46 |
47 | @Override
48 | public Class getAttributeClass() {
49 | return String.class;
50 | }
51 |
52 | @Override
53 | public Class getTypeClass() {
54 | return Book.class;
55 | }
56 |
57 | };
58 |
59 | }
--------------------------------------------------------------------------------
/wars/books-catalog-portlet/src/main/angular/app/books-catalog/books-catalog.component.html:
--------------------------------------------------------------------------------
1 |
26 | * This interface and its corresponding implementation book.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 book.model.impl.BookImpl.
27 | *
28 | *
29 | * @author Brian Wing Shun Chan
30 | * @see Book
31 | * @generated
32 | */
33 | @ProviderType
34 | public interface BookModel extends BaseModel {
35 |
36 | /*
37 | * NOTE FOR DEVELOPERS:
38 | *
39 | * Never modify or reference this interface directly. All methods that expect a book model instance should use the {@link Book} interface instead.
40 | */
41 |
42 | /**
43 | * Returns the primary key of this book.
44 | *
45 | * @return the primary key of this book
46 | */
47 | public String getPrimaryKey();
48 |
49 | /**
50 | * Sets the primary key of this book.
51 | *
52 | * @param primaryKey the primary key of this book
53 | */
54 | public void setPrimaryKey(String primaryKey);
55 |
56 | /**
57 | * Returns the uuid of this book.
58 | *
59 | * @return the uuid of this book
60 | */
61 | @AutoEscape
62 | public String getUuid();
63 |
64 | /**
65 | * Sets the uuid of this book.
66 | *
67 | * @param uuid the uuid of this book
68 | */
69 | public void setUuid(String uuid);
70 |
71 | /**
72 | * Returns the isbn of this book.
73 | *
74 | * @return the isbn of this book
75 | */
76 | @AutoEscape
77 | public String getIsbn();
78 |
79 | /**
80 | * Sets the isbn of this book.
81 | *
82 | * @param isbn the isbn of this book
83 | */
84 | public void setIsbn(String isbn);
85 |
86 | /**
87 | * Returns the title of this book.
88 | *
89 | * @return the title of this book
90 | */
91 | @AutoEscape
92 | public String getTitle();
93 |
94 | /**
95 | * Sets the title of this book.
96 | *
97 | * @param title the title of this book
98 | */
99 | public void setTitle(String title);
100 |
101 | /**
102 | * Returns the author of this book.
103 | *
104 | * @return the author of this book
105 | */
106 | @AutoEscape
107 | public String getAuthor();
108 |
109 | /**
110 | * Sets the author of this book.
111 | *
112 | * @param author the author of this book
113 | */
114 | public void setAuthor(String author);
115 |
116 | }
--------------------------------------------------------------------------------
/wars/books-catalog-portlet/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "rulesDirectory": [
3 | "node_modules/codelyzer"
4 | ],
5 | "rules": {
6 | "arrow-return-shorthand": true,
7 | "callable-types": true,
8 | "class-name": true,
9 | "comment-format": [
10 | true,
11 | "check-space"
12 | ],
13 | "curly": true,
14 | "deprecation": {
15 | "severity": "warn"
16 | },
17 | "eofline": true,
18 | "forin": true,
19 | "import-blacklist": [
20 | true,
21 | "rxjs/Rx"
22 | ],
23 | "import-spacing": true,
24 | "indent": [
25 | true,
26 | "spaces"
27 | ],
28 | "interface-over-type-literal": true,
29 | "label-position": true,
30 | "max-line-length": [
31 | true,
32 | 140
33 | ],
34 | "member-access": false,
35 | "member-ordering": [
36 | true,
37 | {
38 | "order": [
39 | "static-field",
40 | "instance-field",
41 | "static-method",
42 | "instance-method"
43 | ]
44 | }
45 | ],
46 | "no-arg": true,
47 | "no-bitwise": true,
48 | "no-console": [
49 | true,
50 | "debug",
51 | "info",
52 | "time",
53 | "timeEnd",
54 | "trace"
55 | ],
56 | "no-construct": true,
57 | "no-debugger": true,
58 | "no-duplicate-super": true,
59 | "no-empty": false,
60 | "no-empty-interface": true,
61 | "no-eval": true,
62 | "no-inferrable-types": [
63 | true,
64 | "ignore-params"
65 | ],
66 | "no-misused-new": true,
67 | "no-non-null-assertion": true,
68 | "no-redundant-jsdoc": true,
69 | "no-shadowed-variable": true,
70 | "no-string-literal": false,
71 | "no-string-throw": true,
72 | "no-switch-case-fall-through": true,
73 | "no-trailing-whitespace": true,
74 | "no-unnecessary-initializer": true,
75 | "no-unused-expression": true,
76 | "no-use-before-declare": true,
77 | "no-var-keyword": true,
78 | "object-literal-sort-keys": false,
79 | "one-line": [
80 | true,
81 | "check-open-brace",
82 | "check-catch",
83 | "check-else",
84 | "check-whitespace"
85 | ],
86 | "prefer-const": true,
87 | "quotemark": [
88 | true,
89 | "single"
90 | ],
91 | "radix": true,
92 | "semicolon": [
93 | true,
94 | "always"
95 | ],
96 | "triple-equals": [
97 | true,
98 | "allow-null-check"
99 | ],
100 | "typedef-whitespace": [
101 | true,
102 | {
103 | "call-signature": "nospace",
104 | "index-signature": "nospace",
105 | "parameter": "nospace",
106 | "property-declaration": "nospace",
107 | "variable-declaration": "nospace"
108 | }
109 | ],
110 | "unified-signatures": true,
111 | "variable-name": false,
112 | "whitespace": [
113 | true,
114 | "check-branch",
115 | "check-decl",
116 | "check-operator",
117 | "check-separator",
118 | "check-type"
119 | ],
120 | "no-output-on-prefix": true,
121 | "no-inputs-metadata-property": true,
122 | "no-outputs-metadata-property": true,
123 | "no-host-metadata-property": true,
124 | "no-input-rename": true,
125 | "no-output-rename": true,
126 | "use-lifecycle-interface": true,
127 | "use-pipe-transform-interface": true,
128 | "component-class-suffix": true,
129 | "directive-class-suffix": true
130 | }
131 | }
132 |
--------------------------------------------------------------------------------
/wars/books-catalog-portlet/src/main/angular/app/demo-material.module.ts:
--------------------------------------------------------------------------------
1 | import {DragDropModule} from '@angular/cdk/drag-drop';
2 | import {ScrollingModule} from '@angular/cdk/scrolling';
3 | import {CdkTableModule} from '@angular/cdk/table';
4 | import {CdkTreeModule} from '@angular/cdk/tree';
5 | import {NgModule} from '@angular/core';
6 |
7 | import { MatAutocompleteModule } from '@angular/material/autocomplete';
8 | import { MatBadgeModule } from '@angular/material/badge';
9 | import { MatBottomSheetModule } from '@angular/material/bottom-sheet';
10 | import { MatButtonModule } from '@angular/material/button';
11 | import { MatButtonToggleModule } from '@angular/material/button-toggle';
12 | import { MatCardModule } from '@angular/material/card';
13 | import { MatCheckboxModule } from '@angular/material/checkbox';
14 | import { MatChipsModule } from '@angular/material/chips';
15 | import { MatNativeDateModule, MatRippleModule } from '@angular/material/core';
16 | import { MatDatepickerModule } from '@angular/material/datepicker';
17 | import { MatDialogModule } from '@angular/material/dialog';
18 | import { MatDividerModule } from '@angular/material/divider';
19 | import { MatExpansionModule } from '@angular/material/expansion';
20 | import { MatGridListModule } from '@angular/material/grid-list';
21 | import { MatIconModule } from '@angular/material/icon';
22 | import { MatInputModule } from '@angular/material/input';
23 | import { MatListModule } from '@angular/material/list';
24 | import { MatMenuModule } from '@angular/material/menu';
25 | import { MatPaginatorModule } from '@angular/material/paginator';
26 | import { MatProgressBarModule } from '@angular/material/progress-bar';
27 | import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
28 | import { MatRadioModule } from '@angular/material/radio';
29 | import { MatSelectModule } from '@angular/material/select';
30 | import { MatSidenavModule } from '@angular/material/sidenav';
31 | import { MatSlideToggleModule } from '@angular/material/slide-toggle';
32 | import { MatSliderModule } from '@angular/material/slider';
33 | import { MatSnackBarModule } from '@angular/material/snack-bar';
34 | import { MatSortModule } from '@angular/material/sort';
35 | import { MatStepperModule } from '@angular/material/stepper';
36 | import { MatTableModule } from '@angular/material/table';
37 | import { MatTabsModule } from '@angular/material/tabs';
38 | import { MatToolbarModule } from '@angular/material/toolbar';
39 | import { MatTooltipModule } from '@angular/material/tooltip';
40 | import { MatTreeModule } from '@angular/material/tree';
41 |
42 | @NgModule({
43 | exports: [
44 | CdkTableModule,
45 | CdkTreeModule,
46 | DragDropModule,
47 | MatAutocompleteModule,
48 | MatBadgeModule,
49 | MatBottomSheetModule,
50 | MatButtonModule,
51 | MatButtonToggleModule,
52 | MatCardModule,
53 | MatCheckboxModule,
54 | MatChipsModule,
55 | MatStepperModule,
56 | MatDatepickerModule,
57 | MatDialogModule,
58 | MatDividerModule,
59 | MatExpansionModule,
60 | MatGridListModule,
61 | MatIconModule,
62 | MatInputModule,
63 | MatListModule,
64 | MatMenuModule,
65 | MatNativeDateModule,
66 | MatPaginatorModule,
67 | MatProgressBarModule,
68 | MatProgressSpinnerModule,
69 | MatRadioModule,
70 | MatRippleModule,
71 | MatSelectModule,
72 | MatSidenavModule,
73 | MatSliderModule,
74 | MatSlideToggleModule,
75 | MatSnackBarModule,
76 | MatSortModule,
77 | MatTableModule,
78 | MatTabsModule,
79 | MatToolbarModule,
80 | MatTooltipModule,
81 | MatTreeModule,
82 | ScrollingModule,
83 | ]
84 | })
85 | export class DemoMaterialModule {}
--------------------------------------------------------------------------------
/wars/books-catalog-portlet/src/main/angular/polyfills.ts:
--------------------------------------------------------------------------------
1 |
2 | /**
3 | * This file includes polyfills needed by Angular and is loaded before the app.
4 | * You can add your own extra polyfills to this file.
5 | *
6 | * This file is divided into 2 sections:
7 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
8 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main
9 | * file.
10 | *
11 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
12 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
13 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
14 | *
15 | * Learn more in https://angular.io/guide/browser-support
16 | */
17 |
18 | /***************************************************************************************************
19 | * BROWSER POLYFILLS
20 | */
21 |
22 | /** IE9, IE10 and IE11 requires all of the following polyfills. **/
23 | import 'core-js/es/symbol';
24 | import 'core-js/es/object';
25 | import 'core-js/es/function';
26 | import 'core-js/es/parse-int';
27 | import 'core-js/es/parse-float';
28 | import 'core-js/es/number';
29 | import 'core-js/es/math';
30 | import 'core-js/es/string';
31 | import 'core-js/es/date';
32 | import 'core-js/es/array';
33 | import 'core-js/es/regexp';
34 | import 'core-js/es/map';
35 | import 'core-js/es/weak-map';
36 | import 'core-js/es/set';
37 |
38 | /**
39 | * If the application will be indexed by Google Search, the following is required.
40 | * Googlebot uses a renderer based on Chrome 41.
41 | * https://developers.google.com/search/docs/guides/rendering
42 | **/
43 | import 'core-js/es/array';
44 |
45 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */
46 | import 'classlist.js'; // Run `npm install --save classlist.js`.
47 |
48 | /** IE10 and IE11 requires the following for the Reflect API. */
49 | /**
50 | * DO NOT REMOVE
51 | * By default, Reflect polyfills are auto-included by the CLI and
52 | * are required for JIT compilation. StackBlitz examples are
53 | * compiled using JIT.
54 | */
55 | import 'core-js/es/reflect';
56 |
57 | /**
58 | * Web Animations `@angular/platform-browser/animations`
59 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
60 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
61 | **/
62 | import 'web-animations-js'; // Run `npm install --save web-animations-js`.
63 |
64 | /**
65 | * By default, zone.js will patch all possible macroTask and DomEvents
66 | * user can disable parts of macroTask/DomEvents patch by setting following flags
67 | */
68 |
69 | // (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
70 | // (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
71 | // (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
72 |
73 | /*
74 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
75 | * with the following flag, it will bypass `zone.js` patch for IE/Edge
76 | */
77 | (window as any).__Zone_enable_cross_context_check = true;
78 |
79 | /***************************************************************************************************
80 | * Zone JS is required by default for Angular itself.
81 | */
82 | import 'zone.js/dist/zone'; // Included with Angular CLI.*/
83 |
84 |
85 |
86 | /***************************************************************************************************
87 | * APPLICATION IMPORTS
88 | */
89 | import 'hammerjs';
90 |
91 |
92 | if (!Element.prototype.matches) {
93 | Element.prototype.matches = (Element.prototype).msMatchesSelector ||
94 | Element.prototype.webkitMatchesSelector;
95 | }
--------------------------------------------------------------------------------
/modules/book/book-service/src/main/java/book/model/impl/BookCacheModel.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or modify it under
5 | * the terms of the GNU Lesser General Public License as published by the Free
6 | * Software Foundation; either version 2.1 of the License, or (at your option)
7 | * any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 | * details.
13 | */
14 |
15 | package book.model.impl;
16 |
17 | import book.model.Book;
18 |
19 | import com.liferay.petra.lang.HashUtil;
20 | import com.liferay.petra.string.StringBundler;
21 | import com.liferay.portal.kernel.model.CacheModel;
22 |
23 | import java.io.Externalizable;
24 | import java.io.IOException;
25 | import java.io.ObjectInput;
26 | import java.io.ObjectOutput;
27 |
28 | import org.osgi.annotation.versioning.ProviderType;
29 |
30 | /**
31 | * The cache model class for representing Book in entity cache.
32 | *
33 | * @author Brian Wing Shun Chan
34 | * @generated
35 | */
36 | @ProviderType
37 | public class BookCacheModel implements CacheModel, Externalizable {
38 |
39 | @Override
40 | public boolean equals(Object obj) {
41 | if (this == obj) {
42 | return true;
43 | }
44 |
45 | if (!(obj instanceof BookCacheModel)) {
46 | return false;
47 | }
48 |
49 | BookCacheModel bookCacheModel = (BookCacheModel)obj;
50 |
51 | if (isbn.equals(bookCacheModel.isbn)) {
52 | return true;
53 | }
54 |
55 | return false;
56 | }
57 |
58 | @Override
59 | public int hashCode() {
60 | return HashUtil.hash(0, isbn);
61 | }
62 |
63 | @Override
64 | public String toString() {
65 | StringBundler sb = new StringBundler(9);
66 |
67 | sb.append("{uuid=");
68 | sb.append(uuid);
69 | sb.append(", isbn=");
70 | sb.append(isbn);
71 | sb.append(", title=");
72 | sb.append(title);
73 | sb.append(", author=");
74 | sb.append(author);
75 | sb.append("}");
76 |
77 | return sb.toString();
78 | }
79 |
80 | @Override
81 | public Book toEntityModel() {
82 | BookImpl bookImpl = new BookImpl();
83 |
84 | if (uuid == null) {
85 | bookImpl.setUuid("");
86 | }
87 | else {
88 | bookImpl.setUuid(uuid);
89 | }
90 |
91 | if (isbn == null) {
92 | bookImpl.setIsbn("");
93 | }
94 | else {
95 | bookImpl.setIsbn(isbn);
96 | }
97 |
98 | if (title == null) {
99 | bookImpl.setTitle("");
100 | }
101 | else {
102 | bookImpl.setTitle(title);
103 | }
104 |
105 | if (author == null) {
106 | bookImpl.setAuthor("");
107 | }
108 | else {
109 | bookImpl.setAuthor(author);
110 | }
111 |
112 | bookImpl.resetOriginalValues();
113 |
114 | return bookImpl;
115 | }
116 |
117 | @Override
118 | public void readExternal(ObjectInput objectInput) throws IOException {
119 | uuid = objectInput.readUTF();
120 | isbn = objectInput.readUTF();
121 | title = objectInput.readUTF();
122 | author = objectInput.readUTF();
123 | }
124 |
125 | @Override
126 | public void writeExternal(ObjectOutput objectOutput) throws IOException {
127 | if (uuid == null) {
128 | objectOutput.writeUTF("");
129 | }
130 | else {
131 | objectOutput.writeUTF(uuid);
132 | }
133 |
134 | if (isbn == null) {
135 | objectOutput.writeUTF("");
136 | }
137 | else {
138 | objectOutput.writeUTF(isbn);
139 | }
140 |
141 | if (title == null) {
142 | objectOutput.writeUTF("");
143 | }
144 | else {
145 | objectOutput.writeUTF(title);
146 | }
147 |
148 | if (author == null) {
149 | objectOutput.writeUTF("");
150 | }
151 | else {
152 | objectOutput.writeUTF(author);
153 | }
154 | }
155 |
156 | public String uuid;
157 | public String isbn;
158 | public String title;
159 | public String author;
160 |
161 | }
--------------------------------------------------------------------------------
/wars/books-catalog-portlet/src/main/java/com/wordpress/kkaravitis/modules/books/catalog/AbstractAngularPortlet.java:
--------------------------------------------------------------------------------
1 | package com.wordpress.kkaravitis.modules.books.catalog;
2 |
3 | import java.io.IOException;
4 |
5 | import javax.portlet.GenericPortlet;
6 | import javax.portlet.PortletException;
7 | import javax.portlet.RenderRequest;
8 | import javax.portlet.RenderResponse;
9 | import javax.portlet.ResourceRequest;
10 | import javax.portlet.ResourceResponse;
11 | import javax.portlet.ResourceURL;
12 | import javax.servlet.http.HttpServletRequest;
13 |
14 | import com.liferay.portal.kernel.util.PortalUtil;
15 | import com.wordpress.kkaravitis.modules.books.catalog.exception.ApplicationException;
16 | import org.slf4j.Logger;
17 | import org.slf4j.LoggerFactory;
18 | import org.springframework.context.support.ClassPathXmlApplicationContext;
19 |
20 | import com.fasterxml.jackson.databind.ObjectMapper;
21 |
22 | /**
23 | *
24 | * Abstract base class for developing an Angular 8 portlet.
25 | *
26 | *
27 | * Every implementation of this class must implement the
28 | * {@link #createAngularPortletConfiguration(String, RenderRequest, RenderResponse)}
29 | * method by returning a pojo with properties that will be used for angular
30 | * application initialization.
31 | *
32 | *
33 | * @author Konstantinos Karavitis
34 | **/
35 | public abstract class AbstractAngularPortlet extends GenericPortlet {
36 | private String viewTemplate;
37 | private ClassPathXmlApplicationContext context;
38 | private Logger logger;
39 | private ObjectMapper objectMapper = new ObjectMapper();
40 |
41 | /**
42 | * Initializes the portlet.
43 | **/
44 | @Override
45 | public void init() throws PortletException {
46 | logger = LoggerFactory.getLogger(this.getClass());
47 | viewTemplate = getPortletConfig().getInitParameter(Constants.VIEW_TEMPLATE);
48 | context = new ClassPathXmlApplicationContext(Constants.PORTLET_XML_APPLICATION_CONTEXT);
49 | super.init();
50 | }
51 |
52 | /**
53 | * On portlet render phase the angular portlet
54 | * configuration is recreated because a new resource url must be created
55 | * from the new render response and be used as the base api url.
56 | **/
57 | @Override
58 | public void doView(RenderRequest request, RenderResponse response) throws IOException, PortletException {
59 | try {
60 | ResourceURL resourceURL = response.createResourceURL();
61 | String apiUrl = resourceURL.toString();
62 | AngularPortletConfig config = createAngularPortletConfiguration(apiUrl, request, response);
63 | String jsonConfig = objectMapper.writeValueAsString(config);
64 | request.setAttribute(Constants.CONFIG, jsonConfig);
65 | getPortletContext().getRequestDispatcher(viewTemplate).include(request, response);
66 | } catch (Exception exception) {
67 | throw new PortletException(exception);
68 | }
69 | }
70 |
71 | /**
72 | * Every AJAX request (supported methods: GET and POST) from angular app is
73 | * handled on this method first. At this phase the portlet resolves the uri
74 | * that the resource request must be dispatched by reading the "rest_path"
75 | * resource request parameter.
76 | **/
77 | @Override
78 | public void serveResource(ResourceRequest request, ResourceResponse response) throws PortletException, IOException {
79 | HttpServletRequest portalRequest = PortalUtil
80 | .getOriginalServletRequest(PortalUtil.getHttpServletRequest(request));
81 |
82 | String dispatchUrl = Constants.URI_PATTERN + portalRequest.getParameter(Constants.REST_PATH);
83 | String restServiceHttpMethod = portalRequest.getParameter(Constants.REST_METHOD);
84 | getPortletContext().getRequestDispatcher(dispatchUrl).forward(request, response);
85 | }
86 |
87 | /**
88 | * Returns an {@link AngularPortletConfig} implementation for
89 | * initializing the angular application.
90 | **/
91 | protected abstract AngularPortletConfig createAngularPortletConfiguration(String apiUrl, RenderRequest request, RenderResponse response) throws ApplicationException;
92 |
93 | /**
94 | * Returns the view template (view.jsp) of the portlet.
95 | **/
96 | protected String getViewTemplate() {
97 | return viewTemplate;
98 | }
99 |
100 | /**
101 | * Returns the Spring application context of the portlet app.
102 | **/
103 | protected ClassPathXmlApplicationContext getContext() {
104 | return context;
105 | }
106 |
107 | /**
108 | * Returns the logger
109 | **/
110 | protected Logger getLogger() {
111 | return logger;
112 | }
113 | }
--------------------------------------------------------------------------------
/modules/book/book-api/src/main/java/book/model/BookWrapper.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or modify it under
5 | * the terms of the GNU Lesser General Public License as published by the Free
6 | * Software Foundation; either version 2.1 of the License, or (at your option)
7 | * any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 | * details.
13 | */
14 |
15 | package book.model;
16 |
17 | import com.liferay.portal.kernel.model.ModelWrapper;
18 | import com.liferay.portal.kernel.model.wrapper.BaseModelWrapper;
19 |
20 | import java.util.HashMap;
21 | import java.util.Map;
22 |
23 | import org.osgi.annotation.versioning.ProviderType;
24 |
25 | /**
26 | *
27 | * This class is a wrapper for {@link Book}.
28 | *
29 | *
30 | * @author Brian Wing Shun Chan
31 | * @see Book
32 | * @generated
33 | */
34 | @ProviderType
35 | public class BookWrapper
36 | extends BaseModelWrapper implements Book, ModelWrapper {
37 |
38 | public BookWrapper(Book book) {
39 | super(book);
40 | }
41 |
42 | @Override
43 | public Map getModelAttributes() {
44 | Map attributes = new HashMap();
45 |
46 | attributes.put("uuid", getUuid());
47 | attributes.put("isbn", getIsbn());
48 | attributes.put("title", getTitle());
49 | attributes.put("author", getAuthor());
50 |
51 | return attributes;
52 | }
53 |
54 | @Override
55 | public void setModelAttributes(Map attributes) {
56 | String uuid = (String)attributes.get("uuid");
57 |
58 | if (uuid != null) {
59 | setUuid(uuid);
60 | }
61 |
62 | String isbn = (String)attributes.get("isbn");
63 |
64 | if (isbn != null) {
65 | setIsbn(isbn);
66 | }
67 |
68 | String title = (String)attributes.get("title");
69 |
70 | if (title != null) {
71 | setTitle(title);
72 | }
73 |
74 | String author = (String)attributes.get("author");
75 |
76 | if (author != null) {
77 | setAuthor(author);
78 | }
79 | }
80 |
81 | /**
82 | * Returns the author of this book.
83 | *
84 | * @return the author of this book
85 | */
86 | @Override
87 | public String getAuthor() {
88 | return model.getAuthor();
89 | }
90 |
91 | /**
92 | * Returns the isbn of this book.
93 | *
94 | * @return the isbn of this book
95 | */
96 | @Override
97 | public String getIsbn() {
98 | return model.getIsbn();
99 | }
100 |
101 | /**
102 | * Returns the primary key of this book.
103 | *
104 | * @return the primary key of this book
105 | */
106 | @Override
107 | public String getPrimaryKey() {
108 | return model.getPrimaryKey();
109 | }
110 |
111 | /**
112 | * Returns the title of this book.
113 | *
114 | * @return the title of this book
115 | */
116 | @Override
117 | public String getTitle() {
118 | return model.getTitle();
119 | }
120 |
121 | /**
122 | * Returns the uuid of this book.
123 | *
124 | * @return the uuid of this book
125 | */
126 | @Override
127 | public String getUuid() {
128 | return model.getUuid();
129 | }
130 |
131 | @Override
132 | public void persist() {
133 | model.persist();
134 | }
135 |
136 | /**
137 | * Sets the author of this book.
138 | *
139 | * @param author the author of this book
140 | */
141 | @Override
142 | public void setAuthor(String author) {
143 | model.setAuthor(author);
144 | }
145 |
146 | /**
147 | * Sets the isbn of this book.
148 | *
149 | * @param isbn the isbn of this book
150 | */
151 | @Override
152 | public void setIsbn(String isbn) {
153 | model.setIsbn(isbn);
154 | }
155 |
156 | /**
157 | * Sets the primary key of this book.
158 | *
159 | * @param primaryKey the primary key of this book
160 | */
161 | @Override
162 | public void setPrimaryKey(String primaryKey) {
163 | model.setPrimaryKey(primaryKey);
164 | }
165 |
166 | /**
167 | * Sets the title of this book.
168 | *
169 | * @param title the title of this book
170 | */
171 | @Override
172 | public void setTitle(String title) {
173 | model.setTitle(title);
174 | }
175 |
176 | /**
177 | * Sets the uuid of this book.
178 | *
179 | * @param uuid the uuid of this book
180 | */
181 | @Override
182 | public void setUuid(String uuid) {
183 | model.setUuid(uuid);
184 | }
185 |
186 | @Override
187 | protected BookWrapper wrap(Book book) {
188 | return new BookWrapper(book);
189 | }
190 |
191 | }
--------------------------------------------------------------------------------
/wars/books-catalog-portlet/angular.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3 | "version": 1,
4 | "newProjectRoot": "projects",
5 | "projects": {
6 | "portlet": {
7 | "root": "",
8 | "sourceRoot": "src/main/angular",
9 | "projectType": "application",
10 | "prefix": "app",
11 | "schematics": {},
12 | "architect": {
13 | "build": {
14 | "builder": "@angular-devkit/build-angular:browser",
15 | "options": {
16 | "outputPath": "target/dist/portlet",
17 | "index": "src/main/angular/index.html",
18 | "main": "src/main/angular/main.ts",
19 | "polyfills": "src/main/angular/polyfills.ts",
20 | "tsConfig": "src/main/angular/tsconfig.app.json",
21 | "assets": [
22 | "src/main/angular/favicon.ico",
23 | "src/main/angular/assets"
24 | ],
25 | "styles": [
26 | "src/main/angular/styles.css"
27 | ],
28 | "scripts": [
29 | {
30 | "input": "node_modules/document-register-element/build/document-register-element.js"
31 | },
32 | {
33 | "input": "node_modules/document-register-element/build/document-register-element.js"
34 | }
35 | ]
36 | },
37 | "configurations": {
38 | "production": {
39 | "fileReplacements": [
40 | {
41 | "replace": "src/main/angular/environments/environment.ts",
42 | "with": "src/main/angular/environments/environment.prod.ts"
43 | }
44 | ],
45 | "optimization": true,
46 | "outputHashing": "all",
47 | "sourceMap": false,
48 | "extractCss": true,
49 | "namedChunks": false,
50 | "aot": true,
51 | "extractLicenses": true,
52 | "vendorChunk": false,
53 | "buildOptimizer": true,
54 | "budgets": [
55 | {
56 | "type": "initial",
57 | "maximumWarning": "2mb",
58 | "maximumError": "5mb"
59 | }
60 | ]
61 | }
62 | }
63 | },
64 | "serve": {
65 | "builder": "@angular-devkit/build-angular:dev-server",
66 | "options": {
67 | "browserTarget": "portlet:build"
68 | },
69 | "configurations": {
70 | "production": {
71 | "browserTarget": "portlet:build:production"
72 | }
73 | }
74 | },
75 | "extract-i18n": {
76 | "builder": "@angular-devkit/build-angular:extract-i18n",
77 | "options": {
78 | "browserTarget": "portlet:build"
79 | }
80 | },
81 | "test": {
82 | "builder": "@angular-devkit/build-angular:karma",
83 | "options": {
84 | "main": "src/main/angular/test.ts",
85 | "polyfills": "src/main/angular/polyfills.ts",
86 | "tsConfig": "src/main/angular/tsconfig.spec.json",
87 | "karmaConfig": "src/main/angular/karma.conf.js",
88 | "styles": [
89 | "src/main/angular/styles.css"
90 | ],
91 | "scripts": [],
92 | "assets": [
93 | "src/main/angular/favicon.ico",
94 | "src/main/angular/assets"
95 | ]
96 | }
97 | },
98 | "lint": {
99 | "builder": "@angular-devkit/build-angular:tslint",
100 | "options": {
101 | "tsConfig": [
102 | "src/main/angular/tsconfig.app.json",
103 | "src/main/angular/tsconfig.spec.json"
104 | ],
105 | "exclude": [
106 | "**/node_modules/**"
107 | ]
108 | }
109 | }
110 | }
111 | },
112 | "portlet-e2e": {
113 | "root": "e2e/",
114 | "projectType": "application",
115 | "prefix": "",
116 | "architect": {
117 | "e2e": {
118 | "builder": "@angular-devkit/build-angular:protractor",
119 | "options": {
120 | "protractorConfig": "e2e/protractor.conf.js",
121 | "devServerTarget": "portlet:serve"
122 | },
123 | "configurations": {
124 | "production": {
125 | "devServerTarget": "portlet:serve:production"
126 | }
127 | }
128 | },
129 | "lint": {
130 | "builder": "@angular-devkit/build-angular:tslint",
131 | "options": {
132 | "tsConfig": "e2e/tsconfig.e2e.json",
133 | "exclude": [
134 | "**/node_modules/**"
135 | ]
136 | }
137 | }
138 | }
139 | }
140 | },
141 | "defaultProject": "portlet"
142 | }
--------------------------------------------------------------------------------
/wars/books-catalog-portlet/src/main/webapp/css/material-icons.css:
--------------------------------------------------------------------------------
1 | /* fallback */
2 | @font-face {
3 | font-family: 'Material Icons';
4 | font-style: normal;
5 | font-weight: 400;
6 | src: url(../assets/flUhRq6tzZclQEJ-Vdg-IuiaDsNc.woff2) format('woff2');
7 | }
8 | /* cyrillic-ext */
9 | @font-face {
10 | font-family: 'Roboto';
11 | font-style: normal;
12 | font-weight: 400;
13 | src: local('Roboto'), local('Roboto-Regular'), url(../assets/KFOmCnqEu92Fr1Mu72xKOzY.woff2) format('woff2');
14 | unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
15 | }
16 | /* cyrillic */
17 | @font-face {
18 | font-family: 'Roboto';
19 | font-style: normal;
20 | font-weight: 400;
21 | src: local('Roboto'), local('Roboto-Regular'), url(../assets/KFOmCnqEu92Fr1Mu5mxKOzY.woff2) format('woff2');
22 | unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
23 | }
24 | /* greek-ext */
25 | @font-face {
26 | font-family: 'Roboto';
27 | font-style: normal;
28 | font-weight: 400;
29 | src: local('Roboto'), local('Roboto-Regular'), url(../assets/KFOmCnqEu92Fr1Mu7mxKOzY.woff2) format('woff2');
30 | unicode-range: U+1F00-1FFF;
31 | }
32 | /* greek */
33 | @font-face {
34 | font-family: 'Roboto';
35 | font-style: normal;
36 | font-weight: 400;
37 | src: local('Roboto'), local('Roboto-Regular'), url(../assets/KFOmCnqEu92Fr1Mu4WxKOzY.woff2) format('woff2');
38 | unicode-range: U+0370-03FF;
39 | }
40 | /* vietnamese */
41 | @font-face {
42 | font-family: 'Roboto';
43 | font-style: normal;
44 | font-weight: 400;
45 | src: local('Roboto'), local('Roboto-Regular'), url(../assets/KFOmCnqEu92Fr1Mu7WxKOzY.woff2) format('woff2');
46 | unicode-range: U+0102-0103, U+0110-0111, U+1EA0-1EF9, U+20AB;
47 | }
48 | /* latin-ext */
49 | @font-face {
50 | font-family: 'Roboto';
51 | font-style: normal;
52 | font-weight: 400;
53 | src: local('Roboto'), local('Roboto-Regular'), url(../assets/KFOmCnqEu92Fr1Mu7GxKOzY.woff2) format('woff2');
54 | unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
55 | }
56 | /* latin */
57 | @font-face {
58 | font-family: 'Roboto';
59 | font-style: normal;
60 | font-weight: 400;
61 | src: local('Roboto'), local('Roboto-Regular'), url(../assets/KFOmCnqEu92Fr1Mu4mxK.woff2) format('woff2');
62 | unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
63 | }
64 | /* cyrillic-ext */
65 | @font-face {
66 | font-family: 'Roboto';
67 | font-style: normal;
68 | font-weight: 700;
69 | src: local('Roboto Bold'), local('Roboto-Bold'), url(../assets/KFOlCnqEu92Fr1MmWUlfCRc4EsA.woff2) format('woff2');
70 | unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
71 | }
72 | /* cyrillic */
73 | @font-face {
74 | font-family: 'Roboto';
75 | font-style: normal;
76 | font-weight: 700;
77 | src: local('Roboto Bold'), local('Roboto-Bold'), url(../assets/KFOlCnqEu92Fr1MmWUlfABc4EsA.woff2) format('woff2');
78 | unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
79 | }
80 | /* greek-ext */
81 | @font-face {
82 | font-family: 'Roboto';
83 | font-style: normal;
84 | font-weight: 700;
85 | src: local('Roboto Bold'), local('Roboto-Bold'), url(../assets/KFOlCnqEu92Fr1MmWUlfCBc4EsA.woff2) format('woff2');
86 | unicode-range: U+1F00-1FFF;
87 | }
88 | /* greek */
89 | @font-face {
90 | font-family: 'Roboto';
91 | font-style: normal;
92 | font-weight: 700;
93 | src: local('Roboto Bold'), local('Roboto-Bold'), url(../assets/KFOlCnqEu92Fr1MmWUlfBxc4EsA.woff2) format('woff2');
94 | unicode-range: U+0370-03FF;
95 | }
96 | /* vietnamese */
97 | @font-face {
98 | font-family: 'Roboto';
99 | font-style: normal;
100 | font-weight: 700;
101 | src: local('Roboto Bold'), local('Roboto-Bold'), url(../assets/KFOlCnqEu92Fr1MmWUlfCxc4EsA.woff2) format('woff2');
102 | unicode-range: U+0102-0103, U+0110-0111, U+1EA0-1EF9, U+20AB;
103 | }
104 | /* latin-ext */
105 | @font-face {
106 | font-family: 'Roboto';
107 | font-style: normal;
108 | font-weight: 700;
109 | src: local('Roboto Bold'), local('Roboto-Bold'), url(../assets/KFOlCnqEu92Fr1MmWUlfChc4EsA.woff2) format('woff2');
110 | unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
111 | }
112 | /* latin */
113 | @font-face {
114 | font-family: 'Roboto';
115 | font-style: normal;
116 | font-weight: 700;
117 | src: local('Roboto Bold'), local('Roboto-Bold'), url(../assets/KFOlCnqEu92Fr1MmWUlfBBc4.woff2) format('woff2');
118 | unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
119 | }
120 | .material-icons {
121 | font-family: 'Material Icons';
122 | font-weight: normal;
123 | font-style: normal;
124 | font-size: 24px;
125 | line-height: 1;
126 | letter-spacing: normal;
127 | text-transform: none;
128 | display: inline-block;
129 | white-space: nowrap;
130 | word-wrap: normal;
131 | direction: ltr;
132 | -webkit-font-feature-settings: 'liga';
133 | -webkit-font-smoothing: antialiased;
134 | }
--------------------------------------------------------------------------------
/mvnw.cmd:
--------------------------------------------------------------------------------
1 | @REM ----------------------------------------------------------------------------
2 | @REM Licensed to the Apache Software Foundation (ASF) under one
3 | @REM or more contributor license agreements. See the NOTICE file
4 | @REM distributed with this work for additional information
5 | @REM regarding copyright ownership. The ASF licenses this file
6 | @REM to you under the Apache License, Version 2.0 (the
7 | @REM "License"); you may not use this file except in compliance
8 | @REM with the License. You may obtain a copy of the License at
9 | @REM
10 | @REM http://www.apache.org/licenses/LICENSE-2.0
11 | @REM
12 | @REM Unless required by applicable law or agreed to in writing,
13 | @REM software distributed under the License is distributed on an
14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | @REM KIND, either express or implied. See the License for the
16 | @REM specific language governing permissions and limitations
17 | @REM under the License.
18 | @REM ----------------------------------------------------------------------------
19 |
20 | @REM ----------------------------------------------------------------------------
21 | @REM Maven2 Start Up Batch script
22 | @REM
23 | @REM Required ENV vars:
24 | @REM JAVA_HOME - location of a JDK home dir
25 | @REM
26 | @REM Optional ENV vars
27 | @REM M2_HOME - location of maven2's installed home dir
28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
31 | @REM e.g. to debug Maven itself, use
32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
34 | @REM ----------------------------------------------------------------------------
35 |
36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
37 | @echo off
38 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
40 |
41 | @REM set %HOME% to equivalent of $HOME
42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
43 |
44 | @REM Execute a user defined script before this one
45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending
47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
49 | :skipRcPre
50 |
51 | @setlocal
52 |
53 | set ERROR_CODE=0
54 |
55 | @REM To isolate internal variables from possible post scripts, we use another setlocal
56 | @setlocal
57 |
58 | @REM ==== START VALIDATION ====
59 | if not "%JAVA_HOME%" == "" goto OkJHome
60 |
61 | echo.
62 | echo Error: JAVA_HOME not found in your environment. >&2
63 | echo Please set the JAVA_HOME variable in your environment to match the >&2
64 | echo location of your Java installation. >&2
65 | echo.
66 | goto error
67 |
68 | :OkJHome
69 | if exist "%JAVA_HOME%\bin\java.exe" goto init
70 |
71 | echo.
72 | echo Error: JAVA_HOME is set to an invalid directory. >&2
73 | echo JAVA_HOME = "%JAVA_HOME%" >&2
74 | echo Please set the JAVA_HOME variable in your environment to match the >&2
75 | echo location of your Java installation. >&2
76 | echo.
77 | goto error
78 |
79 | @REM ==== END VALIDATION ====
80 |
81 | :init
82 |
83 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
84 | @REM Fallback to current working directory if not found.
85 |
86 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
87 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
88 |
89 | set EXEC_DIR=%CD%
90 | set WDIR=%EXEC_DIR%
91 | :findBaseDir
92 | IF EXIST "%WDIR%"\.mvn goto baseDirFound
93 | cd ..
94 | IF "%WDIR%"=="%CD%" goto baseDirNotFound
95 | set WDIR=%CD%
96 | goto findBaseDir
97 |
98 | :baseDirFound
99 | set MAVEN_PROJECTBASEDIR=%WDIR%
100 | cd "%EXEC_DIR%"
101 | goto endDetectBaseDir
102 |
103 | :baseDirNotFound
104 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
105 | cd "%EXEC_DIR%"
106 |
107 | :endDetectBaseDir
108 |
109 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
110 |
111 | @setlocal EnableExtensions EnableDelayedExpansion
112 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
113 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
114 |
115 | :endReadAdditionalConfig
116 |
117 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
118 |
119 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
120 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
121 |
122 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
123 | if ERRORLEVEL 1 goto error
124 | goto end
125 |
126 | :error
127 | set ERROR_CODE=1
128 |
129 | :end
130 | @endlocal & set ERROR_CODE=%ERROR_CODE%
131 |
132 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
133 | @REM check for post script, once with legacy .bat ending and once with .cmd ending
134 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
135 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
136 | :skipRcPost
137 |
138 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
139 | if "%MAVEN_BATCH_PAUSE%" == "on" pause
140 |
141 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
142 |
143 | exit /B %ERROR_CODE%
144 |
--------------------------------------------------------------------------------
/modules/book/mvnw.cmd:
--------------------------------------------------------------------------------
1 | @REM ----------------------------------------------------------------------------
2 | @REM Licensed to the Apache Software Foundation (ASF) under one
3 | @REM or more contributor license agreements. See the NOTICE file
4 | @REM distributed with this work for additional information
5 | @REM regarding copyright ownership. The ASF licenses this file
6 | @REM to you under the Apache License, Version 2.0 (the
7 | @REM "License"); you may not use this file except in compliance
8 | @REM with the License. You may obtain a copy of the License at
9 | @REM
10 | @REM http://www.apache.org/licenses/LICENSE-2.0
11 | @REM
12 | @REM Unless required by applicable law or agreed to in writing,
13 | @REM software distributed under the License is distributed on an
14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | @REM KIND, either express or implied. See the License for the
16 | @REM specific language governing permissions and limitations
17 | @REM under the License.
18 | @REM ----------------------------------------------------------------------------
19 |
20 | @REM ----------------------------------------------------------------------------
21 | @REM Maven2 Start Up Batch script
22 | @REM
23 | @REM Required ENV vars:
24 | @REM JAVA_HOME - location of a JDK home dir
25 | @REM
26 | @REM Optional ENV vars
27 | @REM M2_HOME - location of maven2's installed home dir
28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
31 | @REM e.g. to debug Maven itself, use
32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
34 | @REM ----------------------------------------------------------------------------
35 |
36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
37 | @echo off
38 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
40 |
41 | @REM set %HOME% to equivalent of $HOME
42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
43 |
44 | @REM Execute a user defined script before this one
45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending
47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
49 | :skipRcPre
50 |
51 | @setlocal
52 |
53 | set ERROR_CODE=0
54 |
55 | @REM To isolate internal variables from possible post scripts, we use another setlocal
56 | @setlocal
57 |
58 | @REM ==== START VALIDATION ====
59 | if not "%JAVA_HOME%" == "" goto OkJHome
60 |
61 | echo.
62 | echo Error: JAVA_HOME not found in your environment. >&2
63 | echo Please set the JAVA_HOME variable in your environment to match the >&2
64 | echo location of your Java installation. >&2
65 | echo.
66 | goto error
67 |
68 | :OkJHome
69 | if exist "%JAVA_HOME%\bin\java.exe" goto init
70 |
71 | echo.
72 | echo Error: JAVA_HOME is set to an invalid directory. >&2
73 | echo JAVA_HOME = "%JAVA_HOME%" >&2
74 | echo Please set the JAVA_HOME variable in your environment to match the >&2
75 | echo location of your Java installation. >&2
76 | echo.
77 | goto error
78 |
79 | @REM ==== END VALIDATION ====
80 |
81 | :init
82 |
83 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
84 | @REM Fallback to current working directory if not found.
85 |
86 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
87 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
88 |
89 | set EXEC_DIR=%CD%
90 | set WDIR=%EXEC_DIR%
91 | :findBaseDir
92 | IF EXIST "%WDIR%"\.mvn goto baseDirFound
93 | cd ..
94 | IF "%WDIR%"=="%CD%" goto baseDirNotFound
95 | set WDIR=%CD%
96 | goto findBaseDir
97 |
98 | :baseDirFound
99 | set MAVEN_PROJECTBASEDIR=%WDIR%
100 | cd "%EXEC_DIR%"
101 | goto endDetectBaseDir
102 |
103 | :baseDirNotFound
104 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
105 | cd "%EXEC_DIR%"
106 |
107 | :endDetectBaseDir
108 |
109 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
110 |
111 | @setlocal EnableExtensions EnableDelayedExpansion
112 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
113 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
114 |
115 | :endReadAdditionalConfig
116 |
117 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
118 |
119 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
120 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
121 |
122 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
123 | if ERRORLEVEL 1 goto error
124 | goto end
125 |
126 | :error
127 | set ERROR_CODE=1
128 |
129 | :end
130 | @endlocal & set ERROR_CODE=%ERROR_CODE%
131 |
132 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
133 | @REM check for post script, once with legacy .bat ending and once with .cmd ending
134 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
135 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
136 | :skipRcPost
137 |
138 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
139 | if "%MAVEN_BATCH_PAUSE%" == "on" pause
140 |
141 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
142 |
143 | exit /B %ERROR_CODE%
144 |
--------------------------------------------------------------------------------
/mvnw:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # ----------------------------------------------------------------------------
3 | # Licensed to the Apache Software Foundation (ASF) under one
4 | # or more contributor license agreements. See the NOTICE file
5 | # distributed with this work for additional information
6 | # regarding copyright ownership. The ASF licenses this file
7 | # to you under the Apache License, Version 2.0 (the
8 | # "License"); you may not use this file except in compliance
9 | # with the License. You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing,
14 | # software distributed under the License is distributed on an
15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | # KIND, either express or implied. See the License for the
17 | # specific language governing permissions and limitations
18 | # under the License.
19 | # ----------------------------------------------------------------------------
20 |
21 | # ----------------------------------------------------------------------------
22 | # Maven2 Start Up Batch script
23 | #
24 | # Required ENV vars:
25 | # ------------------
26 | # JAVA_HOME - location of a JDK home dir
27 | #
28 | # Optional ENV vars
29 | # -----------------
30 | # M2_HOME - location of maven2's installed home dir
31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven
32 | # e.g. to debug Maven itself, use
33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files
35 | # ----------------------------------------------------------------------------
36 |
37 | if [ -z "$MAVEN_SKIP_RC" ] ; then
38 |
39 | if [ -f /etc/mavenrc ] ; then
40 | . /etc/mavenrc
41 | fi
42 |
43 | if [ -f "$HOME/.mavenrc" ] ; then
44 | . "$HOME/.mavenrc"
45 | fi
46 |
47 | fi
48 |
49 | # OS specific support. $var _must_ be set to either true or false.
50 | cygwin=false;
51 | darwin=false;
52 | mingw=false
53 | case "`uname`" in
54 | CYGWIN*) cygwin=true ;;
55 | MINGW*) mingw=true;;
56 | Darwin*) darwin=true
57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
59 | if [ -z "$JAVA_HOME" ]; then
60 | if [ -x "/usr/libexec/java_home" ]; then
61 | export JAVA_HOME="`/usr/libexec/java_home`"
62 | else
63 | export JAVA_HOME="/Library/Java/Home"
64 | fi
65 | fi
66 | ;;
67 | esac
68 |
69 | if [ -z "$JAVA_HOME" ] ; then
70 | if [ -r /etc/gentoo-release ] ; then
71 | JAVA_HOME=`java-config --jre-home`
72 | fi
73 | fi
74 |
75 | if [ -z "$M2_HOME" ] ; then
76 | ## resolve links - $0 may be a link to maven's home
77 | PRG="$0"
78 |
79 | # need this for relative symlinks
80 | while [ -h "$PRG" ] ; do
81 | ls=`ls -ld "$PRG"`
82 | link=`expr "$ls" : '.*-> \(.*\)$'`
83 | if expr "$link" : '/.*' > /dev/null; then
84 | PRG="$link"
85 | else
86 | PRG="`dirname "$PRG"`/$link"
87 | fi
88 | done
89 |
90 | saveddir=`pwd`
91 |
92 | M2_HOME=`dirname "$PRG"`/..
93 |
94 | # make it fully qualified
95 | M2_HOME=`cd "$M2_HOME" && pwd`
96 |
97 | cd "$saveddir"
98 | # echo Using m2 at $M2_HOME
99 | fi
100 |
101 | # For Cygwin, ensure paths are in UNIX format before anything is touched
102 | if $cygwin ; then
103 | [ -n "$M2_HOME" ] &&
104 | M2_HOME=`cygpath --unix "$M2_HOME"`
105 | [ -n "$JAVA_HOME" ] &&
106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
107 | [ -n "$CLASSPATH" ] &&
108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
109 | fi
110 |
111 | # For Migwn, ensure paths are in UNIX format before anything is touched
112 | if $mingw ; then
113 | [ -n "$M2_HOME" ] &&
114 | M2_HOME="`(cd "$M2_HOME"; pwd)`"
115 | [ -n "$JAVA_HOME" ] &&
116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
117 | # TODO classpath?
118 | fi
119 |
120 | if [ -z "$JAVA_HOME" ]; then
121 | javaExecutable="`which javac`"
122 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
123 | # readlink(1) is not available as standard on Solaris 10.
124 | readLink=`which readlink`
125 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
126 | if $darwin ; then
127 | javaHome="`dirname \"$javaExecutable\"`"
128 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
129 | else
130 | javaExecutable="`readlink -f \"$javaExecutable\"`"
131 | fi
132 | javaHome="`dirname \"$javaExecutable\"`"
133 | javaHome=`expr "$javaHome" : '\(.*\)/bin'`
134 | JAVA_HOME="$javaHome"
135 | export JAVA_HOME
136 | fi
137 | fi
138 | fi
139 |
140 | if [ -z "$JAVACMD" ] ; then
141 | if [ -n "$JAVA_HOME" ] ; then
142 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
143 | # IBM's JDK on AIX uses strange locations for the executables
144 | JAVACMD="$JAVA_HOME/jre/sh/java"
145 | else
146 | JAVACMD="$JAVA_HOME/bin/java"
147 | fi
148 | else
149 | JAVACMD="`which java`"
150 | fi
151 | fi
152 |
153 | if [ ! -x "$JAVACMD" ] ; then
154 | echo "Error: JAVA_HOME is not defined correctly." >&2
155 | echo " We cannot execute $JAVACMD" >&2
156 | exit 1
157 | fi
158 |
159 | if [ -z "$JAVA_HOME" ] ; then
160 | echo "Warning: JAVA_HOME environment variable is not set."
161 | fi
162 |
163 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
164 |
165 | # traverses directory structure from process work directory to filesystem root
166 | # first directory with .mvn subdirectory is considered project base directory
167 | find_maven_basedir() {
168 |
169 | if [ -z "$1" ]
170 | then
171 | echo "Path not specified to find_maven_basedir"
172 | return 1
173 | fi
174 |
175 | basedir="$1"
176 | wdir="$1"
177 | while [ "$wdir" != '/' ] ; do
178 | if [ -d "$wdir"/.mvn ] ; then
179 | basedir=$wdir
180 | break
181 | fi
182 | # workaround for JBEAP-8937 (on Solaris 10/Sparc)
183 | if [ -d "${wdir}" ]; then
184 | wdir=`cd "$wdir/.."; pwd`
185 | fi
186 | # end of workaround
187 | done
188 | echo "${basedir}"
189 | }
190 |
191 | # concatenates all lines of a file
192 | concat_lines() {
193 | if [ -f "$1" ]; then
194 | echo "$(tr -s '\n' ' ' < "$1")"
195 | fi
196 | }
197 |
198 | BASE_DIR=`find_maven_basedir "$(pwd)"`
199 | if [ -z "$BASE_DIR" ]; then
200 | exit 1;
201 | fi
202 |
203 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
204 | echo $MAVEN_PROJECTBASEDIR
205 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
206 |
207 | # For Cygwin, switch paths to Windows format before running java
208 | if $cygwin; then
209 | [ -n "$M2_HOME" ] &&
210 | M2_HOME=`cygpath --path --windows "$M2_HOME"`
211 | [ -n "$JAVA_HOME" ] &&
212 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
213 | [ -n "$CLASSPATH" ] &&
214 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
215 | [ -n "$MAVEN_PROJECTBASEDIR" ] &&
216 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
217 | fi
218 |
219 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
220 |
221 | exec "$JAVACMD" \
222 | $MAVEN_OPTS \
223 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
224 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
225 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
226 |
--------------------------------------------------------------------------------
/modules/book/mvnw:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # ----------------------------------------------------------------------------
3 | # Licensed to the Apache Software Foundation (ASF) under one
4 | # or more contributor license agreements. See the NOTICE file
5 | # distributed with this work for additional information
6 | # regarding copyright ownership. The ASF licenses this file
7 | # to you under the Apache License, Version 2.0 (the
8 | # "License"); you may not use this file except in compliance
9 | # with the License. You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing,
14 | # software distributed under the License is distributed on an
15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | # KIND, either express or implied. See the License for the
17 | # specific language governing permissions and limitations
18 | # under the License.
19 | # ----------------------------------------------------------------------------
20 |
21 | # ----------------------------------------------------------------------------
22 | # Maven2 Start Up Batch script
23 | #
24 | # Required ENV vars:
25 | # ------------------
26 | # JAVA_HOME - location of a JDK home dir
27 | #
28 | # Optional ENV vars
29 | # -----------------
30 | # M2_HOME - location of maven2's installed home dir
31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven
32 | # e.g. to debug Maven itself, use
33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files
35 | # ----------------------------------------------------------------------------
36 |
37 | if [ -z "$MAVEN_SKIP_RC" ] ; then
38 |
39 | if [ -f /etc/mavenrc ] ; then
40 | . /etc/mavenrc
41 | fi
42 |
43 | if [ -f "$HOME/.mavenrc" ] ; then
44 | . "$HOME/.mavenrc"
45 | fi
46 |
47 | fi
48 |
49 | # OS specific support. $var _must_ be set to either true or false.
50 | cygwin=false;
51 | darwin=false;
52 | mingw=false
53 | case "`uname`" in
54 | CYGWIN*) cygwin=true ;;
55 | MINGW*) mingw=true;;
56 | Darwin*) darwin=true
57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
59 | if [ -z "$JAVA_HOME" ]; then
60 | if [ -x "/usr/libexec/java_home" ]; then
61 | export JAVA_HOME="`/usr/libexec/java_home`"
62 | else
63 | export JAVA_HOME="/Library/Java/Home"
64 | fi
65 | fi
66 | ;;
67 | esac
68 |
69 | if [ -z "$JAVA_HOME" ] ; then
70 | if [ -r /etc/gentoo-release ] ; then
71 | JAVA_HOME=`java-config --jre-home`
72 | fi
73 | fi
74 |
75 | if [ -z "$M2_HOME" ] ; then
76 | ## resolve links - $0 may be a link to maven's home
77 | PRG="$0"
78 |
79 | # need this for relative symlinks
80 | while [ -h "$PRG" ] ; do
81 | ls=`ls -ld "$PRG"`
82 | link=`expr "$ls" : '.*-> \(.*\)$'`
83 | if expr "$link" : '/.*' > /dev/null; then
84 | PRG="$link"
85 | else
86 | PRG="`dirname "$PRG"`/$link"
87 | fi
88 | done
89 |
90 | saveddir=`pwd`
91 |
92 | M2_HOME=`dirname "$PRG"`/..
93 |
94 | # make it fully qualified
95 | M2_HOME=`cd "$M2_HOME" && pwd`
96 |
97 | cd "$saveddir"
98 | # echo Using m2 at $M2_HOME
99 | fi
100 |
101 | # For Cygwin, ensure paths are in UNIX format before anything is touched
102 | if $cygwin ; then
103 | [ -n "$M2_HOME" ] &&
104 | M2_HOME=`cygpath --unix "$M2_HOME"`
105 | [ -n "$JAVA_HOME" ] &&
106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
107 | [ -n "$CLASSPATH" ] &&
108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
109 | fi
110 |
111 | # For Migwn, ensure paths are in UNIX format before anything is touched
112 | if $mingw ; then
113 | [ -n "$M2_HOME" ] &&
114 | M2_HOME="`(cd "$M2_HOME"; pwd)`"
115 | [ -n "$JAVA_HOME" ] &&
116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
117 | # TODO classpath?
118 | fi
119 |
120 | if [ -z "$JAVA_HOME" ]; then
121 | javaExecutable="`which javac`"
122 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
123 | # readlink(1) is not available as standard on Solaris 10.
124 | readLink=`which readlink`
125 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
126 | if $darwin ; then
127 | javaHome="`dirname \"$javaExecutable\"`"
128 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
129 | else
130 | javaExecutable="`readlink -f \"$javaExecutable\"`"
131 | fi
132 | javaHome="`dirname \"$javaExecutable\"`"
133 | javaHome=`expr "$javaHome" : '\(.*\)/bin'`
134 | JAVA_HOME="$javaHome"
135 | export JAVA_HOME
136 | fi
137 | fi
138 | fi
139 |
140 | if [ -z "$JAVACMD" ] ; then
141 | if [ -n "$JAVA_HOME" ] ; then
142 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
143 | # IBM's JDK on AIX uses strange locations for the executables
144 | JAVACMD="$JAVA_HOME/jre/sh/java"
145 | else
146 | JAVACMD="$JAVA_HOME/bin/java"
147 | fi
148 | else
149 | JAVACMD="`which java`"
150 | fi
151 | fi
152 |
153 | if [ ! -x "$JAVACMD" ] ; then
154 | echo "Error: JAVA_HOME is not defined correctly." >&2
155 | echo " We cannot execute $JAVACMD" >&2
156 | exit 1
157 | fi
158 |
159 | if [ -z "$JAVA_HOME" ] ; then
160 | echo "Warning: JAVA_HOME environment variable is not set."
161 | fi
162 |
163 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
164 |
165 | # traverses directory structure from process work directory to filesystem root
166 | # first directory with .mvn subdirectory is considered project base directory
167 | find_maven_basedir() {
168 |
169 | if [ -z "$1" ]
170 | then
171 | echo "Path not specified to find_maven_basedir"
172 | return 1
173 | fi
174 |
175 | basedir="$1"
176 | wdir="$1"
177 | while [ "$wdir" != '/' ] ; do
178 | if [ -d "$wdir"/.mvn ] ; then
179 | basedir=$wdir
180 | break
181 | fi
182 | # workaround for JBEAP-8937 (on Solaris 10/Sparc)
183 | if [ -d "${wdir}" ]; then
184 | wdir=`cd "$wdir/.."; pwd`
185 | fi
186 | # end of workaround
187 | done
188 | echo "${basedir}"
189 | }
190 |
191 | # concatenates all lines of a file
192 | concat_lines() {
193 | if [ -f "$1" ]; then
194 | echo "$(tr -s '\n' ' ' < "$1")"
195 | fi
196 | }
197 |
198 | BASE_DIR=`find_maven_basedir "$(pwd)"`
199 | if [ -z "$BASE_DIR" ]; then
200 | exit 1;
201 | fi
202 |
203 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
204 | echo $MAVEN_PROJECTBASEDIR
205 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
206 |
207 | # For Cygwin, switch paths to Windows format before running java
208 | if $cygwin; then
209 | [ -n "$M2_HOME" ] &&
210 | M2_HOME=`cygpath --path --windows "$M2_HOME"`
211 | [ -n "$JAVA_HOME" ] &&
212 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
213 | [ -n "$CLASSPATH" ] &&
214 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
215 | [ -n "$MAVEN_PROJECTBASEDIR" ] &&
216 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
217 | fi
218 |
219 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
220 |
221 | exec "$JAVACMD" \
222 | $MAVEN_OPTS \
223 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
224 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
225 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
226 |
--------------------------------------------------------------------------------
/modules/book/book-api/src/main/java/book/service/BookLocalService.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or modify it under
5 | * the terms of the GNU Lesser General Public License as published by the Free
6 | * Software Foundation; either version 2.1 of the License, or (at your option)
7 | * any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 | * details.
13 | */
14 |
15 | package book.service;
16 |
17 | import book.model.Book;
18 |
19 | import com.liferay.portal.kernel.dao.orm.DynamicQuery;
20 | import com.liferay.portal.kernel.dao.orm.Projection;
21 | import com.liferay.portal.kernel.exception.PortalException;
22 | import com.liferay.portal.kernel.exception.SystemException;
23 | import com.liferay.portal.kernel.model.PersistedModel;
24 | import com.liferay.portal.kernel.search.Indexable;
25 | import com.liferay.portal.kernel.search.IndexableType;
26 | import com.liferay.portal.kernel.service.BaseLocalService;
27 | import com.liferay.portal.kernel.service.PersistedModelLocalService;
28 | import com.liferay.portal.kernel.transaction.Isolation;
29 | import com.liferay.portal.kernel.transaction.Propagation;
30 | import com.liferay.portal.kernel.transaction.Transactional;
31 | import com.liferay.portal.kernel.util.OrderByComparator;
32 |
33 | import java.io.Serializable;
34 |
35 | import java.util.List;
36 |
37 | import org.osgi.annotation.versioning.ProviderType;
38 |
39 | /**
40 | * Provides the local service interface for Book. Methods of this
41 | * service will not have security checks based on the propagated JAAS
42 | * credentials because this service can only be accessed from within the same
43 | * VM.
44 | *
45 | * @author Brian Wing Shun Chan
46 | * @see BookLocalServiceUtil
47 | * @generated
48 | */
49 | @ProviderType
50 | @Transactional(
51 | isolation = Isolation.PORTAL,
52 | rollbackFor = {PortalException.class, SystemException.class}
53 | )
54 | public interface BookLocalService
55 | extends BaseLocalService, PersistedModelLocalService {
56 |
57 | /*
58 | * NOTE FOR DEVELOPERS:
59 | *
60 | * Never modify or reference this interface directly. Always use {@link BookLocalServiceUtil} to access the book local service. Add custom service methods to book.service.impl.BookLocalServiceImpl and rerun ServiceBuilder to automatically copy the method declarations to this interface.
61 | */
62 |
63 | /**
64 | * Adds the book to the database. Also notifies the appropriate model listeners.
65 | *
66 | * @param book the book
67 | * @return the book that was added
68 | */
69 | @Indexable(type = IndexableType.REINDEX)
70 | public Book addBook(Book book);
71 |
72 | /**
73 | * Creates a new book with the primary key. Does not add the book to the database.
74 | *
75 | * @param isbn the primary key for the new book
76 | * @return the new book
77 | */
78 | @Transactional(enabled = false)
79 | public Book createBook(String isbn);
80 |
81 | /**
82 | * Deletes the book from the database. Also notifies the appropriate model listeners.
83 | *
84 | * @param book the book
85 | * @return the book that was removed
86 | */
87 | @Indexable(type = IndexableType.DELETE)
88 | public Book deleteBook(Book book);
89 |
90 | /**
91 | * Deletes the book with the primary key from the database. Also notifies the appropriate model listeners.
92 | *
93 | * @param isbn the primary key of the book
94 | * @return the book that was removed
95 | * @throws PortalException if a book with the primary key could not be found
96 | */
97 | @Indexable(type = IndexableType.DELETE)
98 | public Book deleteBook(String isbn) throws PortalException;
99 |
100 | /**
101 | * @throws PortalException
102 | */
103 | @Override
104 | public PersistedModel deletePersistedModel(PersistedModel persistedModel)
105 | throws PortalException;
106 |
107 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
108 | public DynamicQuery dynamicQuery();
109 |
110 | /**
111 | * Performs a dynamic query on the database and returns the matching rows.
112 | *
113 | * @param dynamicQuery the dynamic query
114 | * @return the matching rows
115 | */
116 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
117 | public List dynamicQuery(DynamicQuery dynamicQuery);
118 |
119 | /**
120 | * Performs a dynamic query on the database and returns a range of the matching rows.
121 | *
122 | *
123 | * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from book.model.impl.BookModelImpl. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
124 | *
125 | *
126 | * @param dynamicQuery the dynamic query
127 | * @param start the lower bound of the range of model instances
128 | * @param end the upper bound of the range of model instances (not inclusive)
129 | * @return the range of matching rows
130 | */
131 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
132 | public List dynamicQuery(
133 | DynamicQuery dynamicQuery, int start, int end);
134 |
135 | /**
136 | * Performs a dynamic query on the database and returns an ordered range of the matching rows.
137 | *
138 | *
139 | * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from book.model.impl.BookModelImpl. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
140 | *
141 | *
142 | * @param dynamicQuery the dynamic query
143 | * @param start the lower bound of the range of model instances
144 | * @param end the upper bound of the range of model instances (not inclusive)
145 | * @param orderByComparator the comparator to order the results by (optionally null)
146 | * @return the ordered range of matching rows
147 | */
148 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
149 | public List dynamicQuery(
150 | DynamicQuery dynamicQuery, int start, int end,
151 | OrderByComparator orderByComparator);
152 |
153 | /**
154 | * Returns the number of rows matching the dynamic query.
155 | *
156 | * @param dynamicQuery the dynamic query
157 | * @return the number of rows matching the dynamic query
158 | */
159 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
160 | public long dynamicQueryCount(DynamicQuery dynamicQuery);
161 |
162 | /**
163 | * Returns the number of rows matching the dynamic query.
164 | *
165 | * @param dynamicQuery the dynamic query
166 | * @param projection the projection to apply to the query
167 | * @return the number of rows matching the dynamic query
168 | */
169 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
170 | public long dynamicQueryCount(
171 | DynamicQuery dynamicQuery, Projection projection);
172 |
173 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
174 | public Book fetchBook(String isbn);
175 |
176 | /**
177 | * Returns the book with the primary key.
178 | *
179 | * @param isbn the primary key of the book
180 | * @return the book
181 | * @throws PortalException if a book with the primary key could not be found
182 | */
183 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
184 | public Book getBook(String isbn) throws PortalException;
185 |
186 | /**
187 | * Returns a range of all the books.
188 | *
189 | *
190 | * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from book.model.impl.BookModelImpl. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
191 | *
192 | *
193 | * @param start the lower bound of the range of books
194 | * @param end the upper bound of the range of books (not inclusive)
195 | * @return the range of books
196 | */
197 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
198 | public List getBooks(int start, int end);
199 |
200 | /**
201 | * Returns the number of books.
202 | *
203 | * @return the number of books
204 | */
205 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
206 | public int getBooksCount();
207 |
208 | /**
209 | * Returns the OSGi service identifier.
210 | *
211 | * @return the OSGi service identifier
212 | */
213 | public String getOSGiServiceIdentifier();
214 |
215 | @Override
216 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
217 | public PersistedModel getPersistedModel(Serializable primaryKeyObj)
218 | throws PortalException;
219 |
220 | /**
221 | * Updates the book in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
222 | *
223 | * @param book the book
224 | * @return the book that was updated
225 | */
226 | @Indexable(type = IndexableType.REINDEX)
227 | public Book updateBook(Book book);
228 |
229 | }
--------------------------------------------------------------------------------
/modules/book/book-api/src/main/java/book/service/BookLocalServiceWrapper.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or modify it under
5 | * the terms of the GNU Lesser General Public License as published by the Free
6 | * Software Foundation; either version 2.1 of the License, or (at your option)
7 | * any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 | * details.
13 | */
14 |
15 | package book.service;
16 |
17 | import com.liferay.portal.kernel.service.ServiceWrapper;
18 |
19 | import org.osgi.annotation.versioning.ProviderType;
20 |
21 | /**
22 | * Provides a wrapper for {@link BookLocalService}.
23 | *
24 | * @author Brian Wing Shun Chan
25 | * @see BookLocalService
26 | * @generated
27 | */
28 | @ProviderType
29 | public class BookLocalServiceWrapper
30 | implements BookLocalService, ServiceWrapper {
31 |
32 | public BookLocalServiceWrapper(BookLocalService bookLocalService) {
33 | _bookLocalService = bookLocalService;
34 | }
35 |
36 | /**
37 | * Adds the book to the database. Also notifies the appropriate model listeners.
38 | *
39 | * @param book the book
40 | * @return the book that was added
41 | */
42 | @Override
43 | public book.model.Book addBook(book.model.Book book) {
44 | return _bookLocalService.addBook(book);
45 | }
46 |
47 | /**
48 | * Creates a new book with the primary key. Does not add the book to the database.
49 | *
50 | * @param isbn the primary key for the new book
51 | * @return the new book
52 | */
53 | @Override
54 | public book.model.Book createBook(String isbn) {
55 | return _bookLocalService.createBook(isbn);
56 | }
57 |
58 | /**
59 | * Deletes the book from the database. Also notifies the appropriate model listeners.
60 | *
61 | * @param book the book
62 | * @return the book that was removed
63 | */
64 | @Override
65 | public book.model.Book deleteBook(book.model.Book book) {
66 | return _bookLocalService.deleteBook(book);
67 | }
68 |
69 | /**
70 | * Deletes the book with the primary key from the database. Also notifies the appropriate model listeners.
71 | *
72 | * @param isbn the primary key of the book
73 | * @return the book that was removed
74 | * @throws PortalException if a book with the primary key could not be found
75 | */
76 | @Override
77 | public book.model.Book deleteBook(String isbn)
78 | throws com.liferay.portal.kernel.exception.PortalException {
79 |
80 | return _bookLocalService.deleteBook(isbn);
81 | }
82 |
83 | /**
84 | * @throws PortalException
85 | */
86 | @Override
87 | public com.liferay.portal.kernel.model.PersistedModel deletePersistedModel(
88 | com.liferay.portal.kernel.model.PersistedModel persistedModel)
89 | throws com.liferay.portal.kernel.exception.PortalException {
90 |
91 | return _bookLocalService.deletePersistedModel(persistedModel);
92 | }
93 |
94 | @Override
95 | public com.liferay.portal.kernel.dao.orm.DynamicQuery dynamicQuery() {
96 | return _bookLocalService.dynamicQuery();
97 | }
98 |
99 | /**
100 | * Performs a dynamic query on the database and returns the matching rows.
101 | *
102 | * @param dynamicQuery the dynamic query
103 | * @return the matching rows
104 | */
105 | @Override
106 | public java.util.List dynamicQuery(
107 | com.liferay.portal.kernel.dao.orm.DynamicQuery dynamicQuery) {
108 |
109 | return _bookLocalService.dynamicQuery(dynamicQuery);
110 | }
111 |
112 | /**
113 | * Performs a dynamic query on the database and returns a range of the matching rows.
114 | *
115 | *
116 | * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from book.model.impl.BookModelImpl. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
117 | *
118 | *
119 | * @param dynamicQuery the dynamic query
120 | * @param start the lower bound of the range of model instances
121 | * @param end the upper bound of the range of model instances (not inclusive)
122 | * @return the range of matching rows
123 | */
124 | @Override
125 | public java.util.List dynamicQuery(
126 | com.liferay.portal.kernel.dao.orm.DynamicQuery dynamicQuery, int start,
127 | int end) {
128 |
129 | return _bookLocalService.dynamicQuery(dynamicQuery, start, end);
130 | }
131 |
132 | /**
133 | * Performs a dynamic query on the database and returns an ordered range of the matching rows.
134 | *
135 | *
136 | * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from book.model.impl.BookModelImpl. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
137 | *
138 | *
139 | * @param dynamicQuery the dynamic query
140 | * @param start the lower bound of the range of model instances
141 | * @param end the upper bound of the range of model instances (not inclusive)
142 | * @param orderByComparator the comparator to order the results by (optionally null)
143 | * @return the ordered range of matching rows
144 | */
145 | @Override
146 | public java.util.List dynamicQuery(
147 | com.liferay.portal.kernel.dao.orm.DynamicQuery dynamicQuery, int start,
148 | int end,
149 | com.liferay.portal.kernel.util.OrderByComparator orderByComparator) {
150 |
151 | return _bookLocalService.dynamicQuery(
152 | dynamicQuery, start, end, orderByComparator);
153 | }
154 |
155 | /**
156 | * Returns the number of rows matching the dynamic query.
157 | *
158 | * @param dynamicQuery the dynamic query
159 | * @return the number of rows matching the dynamic query
160 | */
161 | @Override
162 | public long dynamicQueryCount(
163 | com.liferay.portal.kernel.dao.orm.DynamicQuery dynamicQuery) {
164 |
165 | return _bookLocalService.dynamicQueryCount(dynamicQuery);
166 | }
167 |
168 | /**
169 | * Returns the number of rows matching the dynamic query.
170 | *
171 | * @param dynamicQuery the dynamic query
172 | * @param projection the projection to apply to the query
173 | * @return the number of rows matching the dynamic query
174 | */
175 | @Override
176 | public long dynamicQueryCount(
177 | com.liferay.portal.kernel.dao.orm.DynamicQuery dynamicQuery,
178 | com.liferay.portal.kernel.dao.orm.Projection projection) {
179 |
180 | return _bookLocalService.dynamicQueryCount(dynamicQuery, projection);
181 | }
182 |
183 | @Override
184 | public book.model.Book fetchBook(String isbn) {
185 | return _bookLocalService.fetchBook(isbn);
186 | }
187 |
188 | /**
189 | * Returns the book with the primary key.
190 | *
191 | * @param isbn the primary key of the book
192 | * @return the book
193 | * @throws PortalException if a book with the primary key could not be found
194 | */
195 | @Override
196 | public book.model.Book getBook(String isbn)
197 | throws com.liferay.portal.kernel.exception.PortalException {
198 |
199 | return _bookLocalService.getBook(isbn);
200 | }
201 |
202 | /**
203 | * Returns a range of all the books.
204 | *
205 | *
206 | * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from book.model.impl.BookModelImpl. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
207 | *
208 | *
209 | * @param start the lower bound of the range of books
210 | * @param end the upper bound of the range of books (not inclusive)
211 | * @return the range of books
212 | */
213 | @Override
214 | public java.util.List getBooks(int start, int end) {
215 | return _bookLocalService.getBooks(start, end);
216 | }
217 |
218 | /**
219 | * Returns the number of books.
220 | *
221 | * @return the number of books
222 | */
223 | @Override
224 | public int getBooksCount() {
225 | return _bookLocalService.getBooksCount();
226 | }
227 |
228 | /**
229 | * Returns the OSGi service identifier.
230 | *
231 | * @return the OSGi service identifier
232 | */
233 | @Override
234 | public String getOSGiServiceIdentifier() {
235 | return _bookLocalService.getOSGiServiceIdentifier();
236 | }
237 |
238 | @Override
239 | public com.liferay.portal.kernel.model.PersistedModel getPersistedModel(
240 | java.io.Serializable primaryKeyObj)
241 | throws com.liferay.portal.kernel.exception.PortalException {
242 |
243 | return _bookLocalService.getPersistedModel(primaryKeyObj);
244 | }
245 |
246 | /**
247 | * Updates the book in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
248 | *
249 | * @param book the book
250 | * @return the book that was updated
251 | */
252 | @Override
253 | public book.model.Book updateBook(book.model.Book book) {
254 | return _bookLocalService.updateBook(book);
255 | }
256 |
257 | @Override
258 | public BookLocalService getWrappedService() {
259 | return _bookLocalService;
260 | }
261 |
262 | @Override
263 | public void setWrappedService(BookLocalService bookLocalService) {
264 | _bookLocalService = bookLocalService;
265 | }
266 |
267 | private BookLocalService _bookLocalService;
268 |
269 | }
--------------------------------------------------------------------------------
/modules/book/book-api/src/main/java/book/service/BookLocalServiceUtil.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or modify it under
5 | * the terms of the GNU Lesser General Public License as published by the Free
6 | * Software Foundation; either version 2.1 of the License, or (at your option)
7 | * any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 | * details.
13 | */
14 |
15 | package book.service;
16 |
17 | import org.osgi.annotation.versioning.ProviderType;
18 | import org.osgi.framework.Bundle;
19 | import org.osgi.framework.FrameworkUtil;
20 | import org.osgi.util.tracker.ServiceTracker;
21 |
22 | /**
23 | * Provides the local service utility for Book. This utility wraps
24 | * book.service.impl.BookLocalServiceImpl and
25 | * is an access point for service operations in application layer code running
26 | * on the local server. Methods of this service will not have security checks
27 | * based on the propagated JAAS credentials because this service can only be
28 | * accessed from within the same VM.
29 | *
30 | * @author Brian Wing Shun Chan
31 | * @see BookLocalService
32 | * @generated
33 | */
34 | @ProviderType
35 | public class BookLocalServiceUtil {
36 |
37 | /*
38 | * NOTE FOR DEVELOPERS:
39 | *
40 | * Never modify this class directly. Add custom service methods to book.service.impl.BookLocalServiceImpl and rerun ServiceBuilder to regenerate this class.
41 | */
42 |
43 | /**
44 | * Adds the book to the database. Also notifies the appropriate model listeners.
45 | *
46 | * @param book the book
47 | * @return the book that was added
48 | */
49 | public static book.model.Book addBook(book.model.Book book) {
50 | return getService().addBook(book);
51 | }
52 |
53 | /**
54 | * Creates a new book with the primary key. Does not add the book to the database.
55 | *
56 | * @param isbn the primary key for the new book
57 | * @return the new book
58 | */
59 | public static book.model.Book createBook(String isbn) {
60 | return getService().createBook(isbn);
61 | }
62 |
63 | /**
64 | * Deletes the book from the database. Also notifies the appropriate model listeners.
65 | *
66 | * @param book the book
67 | * @return the book that was removed
68 | */
69 | public static book.model.Book deleteBook(book.model.Book book) {
70 | return getService().deleteBook(book);
71 | }
72 |
73 | /**
74 | * Deletes the book with the primary key from the database. Also notifies the appropriate model listeners.
75 | *
76 | * @param isbn the primary key of the book
77 | * @return the book that was removed
78 | * @throws PortalException if a book with the primary key could not be found
79 | */
80 | public static book.model.Book deleteBook(String isbn)
81 | throws com.liferay.portal.kernel.exception.PortalException {
82 |
83 | return getService().deleteBook(isbn);
84 | }
85 |
86 | /**
87 | * @throws PortalException
88 | */
89 | public static com.liferay.portal.kernel.model.PersistedModel
90 | deletePersistedModel(
91 | com.liferay.portal.kernel.model.PersistedModel persistedModel)
92 | throws com.liferay.portal.kernel.exception.PortalException {
93 |
94 | return getService().deletePersistedModel(persistedModel);
95 | }
96 |
97 | public static com.liferay.portal.kernel.dao.orm.DynamicQuery
98 | dynamicQuery() {
99 |
100 | return getService().dynamicQuery();
101 | }
102 |
103 | /**
104 | * Performs a dynamic query on the database and returns the matching rows.
105 | *
106 | * @param dynamicQuery the dynamic query
107 | * @return the matching rows
108 | */
109 | public static java.util.List dynamicQuery(
110 | com.liferay.portal.kernel.dao.orm.DynamicQuery dynamicQuery) {
111 |
112 | return getService().dynamicQuery(dynamicQuery);
113 | }
114 |
115 | /**
116 | * Performs a dynamic query on the database and returns a range of the matching rows.
117 | *
118 | *
119 | * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from book.model.impl.BookModelImpl. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
120 | *
121 | *
122 | * @param dynamicQuery the dynamic query
123 | * @param start the lower bound of the range of model instances
124 | * @param end the upper bound of the range of model instances (not inclusive)
125 | * @return the range of matching rows
126 | */
127 | public static java.util.List dynamicQuery(
128 | com.liferay.portal.kernel.dao.orm.DynamicQuery dynamicQuery, int start,
129 | int end) {
130 |
131 | return getService().dynamicQuery(dynamicQuery, start, end);
132 | }
133 |
134 | /**
135 | * Performs a dynamic query on the database and returns an ordered range of the matching rows.
136 | *
137 | *
138 | * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from book.model.impl.BookModelImpl. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
139 | *
140 | *
141 | * @param dynamicQuery the dynamic query
142 | * @param start the lower bound of the range of model instances
143 | * @param end the upper bound of the range of model instances (not inclusive)
144 | * @param orderByComparator the comparator to order the results by (optionally null)
145 | * @return the ordered range of matching rows
146 | */
147 | public static java.util.List dynamicQuery(
148 | com.liferay.portal.kernel.dao.orm.DynamicQuery dynamicQuery, int start,
149 | int end,
150 | com.liferay.portal.kernel.util.OrderByComparator orderByComparator) {
151 |
152 | return getService().dynamicQuery(
153 | dynamicQuery, start, end, orderByComparator);
154 | }
155 |
156 | /**
157 | * Returns the number of rows matching the dynamic query.
158 | *
159 | * @param dynamicQuery the dynamic query
160 | * @return the number of rows matching the dynamic query
161 | */
162 | public static long dynamicQueryCount(
163 | com.liferay.portal.kernel.dao.orm.DynamicQuery dynamicQuery) {
164 |
165 | return getService().dynamicQueryCount(dynamicQuery);
166 | }
167 |
168 | /**
169 | * Returns the number of rows matching the dynamic query.
170 | *
171 | * @param dynamicQuery the dynamic query
172 | * @param projection the projection to apply to the query
173 | * @return the number of rows matching the dynamic query
174 | */
175 | public static long dynamicQueryCount(
176 | com.liferay.portal.kernel.dao.orm.DynamicQuery dynamicQuery,
177 | com.liferay.portal.kernel.dao.orm.Projection projection) {
178 |
179 | return getService().dynamicQueryCount(dynamicQuery, projection);
180 | }
181 |
182 | public static book.model.Book fetchBook(String isbn) {
183 | return getService().fetchBook(isbn);
184 | }
185 |
186 | /**
187 | * Returns the book with the primary key.
188 | *
189 | * @param isbn the primary key of the book
190 | * @return the book
191 | * @throws PortalException if a book with the primary key could not be found
192 | */
193 | public static book.model.Book getBook(String isbn)
194 | throws com.liferay.portal.kernel.exception.PortalException {
195 |
196 | return getService().getBook(isbn);
197 | }
198 |
199 | /**
200 | * Returns a range of all the books.
201 | *
202 | *
203 | * Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from book.model.impl.BookModelImpl. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
204 | *
205 | *
206 | * @param start the lower bound of the range of books
207 | * @param end the upper bound of the range of books (not inclusive)
208 | * @return the range of books
209 | */
210 | public static java.util.List getBooks(int start, int end) {
211 | return getService().getBooks(start, end);
212 | }
213 |
214 | /**
215 | * Returns the number of books.
216 | *
217 | * @return the number of books
218 | */
219 | public static int getBooksCount() {
220 | return getService().getBooksCount();
221 | }
222 |
223 | /**
224 | * Returns the OSGi service identifier.
225 | *
226 | * @return the OSGi service identifier
227 | */
228 | public static String getOSGiServiceIdentifier() {
229 | return getService().getOSGiServiceIdentifier();
230 | }
231 |
232 | public static com.liferay.portal.kernel.model.PersistedModel
233 | getPersistedModel(java.io.Serializable primaryKeyObj)
234 | throws com.liferay.portal.kernel.exception.PortalException {
235 |
236 | return getService().getPersistedModel(primaryKeyObj);
237 | }
238 |
239 | /**
240 | * Updates the book in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
241 | *
242 | * @param book the book
243 | * @return the book that was updated
244 | */
245 | public static book.model.Book updateBook(book.model.Book book) {
246 | return getService().updateBook(book);
247 | }
248 |
249 | public static BookLocalService getService() {
250 | return _serviceTracker.getService();
251 | }
252 |
253 | private static ServiceTracker
254 | _serviceTracker;
255 |
256 | static {
257 | Bundle bundle = FrameworkUtil.getBundle(BookLocalService.class);
258 |
259 | ServiceTracker serviceTracker =
260 | new ServiceTracker(
261 | bundle.getBundleContext(), BookLocalService.class, null);
262 |
263 | serviceTracker.open();
264 |
265 | _serviceTracker = serviceTracker;
266 | }
267 |
268 | }
--------------------------------------------------------------------------------
/modules/book/book-service/test/integration/book/service/persistence/test/BookPersistenceTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
3 | *
4 | * This library is free software; you can redistribute it and/or modify it under
5 | * the terms of the GNU Lesser General Public License as published by the Free
6 | * Software Foundation; either version 2.1 of the License, or (at your option)
7 | * any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful, but WITHOUT
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 | * details.
13 | */
14 |
15 | package book.service.persistence.test;
16 |
17 | import book.exception.NoSuchBookException;
18 |
19 | import book.model.Book;
20 |
21 | import book.service.persistence.BookPersistence;
22 | import book.service.persistence.BookUtil;
23 |
24 | import com.liferay.arquillian.extension.junit.bridge.junit.Arquillian;
25 | import com.liferay.portal.kernel.dao.orm.DynamicQuery;
26 | import com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil;
27 | import com.liferay.portal.kernel.dao.orm.ProjectionFactoryUtil;
28 | import com.liferay.portal.kernel.dao.orm.QueryUtil;
29 | import com.liferay.portal.kernel.dao.orm.RestrictionsFactoryUtil;
30 | import com.liferay.portal.kernel.test.rule.AggregateTestRule;
31 | import com.liferay.portal.kernel.test.util.RandomTestUtil;
32 | import com.liferay.portal.kernel.transaction.Propagation;
33 | import com.liferay.portal.kernel.util.OrderByComparator;
34 | import com.liferay.portal.kernel.util.OrderByComparatorFactoryUtil;
35 | import com.liferay.portal.test.rule.LiferayIntegrationTestRule;
36 | import com.liferay.portal.test.rule.PersistenceTestRule;
37 | import com.liferay.portal.test.rule.TransactionalTestRule;
38 |
39 | import java.io.Serializable;
40 |
41 | import java.util.ArrayList;
42 | import java.util.HashSet;
43 | import java.util.Iterator;
44 | import java.util.List;
45 | import java.util.Map;
46 | import java.util.Set;
47 |
48 | import org.junit.After;
49 | import org.junit.Assert;
50 | import org.junit.Before;
51 | import org.junit.ClassRule;
52 | import org.junit.Rule;
53 | import org.junit.Test;
54 | import org.junit.runner.RunWith;
55 |
56 | /**
57 | * @generated
58 | */
59 | @RunWith(Arquillian.class)
60 | public class BookPersistenceTest {
61 |
62 | @ClassRule
63 | @Rule
64 | public static final AggregateTestRule aggregateTestRule =
65 | new AggregateTestRule(
66 | new LiferayIntegrationTestRule(), PersistenceTestRule.INSTANCE,
67 | new TransactionalTestRule(Propagation.REQUIRED, "book.service"));
68 |
69 | @Before
70 | public void setUp() {
71 | _persistence = BookUtil.getPersistence();
72 |
73 | Class> clazz = _persistence.getClass();
74 |
75 | _dynamicQueryClassLoader = clazz.getClassLoader();
76 | }
77 |
78 | @After
79 | public void tearDown() throws Exception {
80 | Iterator iterator = _books.iterator();
81 |
82 | while (iterator.hasNext()) {
83 | _persistence.remove(iterator.next());
84 |
85 | iterator.remove();
86 | }
87 | }
88 |
89 | @Test
90 | public void testCreate() throws Exception {
91 | String pk = RandomTestUtil.randomString();
92 |
93 | Book book = _persistence.create(pk);
94 |
95 | Assert.assertNotNull(book);
96 |
97 | Assert.assertEquals(book.getPrimaryKey(), pk);
98 | }
99 |
100 | @Test
101 | public void testRemove() throws Exception {
102 | Book newBook = addBook();
103 |
104 | _persistence.remove(newBook);
105 |
106 | Book existingBook = _persistence.fetchByPrimaryKey(
107 | newBook.getPrimaryKey());
108 |
109 | Assert.assertNull(existingBook);
110 | }
111 |
112 | @Test
113 | public void testUpdateNew() throws Exception {
114 | addBook();
115 | }
116 |
117 | @Test
118 | public void testUpdateExisting() throws Exception {
119 | String pk = RandomTestUtil.randomString();
120 |
121 | Book newBook = _persistence.create(pk);
122 |
123 | newBook.setUuid(RandomTestUtil.randomString());
124 |
125 | newBook.setTitle(RandomTestUtil.randomString());
126 |
127 | newBook.setAuthor(RandomTestUtil.randomString());
128 |
129 | _books.add(_persistence.update(newBook));
130 |
131 | Book existingBook = _persistence.findByPrimaryKey(
132 | newBook.getPrimaryKey());
133 |
134 | Assert.assertEquals(existingBook.getUuid(), newBook.getUuid());
135 | Assert.assertEquals(existingBook.getIsbn(), newBook.getIsbn());
136 | Assert.assertEquals(existingBook.getTitle(), newBook.getTitle());
137 | Assert.assertEquals(existingBook.getAuthor(), newBook.getAuthor());
138 | }
139 |
140 | @Test
141 | public void testCountByUuid() throws Exception {
142 | _persistence.countByUuid("");
143 |
144 | _persistence.countByUuid("null");
145 |
146 | _persistence.countByUuid((String)null);
147 | }
148 |
149 | @Test
150 | public void testCountByAuthor() throws Exception {
151 | _persistence.countByAuthor("");
152 |
153 | _persistence.countByAuthor("null");
154 |
155 | _persistence.countByAuthor((String)null);
156 | }
157 |
158 | @Test
159 | public void testCountByTitle() throws Exception {
160 | _persistence.countByTitle("");
161 |
162 | _persistence.countByTitle("null");
163 |
164 | _persistence.countByTitle((String)null);
165 | }
166 |
167 | @Test
168 | public void testFindByPrimaryKeyExisting() throws Exception {
169 | Book newBook = addBook();
170 |
171 | Book existingBook = _persistence.findByPrimaryKey(
172 | newBook.getPrimaryKey());
173 |
174 | Assert.assertEquals(existingBook, newBook);
175 | }
176 |
177 | @Test(expected = NoSuchBookException.class)
178 | public void testFindByPrimaryKeyMissing() throws Exception {
179 | String pk = RandomTestUtil.randomString();
180 |
181 | _persistence.findByPrimaryKey(pk);
182 | }
183 |
184 | @Test
185 | public void testFindAll() throws Exception {
186 | _persistence.findAll(
187 | QueryUtil.ALL_POS, QueryUtil.ALL_POS, getOrderByComparator());
188 | }
189 |
190 | protected OrderByComparator getOrderByComparator() {
191 | return OrderByComparatorFactoryUtil.create(
192 | "BOOK_Book", "uuid", true, "isbn", true, "title", true, "author",
193 | true);
194 | }
195 |
196 | @Test
197 | public void testFetchByPrimaryKeyExisting() throws Exception {
198 | Book newBook = addBook();
199 |
200 | Book existingBook = _persistence.fetchByPrimaryKey(
201 | newBook.getPrimaryKey());
202 |
203 | Assert.assertEquals(existingBook, newBook);
204 | }
205 |
206 | @Test
207 | public void testFetchByPrimaryKeyMissing() throws Exception {
208 | String pk = RandomTestUtil.randomString();
209 |
210 | Book missingBook = _persistence.fetchByPrimaryKey(pk);
211 |
212 | Assert.assertNull(missingBook);
213 | }
214 |
215 | @Test
216 | public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereAllPrimaryKeysExist()
217 | throws Exception {
218 |
219 | Book newBook1 = addBook();
220 | Book newBook2 = addBook();
221 |
222 | Set primaryKeys = new HashSet();
223 |
224 | primaryKeys.add(newBook1.getPrimaryKey());
225 | primaryKeys.add(newBook2.getPrimaryKey());
226 |
227 | Map books = _persistence.fetchByPrimaryKeys(
228 | primaryKeys);
229 |
230 | Assert.assertEquals(2, books.size());
231 | Assert.assertEquals(newBook1, books.get(newBook1.getPrimaryKey()));
232 | Assert.assertEquals(newBook2, books.get(newBook2.getPrimaryKey()));
233 | }
234 |
235 | @Test
236 | public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereNoPrimaryKeysExist()
237 | throws Exception {
238 |
239 | String pk1 = RandomTestUtil.randomString();
240 |
241 | String pk2 = RandomTestUtil.randomString();
242 |
243 | Set primaryKeys = new HashSet();
244 |
245 | primaryKeys.add(pk1);
246 | primaryKeys.add(pk2);
247 |
248 | Map books = _persistence.fetchByPrimaryKeys(
249 | primaryKeys);
250 |
251 | Assert.assertTrue(books.isEmpty());
252 | }
253 |
254 | @Test
255 | public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereSomePrimaryKeysExist()
256 | throws Exception {
257 |
258 | Book newBook = addBook();
259 |
260 | String pk = RandomTestUtil.randomString();
261 |
262 | Set primaryKeys = new HashSet();
263 |
264 | primaryKeys.add(newBook.getPrimaryKey());
265 | primaryKeys.add(pk);
266 |
267 | Map books = _persistence.fetchByPrimaryKeys(
268 | primaryKeys);
269 |
270 | Assert.assertEquals(1, books.size());
271 | Assert.assertEquals(newBook, books.get(newBook.getPrimaryKey()));
272 | }
273 |
274 | @Test
275 | public void testFetchByPrimaryKeysWithNoPrimaryKeys() throws Exception {
276 | Set primaryKeys = new HashSet();
277 |
278 | Map books = _persistence.fetchByPrimaryKeys(
279 | primaryKeys);
280 |
281 | Assert.assertTrue(books.isEmpty());
282 | }
283 |
284 | @Test
285 | public void testFetchByPrimaryKeysWithOnePrimaryKey() throws Exception {
286 | Book newBook = addBook();
287 |
288 | Set primaryKeys = new HashSet();
289 |
290 | primaryKeys.add(newBook.getPrimaryKey());
291 |
292 | Map books = _persistence.fetchByPrimaryKeys(
293 | primaryKeys);
294 |
295 | Assert.assertEquals(1, books.size());
296 | Assert.assertEquals(newBook, books.get(newBook.getPrimaryKey()));
297 | }
298 |
299 | @Test
300 | public void testDynamicQueryByPrimaryKeyExisting() throws Exception {
301 | Book newBook = addBook();
302 |
303 | DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(
304 | Book.class, _dynamicQueryClassLoader);
305 |
306 | dynamicQuery.add(RestrictionsFactoryUtil.eq("isbn", newBook.getIsbn()));
307 |
308 | List result = _persistence.findWithDynamicQuery(dynamicQuery);
309 |
310 | Assert.assertEquals(1, result.size());
311 |
312 | Book existingBook = result.get(0);
313 |
314 | Assert.assertEquals(existingBook, newBook);
315 | }
316 |
317 | @Test
318 | public void testDynamicQueryByPrimaryKeyMissing() throws Exception {
319 | DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(
320 | Book.class, _dynamicQueryClassLoader);
321 |
322 | dynamicQuery.add(
323 | RestrictionsFactoryUtil.eq("isbn", RandomTestUtil.randomString()));
324 |
325 | List result = _persistence.findWithDynamicQuery(dynamicQuery);
326 |
327 | Assert.assertEquals(0, result.size());
328 | }
329 |
330 | @Test
331 | public void testDynamicQueryByProjectionExisting() throws Exception {
332 | Book newBook = addBook();
333 |
334 | DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(
335 | Book.class, _dynamicQueryClassLoader);
336 |
337 | dynamicQuery.setProjection(ProjectionFactoryUtil.property("isbn"));
338 |
339 | Object newIsbn = newBook.getIsbn();
340 |
341 | dynamicQuery.add(
342 | RestrictionsFactoryUtil.in("isbn", new Object[] {newIsbn}));
343 |
344 | List