Skip to content

feat: add REST APIs for company info #34671#34672

Open
hassandotcms wants to merge 13 commits intomainfrom
34671-feature-basic-config-apis
Open

feat: add REST APIs for company info #34671#34672
hassandotcms wants to merge 13 commits intomainfrom
34671-feature-basic-config-apis

Conversation

@hassandotcms
Copy link
Contributor

@hassandotcms hassandotcms commented Feb 17, 2026

Proposed Changes

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.

Checklist

  • Tests
  • Translations
  • Security Implications Contemplated (add notes if applicable)

Additional Info

** any additional useful context or info **

Screenshots

Original Updated
** original screenshot ** ** updated screenshot **

This PR fixes: #34671

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.
@hassandotcms hassandotcms linked an issue Feb 17, 2026 that may be closed by this pull request
@github-actions github-actions bot added Area : Backend PR changes Java/Maven backend code Area : CI/CD PR changes GitHub Actions/workflows labels Feb 17, 2026
@spbolton spbolton removed the Area : CI/CD PR changes GitHub Actions/workflows label Feb 17, 2026
@hassandotcms hassandotcms changed the title feat: add REST API for company locale info feat: add REST APIs for company info #34671 Feb 26, 2026
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.
…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
- Change 5 tests to expect ValidationException (from @NotNull via
  Validated.checkValid) instead of BadRequestException
- Remove 2 logo path validation tests (validation was removed) #34671
@hassandotcms hassandotcms marked this pull request as ready for review March 3, 2026 14:54
requiredMode = Schema.RequiredMode.REQUIRED
)
String authType();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

best suited as an enum

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


// NavLogo feature is Enterprise only
String navBarLogo = form.getNavBarLogo();
if (LicenseUtil.getLevel() == LicenseLevel.COMMUNITY.level
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that licensing matters anymore. But please double check.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loginLogo == City?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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("@")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have a /v1/configuration
Perhaps this should be part of that resource

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

hassandotcms and others added 3 commits March 5, 2026 20:47
- 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>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area : Backend PR changes Java/Maven backend code

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

[FEATURE] Basic Config APIs

3 participants