Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#27979 new lang vars endpoint #28237

Closed
wants to merge 38 commits into from

Conversation

fabrizzio-dotCMS
Copy link
Contributor

@fabrizzio-dotCMS fabrizzio-dotCMS commented Apr 15, 2024

Proposed Changes

  • The main goal of this PR is to introduce the new methods that will be used to replace the old Language Keys stored as property files
  • These methods have been added to LanguageVariableAPI
  • My Main concern here is that the new methods are designed to simply return the LanguageVariables no user or permission is contemplated here. I need to know if we're gonna need to do that.
  • Even though there were a few other methods here designed to return KeyValue objects these have a problem with being index dependant
  • A New interface LanguageVariable has been created. it extends KeyValue but explicitly adds the intention to have a language associated. Also, there is a new DataGen related to these classes.
  • These LanguageVariables are cached using the same LanguageCache but a separate group. All the Language Variables are cached per language. so if we update or unpublish a LanguageVariable let's say (and cache invalidation is needed) This will not affect other LanguageVaribales of a different language living cache.
  • A new Endpoint for retrieving LanguageVariables has been added.
  • The respective postman test was added too.
  • Changes were made to ESContentletAPIImpl so the respective cache invalidation can be accomplished.
  • Several issues were outlined on ESContentletAPIImpl by sonar so they were corrected.

@fabrizzio-dotCMS fabrizzio-dotCMS marked this pull request as ready for review April 22, 2024 22:23
@nollymar
Copy link
Contributor

@fabrizzio-dotCMS about your concern here "My Main concern here is that the new methods are designed to simply return the LanguageVariables no user or permission is contemplated here. I need to know if we're gonna need to do that." ....we agreed that the language variables would inherit permissions from the LanguageVariable content type

@fabrizzio-dotCMS
Copy link
Contributor Author

fabrizzio-dotCMS commented Apr 24, 2024

@fabrizzio-dotCMS about your concern here "My Main concern here is that the new methods are designed to simply return the LanguageVariables no user or permission is contemplated here. I need to know if we're gonna need to do that." ....we agreed that the language variables would inherit permissions from the LanguageVariable content type

@nollymar
Yeah, we share the same concern. There are two main methods here. The one that returns Paginated LaguageVariables. That one I intend to use to populate the new screen. The admin role guards that one. So I don't think We're gonna need a user there.

The second method I'm introducing here is the one I intend to use to replace the properties LanguageKey on that one I introduced a User. And I perform a permission check. My reasoning here is that we can always call it using system user. to get everything

@nollymar
Copy link
Contributor

nollymar commented Apr 24, 2024

@wezell do we want to get language variables from the database? I understand that we don't want to depend on ES for it and @fabrizzio-dotCMS is caching those records after hitting the database. However, considering that language variables are pieces of content now, shouldn't we just leverage on the index the same way we do in Content Search for example?

On the other hand, @fabrizzio-dotCMS has another point that is totally valid ... we shouldn't rely on ES when a user wants to use a specific language variable.

We would like to have your input on it.

@CloseDBIfOpened
@Override
public List<LanguageVariable> findVariables(final long langId, final User user) throws DotDataException {
final ContentletFactory contentletFactory = FactoryLocator.getContentletFactory();
Copy link
Contributor

Choose a reason for hiding this comment

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

log inputs

@@ -0,0 +1,63 @@
package com.dotcms.rest;

public class AbstractPaginationContext {
Copy link
Contributor

Choose a reason for hiding this comment

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

nice abstraction

Copy link
Contributor

Choose a reason for hiding this comment

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

but create a buider

public Response getVariables(
@Context final HttpServletRequest request,
@Context final HttpServletResponse response,
@BeanParam final PaginationContext paginationContext) throws DotDataException {
Copy link
Contributor

Choose a reason for hiding this comment

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

keep in mind we already have some standard to do pagination by PaginationUtil, take a look

*/
@Override
public int countByTypeWorkingOrLive(final ContentType contentType, final boolean working) {
final DotConnect dotConnect = new DotConnect();
Copy link
Contributor

Choose a reason for hiding this comment

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

if you want you can reduce this to one line

return new DotConnect().setSQL("select count(distinct contentlet.identifier) as x "
                + " from contentlet, contentlet_version_info, inode "
                + " where contentlet.structure_inode = ? "
                + " and contentlet_version_info.identifier = contentlet.identifier "
                + " and contentlet_version_info."+ (working?WORKING_INODE:LIVE_INODE)+"= contentlet.inode "
                + " and contentlet.inode = inode.inode "
                + " and contentlet_version_info.deleted = 'false' ")
            .addParam(contentType.inode()).dotConnect.getInt("x");

@fabrizzio-dotCMS
Copy link
Contributor Author

closed in favor of #28429

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Internal QA
Development

Successfully merging this pull request may close these issues.

None yet

3 participants