Two portlets with same database - liferay

I am developing Liferay portal and I have one portlet which handles the administrator side of the portal and one the client side. The thing is that the clients cannot see the administrator page (including the portlet). Also I have created custom DataBase for the portal (I included my own tables in the Liferay database using Service Builder). Now I want to use the same database so I can take info from it using the client portlet.
Any ideas?
I am using Liferay 6.1 with Tomcat and Liferay SDK plugin for Eclipse.

You can copy the [portlet name]-service.jar from Web-Inf/lib, and paste it to any other portlet's lib folder. Even better if you can do this with maven and add this jar as a dependency. This way you can have access to the Util Classes that your service provides, to any other Portlet

All portlets in a plugin project share the service builder service made by that plugin (because they end up in one war file and thus share runtime context). So you could just put both your portlets in the same plugin and they can both access that plugin's service builder services/tables. I think you will find this is a commonly used approach. The permission and visibility issues you mention are not impacted by this organization.
Doing it this way keeps the deployment simple -- just deploy the plugin's war, done.
If there are reasons beyond your control that require the portlets to be in separate plugins, then it becomes harder -- yannicuLar's approach is one way.

If you have two portlets sharing same tables/entities , you can copy the service.jar to
tomcat-7.0.27\lib\ext a common location where these two portlets can access this .jar at runtime.

Related

Can I extend an Oracle ADF (or any Java EE) war/ear without having access to the source?

There is a packaged application created in Oracle ADF (lets generalise and say any Java EE framework) that I would like to customise/extend. I want to make changes like add a new JSF page or modify a JSF page in there and change the data which appears on the page.
I do not have the source code, just the war/ear file. Can I import this in JDeveloper for ADF (or Eclipse/NetBeans/IntelliJ in case of other EE frameworks) and create new objects extending the jar files in there without having the source code?
You can run your Jdev in customisation Developer role , open your EAR file , go to your JSF , jsff and try to have customisation put on top of it. You will need to deploy this as MAR file. Similar concept also applies to Oracle's Webcenter and it's taskflow customisations. Also , for this feature Seeded customisation should be enabled in your deployment profile.
Read more here : Customization
Also found this - how customisable the ADF app is depends on how the app is written in the first place. Use of MDS enables higher degree of customisability:
https://docs.oracle.com/middleware/1212/adf/ADFFD/customize.htm#ADFFD2085

Liferay create site / page programmatically

I have been using Liferay for work for 2 weeks. I noticed that it's a bit difficult to find good documentation and tutorials.
Until now I created pages from the web portal. After I create them, I drag and drop portlets. I don't really like this approach, I would prefer to use a coding approach. Is there a way to create a website or page programmatically by defining a project as I do to create portlets?
Moreover, I am using Liferay with WebLogic 10.3.6. I want to know where liferay puts pages I created via web-portal on the file system. I suppose that a file, or something similar, is created when I declare a new site on the Liferay web-portal.
Thank you all,
Marco
Yes Liferay has it's Database, all data of any Liferay object is stored in the database and / or on the file system depending on your configuration.
However, one of the functionality of Liferay is to let you create pages / sites through the UI. As documented in the Java Portal Specification and Liferay Server Documents your approach to create pages in an alternative way is possible but it is part of Liferay's Portal Services. You can use Liferay's Service (HTTP REST) API to call the related service. To access those APIs you need to configure your Liferay Server.
In case you want to do programmatically you still need to configure, enable and call those external HTTP services from your code. You should not create Liferay Objects from your own code hosted as an extension inside your Liferay Instance as that will result inconsistency in your Liferay Database / filesystem. (As in case of page creation Liferay creates a set of other related objects in it's database / filesystem.)
In your liferay bundle you will find two plugins of interest.
First is resources-importer-web for which description says
The Resources Importer app allows front-end developers to package web
content, portlet configurations, and layouts together in a theme
without saving it as a compiled .LAR file thereby allowing for greater
flexibility in its usage between Liferay Portal versions.This app will automatically create associated content when other
plugins are deployed that are configured to make use of the Resource
Importer app.This app installs as a Liferay service.
Second is welcome-theme which declares resources to be created by resources-importer-web. This on should be example how to create your own. Take a look at
welcome-theme\WEB-INF\src\resources-importer\*
welcome-theme\WEB-INF\liferay-plugin-package.properties
This feature is described at importing-resources-with-themes
As mentioned by gabor_the_kid, Liferay stores all objects in its tables. For example, User related objects would be in user table. Liferay exposed services or API's to change the default/to add new behaviors by program but not easier than achieving it through UI. Also maintenance should be considered for going program way of creating pages or layouts etc.
You can describe your changes using xml and use the Liferay Portal DB Setup core to create the changes in DB.
The library defines the list of available xml configurations.

newbie --> How to deploy my jsr 168 portlet inside liferay

Three simple questions...
Question 1.
I have a JSR168 portlet that is deployed over IBM Websphere Portal server at my company. I was using a version of IBM Portal server for my development but strictly speaking I don't think I am allowed to use these at my company. So now my plan is to do my development and testing on my local machine using liferay and then deploy to IBM Portal Server.
From what I have read about liferay since it supports jsr168 I should not have any problems. Is this correct?
Question 2.
I've just finished installing the liferay 6.2-5 stack on my mac from the Bitnami site. It is running but I am having troubles understanding how I can deploy my first portlet (which by the way works under IBM Portal Server).
After logging in I go to Admin> Control Panel> Apps> App Manager. I then hit Install and select my war file and then put in a context root. But I keep getting an error message "Please enter a valid url".
What is the problem here?
Question 3.
After the Portlet has been installed how can I see it in liferay?
thanks in advance
for 1: correct, Liferay supports JSR-168
for 2: You can either drop your WAR file in Liferay's "deploy" folder, which will cause Liferay to deploy it from there. If it disappears from that folder within a few seconds, it has been deployed.
The administrative UI allows you to do a similar thing through the Web UI - you can either upload your plugin or point to a URL where Liferay can download it: Don't mix it up with Websphere's admin UI where you give the context name for an uploaded application. In Liferay you'll either have to use the upload OR the URL. The context name is derived from the name of the WAR file.
for 3: You'll find your plugin when you choose the "Add" button - login as Administrator and you'll find a "+" labelled button on the left side of the screen. Choose "Application" and look for your portlet (you can filter the list). If you include some Liferay-specific deployment descriptors (look up WEB-INF/liferay-display.xml) you can also influence which section/headline it appears under.

Liferay or GateIn

Now our team is facing new project - creation of new company's intranet portal. Because of some reasons we are considering java open source portals and deciding between Liferay and GateIn.
One of very important requirements is following: portal representation for users must depend on country/language settings of customer computer, it means not only portlets localization but users in US subsidiaries of the company should see probably other structure than users in France.
Is it possible to implement the requirement in Liferay and GateIn?.
This can definitely be achieved through Liferay. Please have a look at the concepts of creating organisations.
Am not sure if this can be done in GateIn. However, there are many other things that you may need to keep in mind before choosing these Portals. I have tried to mention few of them here.
1. Check the stability of the Portal server that you will choose to run on a particular Container. GateIn initially was unstable.
2. You may have to override few files (for your customization) if required. GateIn uses GTMPL view technology for the same. Check how good are you in this. In this case, Liferay is easier (Liferay doesn't use any GTMPL UI framework)
3. Apart from developing a location based Portal, if you are also trying to achieve other things like fully Ajax based pages, a good UI framework (like JSF) etc then check if the Portal server you are choosing runs on a particular Container which supports Ajax, JSF (latest versions)
Above were few and list may grow. But, to conclude I would suggest to go for Liferay :)
This can be achieved with Gatein at different level :
Sites : you can declare multiple sites running on the same portal instance(sharing same User Base). In this case you can automatically redirect user to different country sites, based on the country/language of the user.
Sites Navigations : Gatein provides portal, group and user navigations. Navigation is created dynamically when a user connects to the portal. You can have only websites, navigation will created dynamically by user (based on group and user permissions).
Pages (Dynamics layout rendering): GateIn renders each page dynamically. A page is composed of multiple containers that contains portlets or gadgets.
By setting permissions on each container and by using User Group or Membership of the connected user, it's possible to have different page layout.
Of course, you can also mixed these 3 approaches to build your portal.
Liferay is very buggy, and community is very bad. Unless you pay the support.
GateIn promises much, but still lacks functionality.
You may consider JBoss Juzu and Apache Struts to develop generic portlets in order to void any portal vendor lock-in.
Struts provides features of internationalization, localization, timezones achieve my project.
I make use of struts2-portlet plugin to achieve a reporting portlet running on multiple portals. Here is my sample: code.google.com/p/jasperrocks/wiki/Features

Setting up a new website with Liferay Portal - basic steps?

I know this is not specifically a programming question, but programmers will often have to do this work.
How do I create a website with Liferay portal - the docs are pretty light on this fundamental issue and are all for version 4.4. I am using version 5.2 and the docs don't seem to be relevant.
Do you know what the basic steps are. So far I have logged in as the bruno user and can see the 7cogs website and edit it. But I now need to create my own website (for my company) and be able to develop portlets to add to the parts of the page.
Further I notice that the docs talk about doing work in Eclipse. If our website is all static HTML, (the reason we want liferay is mainly so that we can edit content items using its content management tools), then will there be any need for Java dev, or will it all be drag n drop and clicking to get setup. Any guidance will be much appreciated.
Liferay can be used as a simple CMS, without much Java knowledge : creating, editing and positioning of web content fragments are drag'n'drop and use of the included rich text editor.
But to start using Liferay for your company, there are two main steps : a technical configuration (database, etc.), and a look'n'feel customization.
The technical part
First of all, you should get rid of the 7cogs website : this is called a hook in the Liferay wording. To do that, if you are using Tomcat for the application server, just delete the 7cogs directory as stated here.
You can now create the configuration file for your installation : it's a simple text properties file, named portal-ext.properties and placed in the webapps/ROOT/WEB-INF/classes folder of your tomcat installation.
This file handles most of the configuration of the Liferay portal, for example :
the name of your company
if you want to display a terms of use page on first login
if you want anybody to be able to create an account on your portal
the database where the data will be stored
To do this, the properties in the portal-ext.properties override default properties found in a embedded portal.properties file located in the jar file portal-impl.jar, in the webapps/ROOT/WEB-INF/lib directory. Just unzip the jar file in a temporary folder to access the portal.properties file.
A sample portal-ext.properties file :
company.default.web.id=yourcompany.com
terms.of.use.required=false
company.security.strangers=false
jdbc.default.driverClassName=com.mysql.jdbc.Driver
jdbc.default.url=jdbc:mysql://localhost/lportal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
jdbc.default.username=root
jdbc.default.password=root
Once done, you can startup your application server. As the default admin (named test, something you can change in the portal-ext.properties file), you can access to the centralized web "control center", located in the "dock" (the strange menu labelled "welcome Test" in the upper right part of any page once logged in).
I would advise you to read the administration guide, useful for most administrative tasks.
The "branding" part
Liferay uses "Themes" to automatically decorate the portal pages (logo, navigation, portlet borders...) using images, CSS, Javascript (JQuery) and the templating language Velocity. The themes are bundled in a .war file, like a standard web application, and deployed on the fly either via the control center or by dropping the file in the deploy directory of the server.
Liferay can use several themes at the same time, one for each community (a group of pages, users and content) for example.
Creating your own theme can be done afterwards, using the "Plugins SDK".
The Wiki, forums and blogs can be very useful.

Resources