sergiogonzalez/liferay-portal — pull request #1027 by Ithildir (2013-09-17 13:05:30+00:00)
Title: LPS-40265

Hi!

I'm Andrea Di Giorgi of SMC Treviso, Italy. Nice to talk with you :-)

I saw on JIRA that you're the core maintainer of the DM portlet, so I'm sending you my proposed solution for LPS-40265. In a word, it's a problem which involves the validation of Document Type required fields if the current language isn't the default one: even if the user enters a value for them, they're still considered as empty, and a StorageFieldRequiredException exception is thrown.

As you know, this validation code is in the BaseStorageAdapter.validateDDMStructureFields method, which checks if field.getValue() is null or not. This getter uses the default locale previously set in the Field object in order to retrieve the value from the valuesMap. Field objects are created in DDMImpl.createField, which sets the default locale depending on the value of the "defaultLanguageId" serviceContext attribute; if it's null, the default locale is used instead.

In DM portlet, edit_file_entry.jsp and upload_multiple_file_entries.jsp don't have a "defaultLanguageId" input (while there's one in Journal and DDL portlets), because a user can't enter Document Type values in multiple languages. Because of this, Field objects' default locale is always the default one, while their valuesMap contain values only for the current locale, hence the error.

I hope my proposed solution is ok! :blush: But I'm still undecided if it's better to have a hidden input instead...

Thank you!