|
|
|
@ -1,5 +1,7 @@
|
|
|
|
|
package it.tref.liferay.portos.bo.startup; |
|
|
|
|
|
|
|
|
|
import java.util.Date; |
|
|
|
|
|
|
|
|
|
import it.tref.liferay.portos.bo.shared.util.Constants; |
|
|
|
|
|
|
|
|
|
import com.liferay.portal.kernel.events.ActionException; |
|
|
|
@ -26,8 +28,7 @@ import com.liferay.portlet.expando.service.ExpandoTableLocalServiceUtil;
|
|
|
|
|
|
|
|
|
|
public class CompanyExpandoStartupAction extends SimpleAction { |
|
|
|
|
|
|
|
|
|
private static final Log _log = LogFactoryUtil |
|
|
|
|
.getLog(CompanyExpandoStartupAction.class); |
|
|
|
|
private static final Log _log = LogFactoryUtil.getLog(CompanyExpandoStartupAction.class); |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void run(String[] companyIds) throws ActionException { |
|
|
|
@ -40,116 +41,92 @@ public class CompanyExpandoStartupAction extends SimpleAction {
|
|
|
|
|
for (String companyIdStr : companyIds) { |
|
|
|
|
|
|
|
|
|
long companyId = Long.valueOf(companyIdStr); |
|
|
|
|
initExpandoColumnCompany(companyId, defaultActions, |
|
|
|
|
guestActions); |
|
|
|
|
initExpandoColumnCompany(companyId, defaultActions, guestActions); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
_log.error( |
|
|
|
|
"Errore nella procedura automatizzata di configurazione", e); |
|
|
|
|
_log.error("Errore nella procedura automatizzata di configurazione", e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void initExpandoColumnCompany(long companyId, |
|
|
|
|
String[] defaultActions, String[] guestActions) |
|
|
|
|
private void initExpandoColumnCompany(long companyId, String[] defaultActions, String[] guestActions) |
|
|
|
|
throws NumberFormatException, SystemException { |
|
|
|
|
|
|
|
|
|
String className = Company.class.getName(); |
|
|
|
|
|
|
|
|
|
addExpandoColumnIfNotExists(companyId, className, |
|
|
|
|
Constants.COMPANY_CUSTOM_FIELD_VERSIONING_CHANGES, |
|
|
|
|
ExpandoColumnConstants.STRING, |
|
|
|
|
Constants.COMPANY_CUSTOM_FIELD_VERSIONING_CHANGES_URL, |
|
|
|
|
addExpandoColumnIfNotExists(companyId, className, Constants.COMPANY_CUSTOM_FIELD_VERSIONING_CHANGES, |
|
|
|
|
ExpandoColumnConstants.STRING, Constants.COMPANY_CUSTOM_FIELD_VERSIONING_CHANGES_URL, |
|
|
|
|
defaultActions, guestActions); |
|
|
|
|
|
|
|
|
|
addExpandoColumnIfNotExists(companyId, className, |
|
|
|
|
Constants.COMPANY_CUSTOM_FIELD_VERSIONING_SNAPSHOTS, |
|
|
|
|
ExpandoColumnConstants.STRING, |
|
|
|
|
Constants.COMPANY_CUSTOM_FIELD_VERSIONING_SNAPSHOTS_URL, |
|
|
|
|
defaultActions, guestActions); |
|
|
|
|
Constants.COMPANY_CUSTOM_FIELD_VERSIONING_SNAPSHOTS, ExpandoColumnConstants.STRING, |
|
|
|
|
Constants.COMPANY_CUSTOM_FIELD_VERSIONING_SNAPSHOTS_URL, defaultActions, guestActions); |
|
|
|
|
|
|
|
|
|
addExpandoColumnIfNotExists(companyId, className, |
|
|
|
|
Constants.COMPANY_CUSTOM_FIELD_VERSIONING_SNAPSHOTS_COUNT, |
|
|
|
|
ExpandoColumnConstants.STRING, |
|
|
|
|
Constants.COMPANY_CUSTOM_FIELD_VERSIONING_SNAPSHOTS_COUNT_URL, |
|
|
|
|
defaultActions, guestActions); |
|
|
|
|
Constants.COMPANY_CUSTOM_FIELD_VERSIONING_SNAPSHOTS_COUNT, ExpandoColumnConstants.STRING, |
|
|
|
|
Constants.COMPANY_CUSTOM_FIELD_VERSIONING_SNAPSHOTS_COUNT_URL, defaultActions, guestActions); |
|
|
|
|
|
|
|
|
|
addExpandoColumnIfNotExists(companyId, className, |
|
|
|
|
Constants.COMPANY_CUSTOM_FIELD_VERSIONING_COMMIT, |
|
|
|
|
ExpandoColumnConstants.STRING, |
|
|
|
|
Constants.COMPANY_CUSTOM_FIELD_VERSIONING_COMMIT_URL, |
|
|
|
|
addExpandoColumnIfNotExists(companyId, className, Constants.COMPANY_CUSTOM_FIELD_VERSIONING_COMMIT, |
|
|
|
|
ExpandoColumnConstants.STRING, Constants.COMPANY_CUSTOM_FIELD_VERSIONING_COMMIT_URL, |
|
|
|
|
defaultActions, guestActions); |
|
|
|
|
|
|
|
|
|
addExpandoColumnIfNotExists( |
|
|
|
|
companyId, |
|
|
|
|
className, |
|
|
|
|
addExpandoColumnIfNotExists(companyId, className, |
|
|
|
|
Constants.COMPANY_CUSTOM_FIELD_PROTOCOLLO_CODICE_INIZIALE_LABEL, |
|
|
|
|
ExpandoColumnConstants.STRING, |
|
|
|
|
Constants.COMPANY_CUSTOM_FIELD_PROTOCOLLO_CODICE_INIZIALE_VALUE, |
|
|
|
|
defaultActions, guestActions); |
|
|
|
|
Constants.COMPANY_CUSTOM_FIELD_PROTOCOLLO_CODICE_INIZIALE_VALUE, defaultActions, guestActions); |
|
|
|
|
|
|
|
|
|
addExpandoColumnIfNotExists( |
|
|
|
|
companyId, |
|
|
|
|
className, |
|
|
|
|
addExpandoColumnIfNotExists(companyId, className, |
|
|
|
|
Constants.COMPANY_CUSTOM_FIELD_PROTOCOLLO_CODICE_SEGUENTE_LABEL, |
|
|
|
|
ExpandoColumnConstants.STRING, |
|
|
|
|
Constants.COMPANY_CUSTOM_FIELD_PROTOCOLLO_CODICE_SEGUENTE_VALUE, |
|
|
|
|
defaultActions, guestActions); |
|
|
|
|
Constants.COMPANY_CUSTOM_FIELD_PROTOCOLLO_CODICE_SEGUENTE_VALUE, defaultActions, guestActions); |
|
|
|
|
|
|
|
|
|
addExpandoColumnIfNotExists(companyId, className, |
|
|
|
|
Constants.ORG_CUSTOM_FIELD_PO, ExpandoColumnConstants.STRING, |
|
|
|
|
StringPool.BLANK, defaultActions, guestActions); |
|
|
|
|
addExpandoColumnIfNotExists(companyId, className, Constants.ORG_CUSTOM_FIELD_PO, |
|
|
|
|
ExpandoColumnConstants.STRING, StringPool.BLANK, defaultActions, guestActions); |
|
|
|
|
|
|
|
|
|
addExpandoColumnIfNotExists(companyId, className, |
|
|
|
|
Constants.GESTIONE_PRATICA_URL_FE, |
|
|
|
|
ExpandoColumnConstants.STRING, StringPool.BLANK, |
|
|
|
|
defaultActions, guestActions); |
|
|
|
|
addExpandoColumnIfNotExists(companyId, className, Constants.GESTIONE_PRATICA_URL_FE, |
|
|
|
|
ExpandoColumnConstants.STRING, StringPool.BLANK, defaultActions, guestActions); |
|
|
|
|
|
|
|
|
|
addExpandoColumnIfNotExists(companyId, className, |
|
|
|
|
Constants.GESTIONE_PRATICA_URL_BO, |
|
|
|
|
ExpandoColumnConstants.STRING, StringPool.BLANK, |
|
|
|
|
defaultActions, guestActions); |
|
|
|
|
addExpandoColumnIfNotExists(companyId, className, Constants.GESTIONE_PRATICA_URL_BO, |
|
|
|
|
ExpandoColumnConstants.STRING, StringPool.BLANK, defaultActions, guestActions); |
|
|
|
|
|
|
|
|
|
addExpandoColumnIfNotExists(companyId, className, |
|
|
|
|
Constants.CF_ORGANIZATION_MEMBERSHIP, |
|
|
|
|
ExpandoColumnConstants.STRING, StringPool.BLANK, |
|
|
|
|
defaultActions, guestActions); |
|
|
|
|
addExpandoColumnIfNotExists(companyId, className, Constants.CF_ORGANIZATION_MEMBERSHIP, |
|
|
|
|
ExpandoColumnConstants.STRING, StringPool.BLANK, defaultActions, guestActions); |
|
|
|
|
|
|
|
|
|
// Manifattura Web Group, mofidica per rendere la dimensione massima
|
|
|
|
|
// degli allegati configurabile da pannello di controllo. In origine era
|
|
|
|
|
// hardcoded a 20971520 byte.
|
|
|
|
|
addExpandoColumnIfNotExists( |
|
|
|
|
companyId, |
|
|
|
|
className, |
|
|
|
|
addExpandoColumnIfNotExists(companyId, className, |
|
|
|
|
Constants.COMPANY_CUSTOM_FIELD_DIMENSIONE_MASSIMA_ALLEGATI_IN_MIB, |
|
|
|
|
ExpandoColumnConstants.SHORT, |
|
|
|
|
Constants.COMPANY_CUSTOM_FIELD_DIMENSIONE_MASSIMA_ALLEGATI_DEFAULT, |
|
|
|
|
defaultActions, guestActions); |
|
|
|
|
Constants.COMPANY_CUSTOM_FIELD_DIMENSIONE_MASSIMA_ALLEGATI_DEFAULT, defaultActions, |
|
|
|
|
guestActions); |
|
|
|
|
|
|
|
|
|
addExpandoColumnIfNotExists(companyId, className, Constants.COMPANY_CUSTOM_FIELD_LINK_SEED, |
|
|
|
|
ExpandoColumnConstants.STRING, String.valueOf(new Date().getTime()), defaultActions, |
|
|
|
|
guestActions); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private ExpandoColumn addExpandoColumnIfNotExists(long companyId, |
|
|
|
|
String className, String name, int type, String defaultData, |
|
|
|
|
String[] defaultActions, String[] guestActions) |
|
|
|
|
private ExpandoColumn addExpandoColumnIfNotExists(long companyId, String className, String name, |
|
|
|
|
int type, String defaultData, String[] defaultActions, String[] guestActions) |
|
|
|
|
throws SystemException { |
|
|
|
|
|
|
|
|
|
long classNameId = PortalUtil.getClassNameId(className); |
|
|
|
|
|
|
|
|
|
ExpandoTable expandoTable = null; |
|
|
|
|
try { |
|
|
|
|
expandoTable = ExpandoTableLocalServiceUtil.getTable(companyId, |
|
|
|
|
classNameId, ExpandoTableConstants.DEFAULT_TABLE_NAME); |
|
|
|
|
expandoTable = ExpandoTableLocalServiceUtil.getTable(companyId, classNameId, |
|
|
|
|
ExpandoTableConstants.DEFAULT_TABLE_NAME); |
|
|
|
|
} catch (PortalException e) { |
|
|
|
|
try { |
|
|
|
|
expandoTable = ExpandoTableLocalServiceUtil.addTable(companyId, |
|
|
|
|
classNameId, ExpandoTableConstants.DEFAULT_TABLE_NAME); |
|
|
|
|
expandoTable = ExpandoTableLocalServiceUtil.addTable(companyId, classNameId, |
|
|
|
|
ExpandoTableConstants.DEFAULT_TABLE_NAME); |
|
|
|
|
} catch (PortalException e1) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ExpandoColumn expandoColumn = ExpandoColumnLocalServiceUtil.getColumn( |
|
|
|
|
expandoTable.getTableId(), name); |
|
|
|
|
ExpandoColumn expandoColumn = ExpandoColumnLocalServiceUtil |
|
|
|
|
.getColumn(expandoTable.getTableId(), name); |
|
|
|
|
|
|
|
|
|
if (expandoColumn == null) { |
|
|
|
|
|
|
|
|
@ -158,23 +135,20 @@ public class CompanyExpandoStartupAction extends SimpleAction {
|
|
|
|
|
// creazione di campi personalizzati di tipo intero
|
|
|
|
|
switch (type) { |
|
|
|
|
case ExpandoColumnConstants.INTEGER: |
|
|
|
|
expandoColumn = ExpandoColumnLocalServiceUtil.addColumn( |
|
|
|
|
expandoTable.getTableId(), name, type, |
|
|
|
|
Integer.valueOf(defaultData)); |
|
|
|
|
expandoColumn = ExpandoColumnLocalServiceUtil.addColumn(expandoTable.getTableId(), name, |
|
|
|
|
type, Integer.valueOf(defaultData)); |
|
|
|
|
break; |
|
|
|
|
case ExpandoColumnConstants.LONG: |
|
|
|
|
expandoColumn = ExpandoColumnLocalServiceUtil.addColumn( |
|
|
|
|
expandoTable.getTableId(), name, type, |
|
|
|
|
Long.valueOf(defaultData)); |
|
|
|
|
expandoColumn = ExpandoColumnLocalServiceUtil.addColumn(expandoTable.getTableId(), name, |
|
|
|
|
type, Long.valueOf(defaultData)); |
|
|
|
|
break; |
|
|
|
|
case ExpandoColumnConstants.SHORT: |
|
|
|
|
expandoColumn = ExpandoColumnLocalServiceUtil.addColumn( |
|
|
|
|
expandoTable.getTableId(), name, type, |
|
|
|
|
Short.valueOf(defaultData)); |
|
|
|
|
expandoColumn = ExpandoColumnLocalServiceUtil.addColumn(expandoTable.getTableId(), name, |
|
|
|
|
type, Short.valueOf(defaultData)); |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
expandoColumn = ExpandoColumnLocalServiceUtil.addColumn( |
|
|
|
|
expandoTable.getTableId(), name, type, defaultData); |
|
|
|
|
expandoColumn = ExpandoColumnLocalServiceUtil.addColumn(expandoTable.getTableId(), name, |
|
|
|
|
type, defaultData); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} catch (PortalException e) { |
|
|
|
@ -183,28 +157,19 @@ public class CompanyExpandoStartupAction extends SimpleAction {
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
Role roleGuest = RoleLocalServiceUtil.getRole(companyId, |
|
|
|
|
RoleConstants.GUEST); |
|
|
|
|
Role rolePowerUser = RoleLocalServiceUtil.getRole(companyId, |
|
|
|
|
RoleConstants.POWER_USER); |
|
|
|
|
Role roleUser = RoleLocalServiceUtil.getRole(companyId, |
|
|
|
|
RoleConstants.USER); |
|
|
|
|
|
|
|
|
|
ResourcePermissionLocalServiceUtil.setResourcePermissions( |
|
|
|
|
companyId, ExpandoColumn.class.getName(), |
|
|
|
|
ResourceConstants.SCOPE_INDIVIDUAL, |
|
|
|
|
String.valueOf(expandoColumn.getColumnId()), |
|
|
|
|
roleGuest.getRoleId(), guestActions); |
|
|
|
|
ResourcePermissionLocalServiceUtil.setResourcePermissions( |
|
|
|
|
companyId, ExpandoColumn.class.getName(), |
|
|
|
|
ResourceConstants.SCOPE_INDIVIDUAL, |
|
|
|
|
String.valueOf(expandoColumn.getColumnId()), |
|
|
|
|
rolePowerUser.getRoleId(), defaultActions); |
|
|
|
|
ResourcePermissionLocalServiceUtil.setResourcePermissions( |
|
|
|
|
companyId, ExpandoColumn.class.getName(), |
|
|
|
|
ResourceConstants.SCOPE_INDIVIDUAL, |
|
|
|
|
String.valueOf(expandoColumn.getColumnId()), |
|
|
|
|
roleUser.getRoleId(), defaultActions); |
|
|
|
|
Role roleGuest = RoleLocalServiceUtil.getRole(companyId, RoleConstants.GUEST); |
|
|
|
|
Role rolePowerUser = RoleLocalServiceUtil.getRole(companyId, RoleConstants.POWER_USER); |
|
|
|
|
Role roleUser = RoleLocalServiceUtil.getRole(companyId, RoleConstants.USER); |
|
|
|
|
|
|
|
|
|
ResourcePermissionLocalServiceUtil.setResourcePermissions(companyId, |
|
|
|
|
ExpandoColumn.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL, |
|
|
|
|
String.valueOf(expandoColumn.getColumnId()), roleGuest.getRoleId(), guestActions); |
|
|
|
|
ResourcePermissionLocalServiceUtil.setResourcePermissions(companyId, |
|
|
|
|
ExpandoColumn.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL, |
|
|
|
|
String.valueOf(expandoColumn.getColumnId()), rolePowerUser.getRoleId(), defaultActions); |
|
|
|
|
ResourcePermissionLocalServiceUtil.setResourcePermissions(companyId, |
|
|
|
|
ExpandoColumn.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL, |
|
|
|
|
String.valueOf(expandoColumn.getColumnId()), roleUser.getRoleId(), defaultActions); |
|
|
|
|
} catch (PortalException e) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|