feat: add REST APIs for company info #34671#34672
feat: add REST APIs for company info #34671#34672hassandotcms wants to merge 13 commits intomainfrom
Conversation
Add POST /api/v1/configuration/_saveCompanyLocaleInfo endpoint to ConfigurationResource as a modern replacement for the legacy POST /api/config/saveCompanyLocaleInfo. Uses JSON input, proper InitBuilder auth, Swagger annotations, and delegates to CompanyManagerUtil.updateUsers for timezone validation, default user locale persistence, and JVM timezone update.
…ure-basic-config-apis
Introduce new /api/v1/company resource with 5 endpoints to replace legacy form-encoded APIs in CMSConfigResource: - GET /api/v1/company — read full company config for admin UI - PUT /api/v1/company/basic-info — save branding, portal URL, email - PUT /api/v1/company/locale-info — save language and timezone - PUT /api/v1/company/auth-type — save authentication type - POST /api/v1/company/_regenerateKey — regenerate security key Uses semantic field names instead of obfuscated Liferay model fields (e.g. primaryColor instead of type, secondaryColor instead of street). Moves _saveCompanyLocaleInfo from ConfigurationResource to the new CompanyResource for consistent API grouping.
…ure-basic-config-apis
…34671 Add 'Company Configuration' tag to DotRestApplication's OpenAPIDefinition to fix RestEndpointAnnotationValidationTest failure. Replace raw RuntimeException with DotRuntimeException in CompanyConfigHelper for proper error handling by the global exception mapper.
Add CompanyResourceIntegrationTest with 19 tests covering all 5 endpoints: GET config, PUT basic-info, PUT auth-type, PUT locale-info, POST regenerateKey. Tests verify persistence, field mapping, input validation, and admin-only access. Also add missing /dA prefix validation for backgroundImage in CompanyBasicInfoForm for consistency with loginScreenLogo and navBarLogo.
…sicInfoForm The read side (toView) already filters non-/dA logos, and the API should remain flexible for REST consumers. OpenAPI docs clearly state the expected format without enforcing it on write. #34671
…ure-basic-config-apis
| requiredMode = Schema.RequiredMode.REQUIRED | ||
| ) | ||
| String authType(); | ||
|
|
There was a problem hiding this comment.
best suited as an enum
|
|
||
| // NavLogo feature is Enterprise only | ||
| String navBarLogo = form.getNavBarLogo(); | ||
| if (LicenseUtil.getLevel() == LicenseLevel.COMMUNITY.level |
There was a problem hiding this comment.
I don't think that licensing matters anymore. But please double check.
There was a problem hiding this comment.
yeah, you are right. but code still has these license checks across the codebase.
i will see if i can remove it.
| */ | ||
| private CompanyConfigView toView(final Company company) { | ||
|
|
||
| final String loginLogo = company.getCity(); |
There was a problem hiding this comment.
loginLogo == City?
There was a problem hiding this comment.
Yes, the Liferay Company model repurposes address fields.
city = loginScreenLogo,
state = navBarLogo.
Same mapping used in CMSConfigResource:91,141 and ConfigurationHelper:115.
I will add a clarifying comment in code
| */ | ||
| private String extractDomain(final String email) { | ||
|
|
||
| if (UtilMethods.isSet(email) && email.contains("@")) { |
There was a problem hiding this comment.
This assumes a valid email. Add a try catch or org.apache.commons.validator.routines.EmailValidator;
to validate that the e-mail is valid
| */ | ||
| @Path("/v1/company") | ||
| @SwaggerCompliant(value = "Company configuration and system settings APIs", batch = 3) | ||
| @Tag(name = "Company Configuration", description = "Company settings and branding management") |
There was a problem hiding this comment.
We already have a /v1/configuration
Perhaps this should be part of that resource
There was a problem hiding this comment.
I mean, our customers don't know anything about a company.
Even though we know there's a table company, etc. I don't think the customer needs to know that the locale is assigned via the company or that the authentication type is bound to the company.
I fear this is not the proper name for this resource
There was a problem hiding this comment.
yeah make sense, "company" leaks an internal detail.
I will move these under /v1/configuration/ as sub-paths (/basic-info, /auth-type, /locale-info, /_regenerateKey)
@fmontes any comment on this?
- Create AuthType enum to replace string-based auth type validation - Add try-catch in extractDomain for defensive email handling - Add field mapping comment in toView() explaining Liferay Company address field repurposing for branding Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ure-basic-config-apis
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Proposed Changes
Introduce new /api/v1/company resource with 5 endpoints to replace legacy form-encoded APIs in CMSConfigResource:
Uses semantic field names instead of obfuscated Liferay model fields
(e.g. primaryColor instead of type, secondaryColor instead of street).
Moves _saveCompanyLocaleInfo from ConfigurationResource to the new
CompanyResource for consistent API grouping.
Checklist
Additional Info
** any additional useful context or info **
Screenshots
This PR fixes: #34671