groups.add(group);
}
final String fname = portletRep.getFname();
IPortletDefinition def = portletDefinitionDao.getPortletDefinitionByFname(fname);
if (def == null) {
def = portletDefinitionDao.createPortletDefinition(
portletType,
fname,
portletRep.getName(),
portletRep.getTitle(),
portletDescriptor.getWebAppName(),
portletDescriptor.getPortletName(),
isFramework != null ? isFramework : false);
}
else {
final IPortletDescriptorKey portletDescriptorKey = def.getPortletDescriptorKey();
portletDescriptorKey.setPortletName(portletDescriptor.getPortletName());
if (isFramework != null && isFramework) {
portletDescriptorKey.setFrameworkPortlet(true);
portletDescriptorKey.setWebAppName(null);
}
else {
portletDescriptorKey.setFrameworkPortlet(false);
portletDescriptorKey.setWebAppName(portletDescriptor.getWebAppName());
}
}
def.setName(portletRep.getName());
def.setTitle(portletRep.getTitle());
def.setDescription(portletRep.getDesc());
final BigInteger timeout = portletRep.getTimeout();
if (timeout != null) {
def.setTimeout(timeout.intValue());
}
final BigInteger actionTimeout = portletRep.getActionTimeout();
if (actionTimeout != null) {
def.setActionTimeout(actionTimeout.intValue());
}
final BigInteger eventTimeout = portletRep.getEventTimeout();
if (eventTimeout != null) {
def.setEventTimeout(eventTimeout.intValue());
}
final BigInteger renderTimeout = portletRep.getRenderTimeout();
if (renderTimeout != null) {
def.setRenderTimeout(renderTimeout.intValue());
}
final BigInteger resourceTimeout = portletRep.getResourceTimeout();
if (resourceTimeout != null) {
def.setResourceTimeout(resourceTimeout.intValue());
}
def.setType(portletType);
Date now = new Date();
IPerson systemUser = PersonFactory.createSystemPerson();
def.setApprovalDate(now);
def.setApproverId(systemUser.getID());
def.setPublishDate(now);
def.setPublisherId(systemUser.getID());
final Set<IPortletDefinitionParameter> parameters = new LinkedHashSet<IPortletDefinitionParameter>();
for (ExternalPortletParameter param : portletRep.getParameters()) {
parameters.add(new PortletDefinitionParameterImpl(param.getName(), param.getValue()));
}
def.setParameters(parameters);
final ArrayList<IPortletPreference> preferenceList = new ArrayList<IPortletPreference>();
for (ExternalPortletPreference pref : portletRep.getPortletPreferences()) {
final List<String> valueList = pref.getValues();
final String[] values = valueList.toArray(new String[valueList.size()]);
final Boolean readOnly = pref.isReadOnly();
preferenceList.add(
new PortletPreferenceImpl(
pref.getName(),
readOnly != null ? readOnly : false,
values));
}
def.setPortletPreferences(preferenceList);
savePortletDefinition(def, PersonFactory.createSystemPerson(), categories, groups);
}