Liferay database table work flow? - liferay

I am new to Liferay. Now I need to create the flow chart which has the Liferay table work flow in following scenarios,
1) What are the list of table will reflect/update if we create the site admin?
2) What are the list of table will reflect/update if we create the site?
I tried by opening database tables and noticed that USER_, CONTACT_ will reflect, But I need list of all the related tables which will reflect when we create the site and siteadmin? I am using Liferay 6.2 version.
Thanks in advance.

When you want to know the internals of any system it is always best to check the relevant source-code. So in this case you can check the source-code for those classes which are used for CRUD operations on User and Site.
1) What are the list of table will reflect/update if we create the site admin?
Site-administrator is a Role, which can be applied to a User created in Liferay.
So if you want all the tables that are created from User-creation till User is assigned the Site-administrator role for a particular site, there here are some which I can recollect:
User_ (Obvious)
Contact_ (not so obvious :-) )
Group_ (Users are also created as a record in this table since Users have public and private pages)
Address (if you add an address)
Phone (if you add a Phone)
Users_Roles (Power user role is assigned by default)
UserGroupRole (user and site-role relationship, Site-administrator is a Site-role)
Users_Groups (user and site relationship)
For others you should refer the source-code for UserLocalServiceImpl, RoleLocalServiceImpl and GroupLocalServiceImpl, check the relevant methods prefixed add, update etc.
The corresponding service.xml for these module would reveal the database tables being used.
2) What are the list of table will reflect/update if we create the site?
Sites are nothing but Groups in Liferay. So its obvious Group_ table is playing a big role.
Other tables also depend upon what configuration you are doing while creating a Site.
Then there would be other tables like Layout when you start creating pages for a Site.
I would strongly encourage to go ahead and explore the source code for the classes and you would understand the flow - when and what tables are affected.
Here is some convention which might help you traverse the source-code, almost every *LocalServiceImpl is associated with a *Model like UserLocalServiceImpl with UserModel and almost every *Model has a corresponding database table with the same name.
Also the name of the functionality would in most cases hints at what service classes are being used to connect to database, like adding a User would hint at using UserLocalServiceImpl.
Hope I have understood your question and have been able to give some proper direction.

If you want to know this because you also want to write to these tables: Don't go there! You should purely use the API to change the data that Liferay stores. Otherwise you will run into disasters some time in the future - promised.
For just getting the SQL commands that Liferay actually uses, configure portal-ext.properties and change this default value:
hibernate.show_sql=false
Then go to "Server Administration/Log Levels" and add a new category "org.hibernate.SQL", configure it to the level DEBUG. Then the results show up in the logs. Note that this log configuration is transient and will be reverted on next server start. If you want the setting to be persistent, you'll need to go into Liferay's log4j configuration files.
Remember: You don't want to write to the tables ever. Promise!

Related

Create contact without user

I try to create a contact that is not associated to an user. All "real" users are imported from LDAP. I want to show a global contact list for different purposes like a birthday-list and a phone book. Not all entries in these lists are imported as users. Now I want to create these contacts with the ContactLocalServiceUtil class programmatically. Are there any advices how to do this? There is no method that needs neither a user-id nor a contact-id.
A Contact, as contained in Liferay's API, is always the contact data of a user. Just because the name describes what you need, does not mean that the underlying concept matches as well. You probably need different data for a general purpose phone book anyways and it's probably easier to introduce your own contact class than adjusting the existing model (you can't add fields to API classes anyway - your only way of extending Liferay's ContactModel would be through Expando fields)
Therefor the advice is: Create your own contact class. If you want to react to user data changes when LDAP is updated, you'll need to frequently import the user data and for example create a model listener on Liferay's contact that updates your custom contacts whenever an update from LDAP is coming in.

Can't Reindex All Search Indexes

I've recently deleted 120,000 Users from my Liferay database using an automated script. Before that however, I manually deleted 2 Users from the database using DELETE FROM User_ WHERE userId=1234567 - just to see what might happen with any associations that User might have had.
The User was deleted, but all other table rows holding that userId (1234567) remained. Fine.
So now I'm at a point where I'd like to reindex all search indexes to get a current list of users, but LR throws an exception:
08:07:41,922 ERROR [http-bio-20110-exec-290][LuceneIndexer:136] Error encountere
d while reindexing
com.liferay.portal.kernel.search.SearchException: com.liferay.portal.NoSuchUserE
xception: No User exists with the key {contactId=1234568}
at com.liferay.portal.kernel.search.BaseIndexer.getDocument(BaseIndexer.j
ava:179)
at com.liferay.portlet.usersadmin.util.ContactIndexer$1.performAction(Con
tactIndexer.java:203)
at com.liferay.portal.kernel.dao.orm.BaseActionableDynamicQuery.performActions
InSingleInterval(BaseActionableDynamicQuery.java:309)
at com.liferay.portal.kernel.dao.orm.BaseActionableDynamicQuery.performActi
This contactId seems to be a single digit higher than the userId for any user created (I could be wrong about that)
So my question is, how can I fix this problem so I can perform the reindex?
Liferay EE 6.2
Tomcat 7.0.33
SQL Server
I found out the contactId for my manually deleted user was still in the Contact_ Table. I deleted him from the table and can now perform the reindex. I can now see all the user & user groups after reindexing.
From LR:
rule #1 with using Liferay - The database is not yours, you should
never be in it and you should never be issuing sql against it.
The Liferay API is the only way to modify data. Period.
The Liferay API supports user deletion. Had you used the Liferay API,
the users would have been deleted and your indexes, etc., would have
been fine.
Okay, I know that's going to come across as a little aggressive or
something, but it's important. The whole Liferay system depends upon
it's data, so any time you tweak the data manually it potentially
breaks the system. If you dig through the actual process that the
Liferay API does for a user deletion, you'd see that the "delete from
user_ where ..." is just a small part.
I always tell people new to Liferay to just forget that the database
exists. It's definitely their database, not yours, and it's not to be
messed with.

How to view standard objects in salesforce online?

there are many standard objects e.g. AccountcontactRole, LetterHead, Approval etc. which can be retrieved using Salesforce APIs. What is the way to see these objects in Salesforce environment in browser?
Very roughly speaking - easiest cheat is to simply put the Id in the URL. So if your Salesforce instance is https://na1.salesforce.com then adding /001.... (any valid Account Id) will take you to this account. Similarly /016... will take you to "this" Letterhead record.
Some data is easily accessible to users - for example AccountContactRole should be available as related list under Account. If it isn't - probably the administrator removed it from page layout because the company decided to use only the straightforward Account - Contact relationship.
Some data like Letterheads, EmailTemplates, Approval processes is visible in the setup area (not all users have the "View Setup and Configuration" permission in their Profiles!)
*Share records (like AccountShare) would be visible after you click the Sharing button on the page layout (if it's not visible - again, check with Admin).
If you're using API to fetch the data, you probably can also use "describe" calls to fetch info which objects are available, what fields are present in the tables... Sometimes the "Frontdoor URLs" property is set (although I confess I'm not sure how to get it, http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_Schema_DescribeSObjectResult_instance_methods.htm doesn't mention it).
Also - if you haven't noticed yet - all Accounts start with "001". Try to guess where "/001" and "/001/o" links would lead.

Is it a good idea to filter inside a JSF template?

The first thing that I must say is that I never use a web filter on Java Web Applications so perhaps it could be a stupid idea.
I'm trying to create a method that could check the privilegies of the user and give the access or not to a certains pages if he can or not access to these pages.
For a better explanation I will do an example.
You should imagine a crud web application ok?
This application have these web pages: List.xhtml (that contains all rows and the links to manage these rows); create.xhtml (as the name tell it is used for create a new row); edit.xhtml (used for modify a row); and view.xhtml (used for view the details of a certain row).
Now I have 2 types of user: administrator and guest ok? The privilegies are simple to imagine, the administrator can do all things and guest can only view the details of the rows.
Which is the problem? The problem is that I hide the links for create and modify a row but if a guest modify the url can enter however into create.xhtml and edit.xhtml and create/modify a row...
I read some others question like:
Securing JSF applications and jsf security-contraint to protect link when the user is not signed in?
and I wrote this question:
Are there some issue at inserting some check into template?
and now I'd like to create a generic method to implement the check of privileges. I have the following ideas on how to solve this:
create a filter like the one in the second linked question and insert a check like "if the user has this privilege for that action do ... otherwise redirect to error.xhtml".
insert a check directly into the template, like in the third linked question.
Which of these would be the better approach? How is this typically done?

SharePoint - Adding users from Active Directory in a custom administration form

I have a project where I need to add users to a SharePoint portal, but when I add them, I also need to set addition parameters inside a separate database.
I want to add a custom administration screen where the administration can set these values when they add the user rather than forcing them to first add the user then go to a separate interface page where they set the values.
Does anyone know of any good articles that will explain how to accomplish this?
Thanks.
It would be easier to create a custom asp.net form that would get all the information required about the user.
the submit could then add the information to the database that is needed and use the object model to add the users.
SPRoleAssignment MyRoleAssign = new SPRoleAssignment(”domain/alias”, “email address”, “User Name”, “Description”);
SPRoleDefinition MyRoleDef = newSubWeb.RoleDefinitions["Contribute"];
MyRoleAssign.RoleDefinitionBindings.Add(MyRoleDef);
site.RoleAssignments.Add(MyRoleAssign);
Code from farhanfaiz.wordpress.com here
Otherwise the SharePoint webservices may do.
Examples here

Resources