Thursday, 31 December 2015

Liferay

My website has been using Drupal 70 for a while now, ever since I started working with Drupal in my previous job. It seemed like a good idea to get some experience with my first CMS/Webportal/thing by toying with it at home.

I have recently switched over to Liferay1. I was looking for a CMS/Webportal/thingie that is more in tune with the rest of my applications (which are written in Java/Glassfish). I could have chosen Hippo2, but I didn't. Liferay seems to align very good with Vaadin3, which is something I plan on perhaps using in the future.

Installing Liferay on GlassFish 4

Liferay comes with a choice of pre-defined application servers, which is very handy. But I already had a Glassfish server installed, so I wished to use that one, and then things do get a bit more complicated4 5.

What follows are some of the things that I ran up against, and how to do some of the administration that I required.

Global site

Apparently, since version 6, there's a Global6 site that is used for defining resources that are accessible for all other sites. Something I don't need, as I only required a one-site install. But it does show that the product seems defined for many websites of an Enterprisy nature.

Making the site private

Control panel -> Sites -> Configuration -> Site Settings -> Membership Type = Private
There are three settings for the site: open, restricted and private.
Open
Users can become members of the site at any time. Users can join sites from the My Sites portlet.
Restricted
Users can request site membership but site administrators must approve requests in order for users to become members. Requests can be made from the My Sites portlet.
Private
Users are not allowed to join the site or request site membership. Private sites don’t appear in the My Sites portlet. Site administrators can still manually select users and assign them as site members.
See [11] for more information regarding these settings.
It is also possible to define how new users are registered on the site12

Favicon

See for changing the favicon7 the (future) blog on "Liferay Themes".

Apple Icons

I got the following warning in my glassfish logs. Apparently I need to get some apple icons in there:
[2015-09-19T17:58:16.236+0000] [glassfish 4.1] [INFO] [] [] [tid: _ThreadID=29 _ThreadName=Thread-8] [timeMillis: 1442685496236] [levelValue: 800] [[
17:58:16,235 WARN [http-listener-1(5)][code_jsp:114] {code="404", msg="Not Found", uri=/apple-touch-icon.png}]]

[2015-09-19T17:58:16.399+0000] [glassfish 4.1] [INFO] [] [] [tid: _ThreadID=28 _ThreadName=Thread-8] [timeMillis: 1442685496399] [levelValue: 800] [[
17:58:16,398 WARN [http-listener-1(4)][code_jsp:114] {code="404", msg="Not Found", uri=/apple-touch-icon-precomposed.png}]]

Unable to change default Display Icon

When attempting to change the display icon prominently displayed in the left-upper corner of the Liferay website, I ran into a little problem.

Changing it can be done using
Control Panel -> Portal Settings -> Display Settings (Under Miscellaneous)
The error message was:
GRIZZLY0039: Request URI is too large.
java.nio.BufferOverflowException
Apparently, it was necessary to increase the buffer size of the glassfish application server8 9:
Configurations -> cluster-config -> Network Config -> Transports -> tcp -> Buffer Size' to 131072 or more.

Liferay site

You can probably remove the Liferay Inc company site that is available standard in the demo.

Issues with the server.policy file

The server.policy file of Glassfish needs to be adapted for Liferay to work properly10.

I added the following which seemed to do the trick:
grant codeBase "file:${com.sun.aas.instanceRoot}/applications/-" {
permission java.security.AllPermission;
};

grant codeBase "file:${com.sun.aas.instanceRoot}/generated/-" {
permission java.security.AllPermission;
};

What version?

You can see the version of the Liferay instance you are running, by going to:
Control panel -> Configuration -> Server Administration
There you will find
Liferay Portal Community Edition 6.2 CE GA4 (Newton / Build 6203 / April 16, 2015)
Uptime: 3 Days, 14:53:03

References

[0] Drupal
https://www.drupal.org/
[1] Liferay
http://www.liferay.com/
[2] Hippo
http://www.onehippo.com/en
[3] Vaadin
https://vaadin.com/home
[4] Liferay Documentation - Installing Liferay on GlassFish 4
http://www.liferay.com/documentation/liferay-portal/6.2/user-guide/-/ai/installing-liferay-on-glassfish-3-liferay-portal-6-2-user-guide-15-en
[5] Liferay Dev - Installing Liferay on GlassFish 4
https://dev.liferay.com/discover/deployment/-/knowledge_base/6-2/installing-liferay-on-glassfish-4
[6] Liferay Wiki - Global Scope
https://www.liferay.com/community/wiki/-/wiki/Main/Global+Scope
[7] Liferay Wiki - How to change the favorites icon
https://www.liferay.com/community/wiki/-/wiki/Main/How+to+change+the+favorites+icon
[8] Stackoverflow - Glassfish 3.1 maximum uri length
http://stackoverflow.com/questions/5936165/glassfish-3-1-maximum-uri-length
[9] Iliachemodanov Blog - Configuration of long URLs in GlassFish
http://www.iliachemodanov.ru/en/blog-en/13-tools/glassfish/24-long-urls-in-glassfish-en
[10] Liferay Forums - Deployment problem on Liferay6.2 Glassfish4
https://www.liferay.com/community/forums/-/message_boards/view_message/52843459#_19_message_48023536
[11] Leveraging Liferay’s Multi-site Capabilities
https://dev.liferay.com/discover/portal/-/knowledge_base/6-2/leveraging-liferays-multi-site-capabilities
[12] Time for action – disabling the Register option for a guest user
https://www.packtpub.com/packtlib/book/Web-Development/9781849517003/6/ch06lvl1sec91/Time%20for%20action%20%20disabling%20the%20Register%20option%20for%20a%20guest%20user

Thursday, 24 December 2015

Client and Server - Waves of the Past

Pardon me for the esoteric title. Just a small note from me to indicate what kind of movements we have had in the past, when it comes to client and server, or frontend and backend, or browser and server or what have you.








ClientServerTimecomments
-Mainframes1950ssingle-user
-Mainframes1960susers provide punchcards to system admins (batch-processing)
Dum terminalsMainframes1970stime-sharing, server does all the work1
Personal Computers-
1980sPCs in network sharing files/printers and do all the work
Personal ComputersServer
1990sPC is fat client and can do all the work, the start of client-server
Thin clientServer
1993Thin client does a little bit of work, but a lot is done on the server side
Internet BrowserServer1994Server does all the work, pushes HTML pages to client
PDAServer2000Basically the same concept as Thinclient, but discontinued.
Single Page Application in your Internet BrowserServer2005Browser does all the work, but queries servers.
Tablets and Mobile phonesMany Servers2010Basically the same concept as Thinclient, but distributed computing starts.

So, my question is always, what next? Will we see things of the Past come round again, where people come to the conclusion that Fat Clients are awesome?

The answer is probably that there will be cases where either fat or thin clients make sense. Especially in the plethora of new devices available nowadays.

References

[1] Wikipedia - Centralized computing
https://en.wikipedia.org/wiki/Centralized_computing

Thursday, 17 December 2015

Trailing Commas

This post might seem trivial, but I decided to go ahead with it.

I recently found out that the following code compiles.
/**
 * The Seasons.
 * @author mr.bear
 */

public enum Seasons
{
    SPRING, SUMMER, AUTUMN, WINTER,
}
I was a little surprised, that the last comma was not a problem. The same can be seen in the following array initializer:
int[] b = {1, 2, 3, 4, 5, 6,};

Apparently, to my surprise, it's written in the JLS.

According to [1], if you look at the Grammar defined for Enums:
EnumBody:
{ [EnumConstantList] [,] [EnumBodyDeclarations] }
For arrays the same rule applies2.
“A trailing comma may appear after the last expression in an array initializer and is ignored.”
I was a little surprised that it has been part of the spec for a very long time3.

References

[1] JLS 8.0 Section 8.9.1 Enum Constants
https://docs.oracle.com/javase/specs/jls/se8/html/jls-8.html#jls-8.9.1
[2] JLS 8.0 Section 10.6
https://docs.oracle.com/javase/specs/jls/se8/html/jls-10.html#jls-10.6
[3] JSL 1.0
http://titanium.cs.berkeley.edu/doc/java-langspec-1.0/
StackOverflow - Arrays with trailing commas inside an array initializer in java
http://stackoverflow.com/questions/11621917/arrays-with-trailing-commas-inside-an-array-initializer-in-java

Thursday, 10 December 2015

true vs. Boolean.TRUE

I saw the following code below at my work, and it got me thoroughly confused. I found the statement above to be unnecessarily complicated.

private boolean useAsReferenceModel = Boolean.FALSE;

Boolean.FALSE returns a Boolean, which is a wrapper2 around the boolean primitive types.

So, in the example above, the Boolean wrapper is auto-unboxed3 to the primitive type false.

So, I changed the code to the simple and straightforward:
private boolean useAsReferenceModel = false;
Let us not make the world more complicated than it really is.

References

[1] StackOverflow - Java what is the difference between false and Boolean.FALSE
http://stackoverflow.com/questions/20090306/java-what-is-the-difference-between-false-and-boolean-false
[2] Wikipedia - Primitive Wrapper Classes
https://en.wikipedia.org/wiki/Primitive_wrapper_class
[3] Oracle JavaDoc - Autoboxing and unboxing
https://docs.oracle.com/javase/tutorial/java/data/autoboxing.html

Thursday, 3 December 2015

Richardson Maturity Model

The Richardson Maturity Model1 gives a very clear idea of how far you are in following the REST software architectural style.

Unfortunately, I seem, personally, in my home projects, to have serious problems reaching the HATEOAS level (level 3). Is that even a problem2?

Does anyone else have the same issue?

Is the last level actually in common use, except for those frameworks that already have it built in, or not?

References

[1] Martin Fowler - Richardson Maturity Model
http://martinfowler.com/articles/richardsonMaturityModel.html

[2] The timeless repository - Haters gonna HATEOAS
http://timelessrepo.com/haters-gonna-hateoas