Foros de discusión
7cogs hook wipes out the database if you delete Bruno
Zsolt Balogh, modificado hace 14 años.
7cogs hook wipes out the database if you delete Bruno
Expert Mensajes: 463 Fecha de incorporación: 23/03/09 Mensajes recientes
Why? I've installed liferay, configured everything, but somehow I forgot to undeploy the 7cogs hook. We were working a lot on new organizations, web pages, etc., then I needed to change something in portal-ext.properties. I've restarted the portal, and interesting thing happened:
Long story short, I've checked the 7congs hooks' source code and I've found this:
And this:
Bruno has a good position in the example Liferay world, he can't be removed from the database, or the hook plugin will
So, I really don't know why does Liferay really need to delete almost all of data from the database...
- I could log in with the ldap data (configured in the database)
- I had no rights, but I was administrator before
- I've checked the database, and there were no pages, only some 7cogs and wol.
Long story short, I've checked the 7congs hooks' source code and I've found this:
protected void clearData(long companyId) throws Exception {
// Users
List<user> users = UserLocalServiceUtil.search(
companyId, null, null, null, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
(OrderByComparator)null);
for (User user : users) {
if (user.getScreenName().equals("test")) {
continue;
}
UserLocalServiceUtil.deleteUser(user.getUserId());
}
// Groups
List<group> groups = GroupLocalServiceUtil.search(
companyId, null, null, null, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
for (Group group : groups) {
IGFolderLocalServiceUtil.deleteFolders(group.getGroupId());
JournalArticleLocalServiceUtil.deleteArticles(group.getGroupId());
JournalTemplateLocalServiceUtil.deleteTemplates(group.getGroupId());
JournalStructureLocalServiceUtil.deleteStructures(
group.getGroupId());
if (!PortalUtil.isSystemGroup(group.getName())) {
GroupLocalServiceUtil.deleteGroup(group.getGroupId());
}
else {
LayoutLocalServiceUtil.deleteLayouts(group.getGroupId(), false);
LayoutLocalServiceUtil.deleteLayouts(group.getGroupId(), true);
}
}
// Organizations
deleteOrganizations(
companyId, OrganizationConstants.DEFAULT_PARENT_ORGANIZATION_ID);
// Roles
List<role> roles = RoleLocalServiceUtil.getRoles(companyId);
for (Role role : roles) {
if (!PortalUtil.isSystemRole(role.getName())) {
RoleLocalServiceUtil.deleteRole(role.getRoleId());
}
}
}</role></group></user>
And this:
// If Bruno exists, do not run again
Bruno has a good position in the example Liferay world, he can't be removed from the database, or the hook plugin will
So, I really don't know why does Liferay really need to delete almost all of data from the database...
Jonas Yuan, modificado hace 14 años.
RE: 7cogs hook wipes out the database if you delete Bruno
Liferay Master Mensajes: 993 Fecha de incorporación: 27/04/07 Mensajes recientes
Hi Zsolt,
The 7cogs hook is used for Demo only. If you just want to use Liferay for demo (hooking functions), you may use Liferay default bundle. Otherwise, it would be better to remove sample data.
The following steps would be useful for development - removing sample data.
• Download latest Liferay Portal Standard Edition Bundled with Tomcat 6.0 from the website http://www.liferay.com/web/guest/downloads/portal.
• Unzip downloaded file into $LIFERAY_PORTAL;
• Remove folders: $TOMCAT_AS_DIR/webapps/sevencogs-hook and $TOMCAT_AS_DIR/webapps/sevencogs-theme. The variable $TOMCAT_AS_DIR refers to Tomcat folder under $LIFERAY_HOME.
• Create a database lportal and an account lportal/lportal in MySQL as follows.
• Create a file named portal-ext.properties at $TOMCAT_AS_DIR/webapps/ROOT/WEB-INF/classes; and add following lines at the end of portal-ext.properties:
• Run $TOMCAT_AS_DIR/bin/startup.sh
• Open your browser and type URL http://localhost:8080
• Login as an administrator - Email Address: test@liferay.com and Password: test.
Hope that it helps.
Thanks
Jonas Yuan
Liferay Portal 5.2 Systems Development
Liferay Portal Enterprise Intranets
The 7cogs hook is used for Demo only. If you just want to use Liferay for demo (hooking functions), you may use Liferay default bundle. Otherwise, it would be better to remove sample data.
The following steps would be useful for development - removing sample data.
• Download latest Liferay Portal Standard Edition Bundled with Tomcat 6.0 from the website http://www.liferay.com/web/guest/downloads/portal.
• Unzip downloaded file into $LIFERAY_PORTAL;
• Remove folders: $TOMCAT_AS_DIR/webapps/sevencogs-hook and $TOMCAT_AS_DIR/webapps/sevencogs-theme. The variable $TOMCAT_AS_DIR refers to Tomcat folder under $LIFERAY_HOME.
• Create a database lportal and an account lportal/lportal in MySQL as follows.
drop database if exists lportal;
create database lportal character set utf8;
grant all on lportal.* to 'lportal'@'localhost' identified by 'lportal' with grant option;
grant all on lportal.* to 'lportal'@'localhost.localdomain' identified by 'lportal' with grant option;
• Create a file named portal-ext.properties at $TOMCAT_AS_DIR/webapps/ROOT/WEB-INF/classes; and add following lines at the end of portal-ext.properties:
## MySQL
jdbc.default.driverClassName=com.mysql.jdbc.Driver
jdbc.default.url=jdbc:mysql://localhost:3306/lportal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
jdbc.default.username=lportal
jdbc.default.password=lportal
• Run $TOMCAT_AS_DIR/bin/startup.sh
• Open your browser and type URL http://localhost:8080
• Login as an administrator - Email Address: test@liferay.com and Password: test.
Hope that it helps.
Thanks
Jonas Yuan
Liferay Portal 5.2 Systems Development
Liferay Portal Enterprise Intranets
Zsolt Balogh, modificado hace 14 años.
RE: 7cogs hook wipes out the database if you delete Bruno
Expert Mensajes: 463 Fecha de incorporación: 23/03/09 Mensajes recientes
Thanks Jonas, I did this when I've installed liferay, just I forgot the 7cogs hook somehow in the deploy directory.
What I really don't understand why does the hook plugin removes all of your organizations, why not just install the demo data?
I know that in this case it was my mistake, but this could be dangerous (e.g. you build the 7cogs from sdk and the ant deploys it...)
What I really don't understand why does the hook plugin removes all of your organizations, why not just install the demo data?
I know that in this case it was my mistake, but this could be dangerous (e.g. you build the 7cogs from sdk and the ant deploys it...)
Jonas Yuan, modificado hace 14 años.
RE: 7cogs hook wipes out the database if you delete Bruno
Liferay Master Mensajes: 993 Fecha de incorporación: 27/04/07 Mensajes recientes
Hi Zsolt,
Yes, you are right, the 7cogs hook is dangerous if you have your own data already.
The following is sample code for hooks (clear Data - users, groups, etc.):
This is the reason that 7cogs hook was removed in EE bundle.
Hope that it helps.
Jonas Yuan
Liferay Portal 5.2 Systems Development
Liferay Portal Enterprise Intranets
Yes, you are right, the 7cogs hook is dangerous if you have your own data already.
The following is sample code for hooks (clear Data - users, groups, etc.):
protected void doRun(long companyId) throws Exception {
if (isAlreadyRan(companyId)) {
return;
}
long defaultUserId = UserLocalServiceUtil.getDefaultUserId(companyId);
clearData(companyId);
setupCommunities(companyId, defaultUserId);
setupOrganizations(companyId, defaultUserId);
setupRoles(companyId, defaultUserId);
setupUsers(companyId);
}
protected void clearData(long companyId) throws Exception {
// Users
List<user> users = UserLocalServiceUtil.search(
companyId, null, null, null, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
(OrderByComparator)null);
for (User user : users) {
if (user.getScreenName().equals("test")) {
continue;
}
UserLocalServiceUtil.deleteUser(user.getUserId());
}
......
</user>
This is the reason that 7cogs hook was removed in EE bundle.
Hope that it helps.
Jonas Yuan
Liferay Portal 5.2 Systems Development
Liferay Portal Enterprise Intranets
Zsolt Balogh, modificado hace 14 años.
RE: 7cogs hook wipes out the database if you delete Bruno
Expert Mensajes: 463 Fecha de incorporación: 23/03/09 Mensajes recientes
I was thinking, what's the data fragment on the database which tells you, that it's untouched, clear liferay install. I can't tell any options, I can understand why Bruno is checked. I wish we had a Bruno colleague, I woudn't work on this right now
I think that the deletion should be removed from the code.
I think that the deletion should be removed from the code.
Jonas Yuan, modificado hace 14 años.
RE: 7cogs hook wipes out the database if you delete Bruno
Liferay Master Mensajes: 993 Fecha de incorporación: 27/04/07 Mensajes recientes
Thanks, Zsolt . The deletion should be removed from the code.
Adding comments for Liferay users:
Don't use 5.2.3 CE bundle for production. For production, use EE bundle instead.
Adding comments for Liferay users:
Don't use 5.2.3 CE bundle for production. For production, use EE bundle instead.
Lisa Simpson, modificado hace 14 años.
RE: 7cogs hook wipes out the database if you delete Bruno
Liferay Legend Mensajes: 2034 Fecha de incorporación: 5/03/09 Mensajes recientes
I think that the 7cogs stuff should be put into the repository and not the bundle. That way, if I want sample stuff its there and I can install it. If I don't want it, its not on my machine and so it's never an issue.