Class AdminAbstractController
- Direct Known Subclasses:
AdminAssetUploadController
,AdminBasicEntityController
,AdminBasicOperationsController
,AdminCatalogActionsController
,AdminExportController
,AdminTranslationController
- Author:
- elbertbautista, apazzolini
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AdminNavigationService
protected SecurityVerifier
static final String
static final String
protected AdminSectionCustomCriteriaService
static final String
protected EntityConfiguration
protected EntityFormValidator
protected ExploitProtectionService
protected AdminAbstractControllerExtensionManager
static final String
static final String
protected FormBuilderService
protected static final org.apache.commons.logging.Log
static final String
protected AdminEntityService
protected ClassNameRequestParamValidationService
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Deprecated.protected void
attachSectionSpecificInfo
(PersistencePackageRequest ppr, Map<String, String> pathVars) A hook method that is invoked every time the getSectionPersistencePackageRequest(..) method is invoked.protected SectionCrumb
createSectionCrumb
(String currentSection, String currentSectionId) protected void
protected void
extractDynamicFormFields
(ClassMetadata cmd, EntityForm entityForm) This method will scan the entityForm for all dynamic form fields and pull them out as appropriate.getAddEntityTypes
(ClassTree classTree) If there are certain types of entities that should not be allowed to be created, an override of this method would be able to specify that.protected String
getClassNameForSection
(String sectionKey) Gets the fully qualified ceiling entity classname for this section.protected ListGrid
getCollectionListGrid
(ClassMetadata mainMetadata, Entity entity, Property collectionProperty, org.springframework.util.MultiValueMap<String, String> requestParams, String sectionKey, List<SectionCrumb> sectionCrumbs) Convenience method for obtaining a ListGrid DTO object for a collection.protected ListGrid
getCollectionListGrid
(ClassMetadata mainMetadata, Entity entity, Property collectionProperty, org.springframework.util.MultiValueMap<String, String> requestParams, String sectionKey, PersistenceResponse persistenceResponse, List<SectionCrumb> sectionCrumbs) Convenience method for obtaining a ListGrid DTO object for a collection.protected FilterAndSortCriteria[]
getCriteria
(Map<String, List<String>> requestParams) Helper method to return an array ofFilterAndSortCriteria
based on a map of propertyName -> list of criteria value.protected String
This method is called when attempting to add new entities that have a polymorphic tree.protected EntityForm
getDynamicFieldTemplateForm
(DynamicEntityFormInfo info, String entityId, EntityForm dynamicFormOverride) Convenience method for obtaining a dynamic field template form for a particular entity.protected String
getDynamicForm
(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, Map<String, String> pathVars, DynamicEntityFormInfo info) Returns a partial representing a dynamic form.protected EntityForm
getEntityForm
(String sectionKey, String sectionClassName, String id) Convenience method for obtaining a fully built EntityForm for the given sectionKey, sectionClassName, and id.protected EntityForm
protected EntityForm
getEntityForm
(DynamicEntityFormInfo info, EntityForm dynamicFormOverride) protected Long
getFirstId
(Map<String, List<String>> requestParams) protected Long
protected Integer
getLowerCount
(Map<String, List<String>> requestParams) protected Integer
getMaxIndex
(Map<String, List<String>> requestParams) Obtains the requested max index parameterprotected Integer
getMaxResults
(Map<String, List<String>> requestParams) Obtains the requested max index parameterprotected Integer
getPageSize
(Map<String, List<String>> requestParams) protected PersistencePackageRequest
getPersistencePackageRequest
(org.springframework.util.MultiValueMap<String, String> requestParams, Class<?> ceilingEntityClass) Returns a PersistencePackageRequest for the given sectionClassName.protected List<SectionCrumb>
getSectionCrumbs
(jakarta.servlet.http.HttpServletRequest request, String currentSection, String currentSectionId) protected String[]
This method is invoked for every request for this controller.protected String
getSectionKey
(Map<String, String> pathVars) This method is used to determine the current section key.protected PersistencePackageRequest
getSectionPersistencePackageRequest
(String sectionClassName, List<SectionCrumb> sectionCrumbs) Deprecated.protected PersistencePackageRequest
getSectionPersistencePackageRequest
(String sectionClassName, List<SectionCrumb> sectionCrumbs, Map<String, String> pathVars) Returns a PersistencePackageRequest for the given sectionClassName.protected PersistencePackageRequest
getSectionPersistencePackageRequest
(String sectionClassName, org.springframework.util.MultiValueMap<String, String> requestParams, List<SectionCrumb> sectionCrumbs) Deprecated.protected PersistencePackageRequest
getSectionPersistencePackageRequest
(String sectionClassName, org.springframework.util.MultiValueMap<String, String> requestParams, List<SectionCrumb> sectionCrumbs, Map<String, String> pathVars) Returns the result of a call to getSectionPersistencePackageRequest(..) with the additional filter and sort criteria attached.getSortDirections
(Map<String, List<String>> requestParams) Obtains the list of sort directions from the bound request parameters.getSortPropertyNames
(Map<String, List<String>> requestParams) Obtains the list of property names to sort on from the bound request parameters.protected Integer
getStartIndex
(Map<String, List<String>> requestParams) Obtains the requested start index parameterprotected Integer
getUpperCount
(Map<String, List<String>> requestParams) protected void
modifyAddEntityForm
(EntityForm entityForm, Map<String, String> pathVars) This method is invoked whenever an assembled EntityForm is rendered for the add entity screen.protected void
modifyCriteria
(Map<String, FilterAndSortCriteria> fasMap) protected void
modifyEntityForm
(EntityForm entityForm, Map<String, String> pathVars) This method is invoked whenever an assembled EntityForm is rendered.protected JsonResponse
populateJsonValidationErrors
(EntityForm form, org.springframework.validation.BindingResult result, JsonResponse json) Populates the given json response object based on the given form and resultprotected void
setModelAttributes
(org.springframework.ui.Model model, String sectionKey) Attributes to add to the model on every requestprotected void
setSpecializedNameForFields
(DynamicEntityFormInfo info, EntityForm dynamicForm) protected String
translateErrorMessage
(org.springframework.validation.ObjectError error) Methods inherited from class org.broadleafcommerce.common.web.controller.BroadleafAbstractController
addDeepLink, getContextPath, isAjaxRequest, jsonResponse
-
Field Details
-
FILTER_VALUE_SEPARATOR
- See Also:
-
FILTER_VALUE_SEPARATOR_REGEX
- See Also:
-
CURRENT_ADMIN_MODULE_ATTRIBUTE_NAME
- See Also:
-
CURRENT_ADMIN_SECTION_ATTRIBUTE_NAME
- See Also:
-
DEFAULT_CONTAINER_VIEW
- See Also:
-
MODAL_CONTAINER_VIEW
- See Also:
-
LOG
protected static final org.apache.commons.logging.Log LOG -
service
-
formService
-
entityConfiguration
-
entityFormValidator
-
adminRemoteSecurityService
-
customCriteriaService
-
extensionManager
-
validationService
-
filterProductTypeExtensionManager
-
eps
-
-
Constructor Details
-
AdminAbstractController
public AdminAbstractController()
-
-
Method Details
-
getEntityForm
protected EntityForm getEntityForm(String sectionKey, String sectionClassName, String id) throws ServiceException Convenience method for obtaining a fully built EntityForm for the given sectionKey, sectionClassName, and id.- Parameters:
sectionKey
-sectionClassName
-id
-- Returns:
- a fully composed EntityForm
- Throws:
ServiceException
-
getDynamicForm
protected String getDynamicForm(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, Map<String, String> pathVars, DynamicEntityFormInfo info) throws ExceptionReturns a partial representing a dynamic form. An example of this is the dynamic fields that render on structured content, which are determined by the currently selected structured content type. This method is typically only invoked through Javascript and used to replace the current dynamic form with the one for the newly selected type.- Parameters:
request
-response
-model
-pathVars
-info
-- Returns:
- the return view path
- Throws:
Exception
-
getCollectionListGrid
protected ListGrid getCollectionListGrid(ClassMetadata mainMetadata, Entity entity, Property collectionProperty, org.springframework.util.MultiValueMap<String, String> requestParams, String sectionKey, PersistenceResponse persistenceResponse, List<SectionCrumb> sectionCrumbs) throws ServiceExceptionConvenience method for obtaining a ListGrid DTO object for a collection. Note that if no criteria is available, then this should be null (or empty)- Parameters:
mainMetadata
- class metadata for the root entity that this collectionProperty relates toentity
-collectionProperty
- property that this collection should be based on from the root entityrequestParams
-sectionKey
- the current main section keypersistenceResponse
-sectionCrumbs
-- Returns:
- the list grid
- Throws:
ServiceException
-
getCollectionListGrid
protected ListGrid getCollectionListGrid(ClassMetadata mainMetadata, Entity entity, Property collectionProperty, org.springframework.util.MultiValueMap<String, String> requestParams, String sectionKey, List<SectionCrumb> sectionCrumbs) throws ServiceExceptionConvenience method for obtaining a ListGrid DTO object for a collection. Note that if no criteria is available, then this should be null (or empty)- Parameters:
mainMetadata
- class metadata for the root entity that this collectionProperty relates toentity
-collectionProperty
- property that this collection should be based on from the root entityrequestParams
-sectionKey
- the current main section keysectionCrumbs
-- Returns:
- the list grid
- Throws:
ServiceException
-
getEntityForm
- Throws:
ServiceException
-
getEntityForm
protected EntityForm getEntityForm(DynamicEntityFormInfo info, EntityForm dynamicFormOverride) throws ServiceException - Throws:
ServiceException
-
getDynamicFieldTemplateForm
protected EntityForm getDynamicFieldTemplateForm(DynamicEntityFormInfo info, String entityId, EntityForm dynamicFormOverride) throws ServiceException Convenience method for obtaining a dynamic field template form for a particular entity. This method differs from#getBlankDynamicFieldTemplateForm(DynamicEntityFormInfo)
in that it will fill out the current values for the fields in this dynamic form from the database. This method is invoked when the initial view of a page containing a dynamic form is triggered.Optionally, you can pass in a pre-existing dynamic form to this method that already has updated values. Example usage would be for after validation has failed and you do not want to lookup old values from the database again.
- Parameters:
info
-entityId
-dynamicFormOverride
- optional dynamic form that already has values to fill out- Returns:
- the entity form
- Throws:
ServiceException
-
setSpecializedNameForFields
-
extractDynamicFormFields
This method will scan the entityForm for all dynamic form fields and pull them out as appropriate.- Parameters:
cmd
-entityForm
-
-
getSectionKey
This method is used to determine the current section key. For this default implementation, the sectionKey is pulled from the pathVariable, {sectionKey}, as defined by the request mapping on this controller. To support controller inheritance and allow more specialized controllers to delegate some methods to this basic controller, overridden implementations of this method could return a hardcoded value instead of reading the map- Parameters:
pathVars
- - the map of all currently bound path variables for this request- Returns:
- the sectionKey for this request
-
getCriteria
Helper method to return an array of
FilterAndSortCriteria
based on a map of propertyName -> list of criteria value. This will also grab the sorts off of the request parameters, if any.The multi-valued map allows users to specify multiple criteria values per property, as well as multiple sort properties and sort directions. For multiple sort properties and sort directions, these would usually come in as request parameters like:
....?sortProperty=defaultSku.name&sortProperty=manufacturer&sortDirection=ASCENDING&sortDirection=DESCENDING
This would attach criteria such that defaultSku.name was sorted ascending, and manufacturer was sorted descending- Parameters:
requestParams
- usually aMultiValueMap
that has been bound by a controller to receive all of the request parameters that are not explicitly named- Returns:
- the final array of
FilterAndSortCriteria
to pass to the fetch
-
modifyCriteria
-
getSortDirections
Obtains the list of sort directions from the bound request parameters. Note that these should appear in the same relative order asgetSortPropertyNames(Map)
- Parameters:
requestParams
-- Returns:
-
getSortPropertyNames
Obtains the list of property names to sort on from the bound request parameters. Note that these should appear in the same relative order asgetSortDirections(Map)
.- Parameters:
requestParams
-- Returns:
-
getClassNameForSection
Gets the fully qualified ceiling entity classname for this section. If this section is not explicitly defined in the database, will return the value passed into this function. For example, if there is a mapping from "/myentity" to "com.mycompany.myentity", both "http://localhost/myentity" and "http://localhost/com.mycompany.myentity" are valid request paths.- Parameters:
sectionKey
-- Returns:
- the className for this sectionKey if found in the database or the sectionKey if not
-
getAddEntityTypes
If there are certain types of entities that should not be allowed to be created, an override of this method would be able to specify that. It could also add additional types if desired.- Parameters:
classTree
-- Returns:
- a List
representing all potentially avaialble entity types to create
-
getDefaultEntityType
This method is called when attempting to add new entities that have a polymorphic tree.If this method returns null, there is no default type set for this particular entity type, and the user will be presented with a selection of possible types to utilize.
If it returns a non-null value, the returned fullyQualifiedClassname will be used and will bypass the selection step.
- Returns:
- null if there is no default type, otherwise the default type
-
getSectionCustomCriteria
This method is invoked for every request for this controller. By default, we do not want to specify a custom criteria, but specialized controllers may want to.- Returns:
- the custom criteria for this section for all requests, if any
-
attachSectionSpecificInfo
Deprecated. -
modifyEntityForm
protected void modifyEntityForm(EntityForm entityForm, Map<String, String> pathVars) throws ExceptionThis method is invoked whenever an assembled EntityForm is rendered. This typically occurs when viewing an entity in the admin or viewing an error state on a POST for that entity.- Parameters:
entityForm
-- Throws:
Exception
-
modifyAddEntityForm
This method is invoked whenever an assembled EntityForm is rendered for the add entity screen.- Parameters:
entityForm
-
-
attachSectionSpecificInfo
protected void attachSectionSpecificInfo(PersistencePackageRequest ppr, Map<String, String> pathVars) A hook method that is invoked every time the getSectionPersistencePackageRequest(..) method is invoked. This allows specialized controllers to hook into every request and manipulate the persistence package request as desired.- Parameters:
ppr
-
-
getStartIndex
Obtains the requested start index parameter- Parameters:
requestParams
-- Returns:
-
getMaxIndex
Obtains the requested max index parameter- Parameters:
requestParams
-- Returns:
-
getMaxResults
Obtains the requested max index parameter- Parameters:
requestParams
-- Returns:
-
getLastId
-
getFirstId
-
getUpperCount
-
getLowerCount
-
getPageSize
-
setModelAttributes
Attributes to add to the model on every request- Parameters:
model
-sectionKey
-
-
getSectionPersistencePackageRequest
@Deprecated protected PersistencePackageRequest getSectionPersistencePackageRequest(String sectionClassName, List<SectionCrumb> sectionCrumbs) Deprecated. -
getSectionPersistencePackageRequest
protected PersistencePackageRequest getSectionPersistencePackageRequest(String sectionClassName, List<SectionCrumb> sectionCrumbs, Map<String, String> pathVars) Returns a PersistencePackageRequest for the given sectionClassName. Will also invoke thegetSectionCustomCriteria()
andattachSectionSpecificInfo(PersistencePackageRequest)
to allow specialized controllers to manipulate the request for every action in this controller.- Parameters:
sectionClassName
-sectionCrumbs
-pathVars
-- Returns:
-
getSectionPersistencePackageRequest
@Deprecated protected PersistencePackageRequest getSectionPersistencePackageRequest(String sectionClassName, org.springframework.util.MultiValueMap<String, String> requestParams, List<SectionCrumb> sectionCrumbs) Deprecated. -
getPersistencePackageRequest
protected PersistencePackageRequest getPersistencePackageRequest(org.springframework.util.MultiValueMap<String, String> requestParams, Class<?> ceilingEntityClass) Returns a PersistencePackageRequest for the given sectionClassName. Will also invoke thegetSectionCustomCriteria()
andattachSectionSpecificInfo(PersistencePackageRequest)
to allow specialized controllers to manipulate the request for every action in this controller.- Parameters:
requestParams
-ceilingEntityClass
-- Returns:
-
getSectionPersistencePackageRequest
protected PersistencePackageRequest getSectionPersistencePackageRequest(String sectionClassName, org.springframework.util.MultiValueMap<String, String> requestParams, List<SectionCrumb> sectionCrumbs, Map<String, String> pathVars) Returns the result of a call to getSectionPersistencePackageRequest(..) with the additional filter and sort criteria attached.- Parameters:
sectionClassName
-requestParams
-sectionCrumbs
-pathVars
-- Returns:
- the PersistencePacakageRequest
-
getSectionCrumbs
protected List<SectionCrumb> getSectionCrumbs(jakarta.servlet.http.HttpServletRequest request, String currentSection, String currentSectionId) -
createSectionCrumb
-
populateJsonValidationErrors
protected JsonResponse populateJsonValidationErrors(EntityForm form, org.springframework.validation.BindingResult result, JsonResponse json) Populates the given json response object based on the given form and result- Returns:
- the same result that was passed in
-
translateErrorMessage
-
declareForceUseAdditionStatusFilter
protected void declareForceUseAdditionStatusFilter()
-
attachSectionSpecificInfo(PersistencePackageRequest, Map)