Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Nilesh Gundecha
delete default Document Types
March 17, 2012 1:06 AM
Answer

Nilesh Gundecha

Rank: Regular Member

Posts: 196

Join Date: November 30, 2009

Recent Posts

Dear All,

I am using Liferay 6.1. In Documents and Media portlet, there are some default Document Types like Online Marketing, Sales Presentation, etc. I do not want these default Document Types to be there.

I can login with Admin and delete these Document Types. But I do not want to this every time I do fresh installation.

Is there any way I can configure this once and all?

Regards,
Nilesh
Hitoshi Ozawa
RE: delete default Document Types
March 17, 2012 1:43 AM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

Unfortunately no. There was request on having a property to turn off these links but for now, you'll have to modify the source code.

Try commenting out in the following:
/portal-impl/src/com/liferay/portal/events/AddDefaultDocumentLibraryStructuresAction.java
Nilesh Gundecha
RE: delete default Document Types
March 17, 2012 1:52 AM
Answer

Nilesh Gundecha

Rank: Regular Member

Posts: 196

Join Date: November 30, 2009

Recent Posts

Thanks for the reply Hitoshi.

I created EXT plugin and did comment some code in the AddDefaultDocumentLibraryStructuresAction.java.

But I am not able to figure out when this code is executed? Any idea?

Its not executed when I add "Documents and Media" portlet on to a page of new Site.

Regards,
Nilesh
Hitoshi Ozawa
RE: delete default Document Types
March 17, 2012 2:19 AM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

Types can be erased by deleting rows #240 through #248 in /ROOT/html/portlet/document_library/view_folders.jsp

<li class="folder file-entry-type ....
Nilesh Gundecha
RE: delete default Document Types
March 17, 2012 2:55 AM
Answer

Nilesh Gundecha

Rank: Regular Member

Posts: 196

Join Date: November 30, 2009

Recent Posts

Thanks Hitoshi.

I am not very convinced to go with hook above jsp. There will be some more jsps to be hooked. Plus, this will make me lose the feature of custom document Types.

Here I am seeing one more strange problem, that when I login as Admin and delete the default Document Types, it gets deleted. But when I restart my Tomcat, all the Document Types are back.

Do I need to open ticket in JIRA for this?

Regards,
Nilesh
Hitoshi Ozawa
RE: delete default Document Types
March 17, 2012 4:45 AM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

Right, deleting the rows will delete all the others items that should show.
I thought you just wanted to know which jsp and where these rows where being outputted.

But when I restart my Tomcat, all the Document Types are back.


I think that's the specs.

The values are being entered into the database table DDMSTRUCTURE so unless you reinstall from the modified version, it's getting the values from the database.
Juan Fernández
RE: delete default Document Types
June 3, 2012 12:39 AM
Answer

Juan Fernández

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1262

Join Date: October 2, 2008

Recent Posts

Hi Hitoshi and Nilesh:
I have just seen this conversation, and somethings are wrong here: I'll write this for future visitors of the thread.

ctually the default document types are created in the class AddDefaultDDMStructuresAction, which is called from the class AddDefaultDataAction, which is a startup action.
This means that it will be launched everytime you restart your server.
In case you want to turn off this creation process, you'll need to comment the following lines in AddDefaultDataAction

1
2SimpleAction addDefaultDDMStructuresAction = new AddDefaultDDMStructuresAction();
3addDefaultDDMStructuresAction.run(ids);


OR

you can add a custom AddDefaultDataAction in the application.startup.events overriding the default one

And you can do this using an Ext Plugin
Thanks, guys
Juan Fernández
Hitoshi Ozawa
RE: delete default Document Types
June 3, 2012 3:02 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

Juan, thank you for you comment. It seems Nilesh doesn't want to completely disable all the default document types, but select the ones he wants to be displayed.

I'll write this to future readers who may be reading this thread. I've answered for Nilesh's particular use case, but to provide a general answer to future readers, much more consideration should be given. Modifying display characterics using ext plugin is not a preferred way unless it is absolutely certain the modification is OK for all portal instances now and in the future. Change the java code so it'll look up settings for a liferay instance in the liferay database table.
Sreeraj AV
RE: delete default Document Types
June 9, 2012 3:14 AM
Answer

Sreeraj AV

Rank: Regular Member

Posts: 236

Join Date: April 26, 2010

Recent Posts

can you please tell me how we can fix this issue using hooks???


Juan Fernández:
Hi Hitoshi and Nilesh:
I have just seen this conversation, and somethings are wrong here: I'll write this for future visitors of the thread.

ctually the default document types are created in the class AddDefaultDDMStructuresAction, which is called from the class AddDefaultDataAction, which is a startup action.
This means that it will be launched everytime you restart your server.
In case you want to turn off this creation process, you'll need to comment the following lines in AddDefaultDataAction

1
2SimpleAction addDefaultDDMStructuresAction = new AddDefaultDDMStructuresAction();
3addDefaultDDMStructuresAction.run(ids);


OR

you can add a custom AddDefaultDataAction in the application.startup.events overriding the default one

And you can do this using an Ext Plugin
Thanks, guys
Juan Fernández
Andrius Kurtinaitis
RE: delete default Document Types
August 6, 2012 4:25 AM
Answer

Andrius Kurtinaitis

Rank: Junior Member

Posts: 62

Join Date: January 24, 2010

Recent Posts

I just added to portal-ext.properties the following line:
1application.startup.events=com.liferay.portal.events.ChannelHubAppStartupAction

And those pesky structures are gone :-)
Also gone are all the default layoutsets, but who really needs them?
Olaf Kock
RE: delete default Document Types
May 24, 2013 8:42 AM
Answer

Olaf Kock

LIFERAY STAFF

Rank: Liferay Legend

Posts: 3459

Join Date: September 23, 2008

Recent Posts

From stackoverflow

If you look at the default configuration, found in portal.properties, there it says

1#
2# Application startup event that runs once for every web site instance of
3# the portal that initializes.
4#
5application.startup.events=com.liferay.portal.events.AddDefaultDataAction,\
6     com.liferay.portal.events.AppStartupAction,\
7     com.liferay.portal.events.ChannelHubAppStartupAction


So you can remove the default com.liferay.portal.events.AddDefaultDataAction from this list by just stating the others in your portal-ext.properties:

1application.startup.events=com.liferay.portal.events.AppStartupAction,\
2     com.liferay.portal.events.ChannelHubAppStartupAction


If you want to do this for all new installations, you'll have to add this change before the first start of the instance. Or you should write an ext plugin that does this out-of-the-box. Why do you need an ext? A hook can only add another StartupAction, not change the existing ones. An ext can change or remove existing startup actions or override their code.

In an ext plugin you could also implement

1application.startup.events=com.mariaioannidou.MyCustomAddDefaultDataAction,\
2     com.liferay.portal.events.AppStartupAction,\
3     com.liferay.portal.events.ChannelHubAppStartupAction


and implement MyCustomAddDefaultDataAction as doing the same that the default action does, sans creating the document types.

On the other hand, a hook could find all of the standard document types that you don't want, check that they are indeed unused, and then delete them. As you can see, AddDefaultDataAction does quite a bit more than just adding the document types, so you might want the rest of the code in the action to run.

Another alternative is to write an ext plugin that actually changes the implementation of com.liferay.portal.events.AddDefaultDataAction, but there you are again with an ext - if you don't deploy this in every installation before your first startup, you'll end up with the default content anyway and you might want to have some code to delete it automatically.

My personal recommendation would be with a hook, deleting the unneeded document types (if they're unused) - the reasons are:

  • Ease of deployment (hot-deployment possible),
  • if you don't deploy your plugin before the first run, you end up needing to delete the unwanted document types anyway,
  • maintainability: It's easier to maintain a hook than an ext plugin.
srini vasulu
RE: delete default Document Types
June 20, 2016 7:06 AM
Answer

srini vasulu

Rank: Junior Member

Posts: 34

Join Date: February 21, 2011

Recent Posts

Thanks olaf for your post here.

I would like to know that you are mentioned that we can achieve this using hook
but i would like to know that on hook how we can delete the document types?.
which hook we need to use?