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

LPS-114374 | LPS-111958 SF #90220

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,31 @@
/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/

package com.liferay.app.builder.portlet.tab;

import org.osgi.annotation.versioning.ProviderType;

/**
* @author Inácio Nery
*/
@ProviderType
public interface AppBuilderAppPortletTab {

public String getEditEntryPoint();

public String getListEntryPoint();

public String getViewEntryPoint();

}
Expand Up @@ -23,6 +23,8 @@ public class AppBuilderWebKeys {

public static final String APP_DEPLOYMENT_TYPE = "APP_DEPLOYMENT_TYPE";

public static final String APP_TAB = "APP_TAB";

public static final String APPS_TABS = "APPS_TABS";

public static final String SHOW_FORM_VIEW = "SHOW_FORM_VIEW";
Expand Down
Expand Up @@ -15,8 +15,12 @@
package com.liferay.app.builder.web.internal.portlet;

import com.liferay.app.builder.model.AppBuilderApp;
import com.liferay.app.builder.portlet.tab.AppBuilderAppPortletTab;
import com.liferay.app.builder.web.internal.constants.AppBuilderWebKeys;
import com.liferay.osgi.service.tracker.collections.map.ServiceTrackerMap;
import com.liferay.osgi.service.tracker.collections.map.ServiceTrackerMapFactory;
import com.liferay.portal.kernel.portlet.bridges.mvc.MVCPortlet;
import com.liferay.portal.kernel.util.HashMapBuilder;
import com.liferay.portal.kernel.util.HashMapDictionary;

import java.io.IOException;
Expand All @@ -28,6 +32,9 @@
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;

import org.osgi.framework.Bundle;
import org.osgi.framework.FrameworkUtil;

/**
* @author Gabriel Albuquerque
*/
Expand All @@ -46,6 +53,14 @@ public AppPortlet(
String portletName, boolean showFormView, boolean showTableView) {

_appBuilderApp = appBuilderApp;

Bundle bundle = FrameworkUtil.getBundle(AppPortlet.class);

_appBuilderAppPortletTabTrackerMap =
ServiceTrackerMapFactory.openSingleValueMap(
bundle.getBundleContext(), AppBuilderAppPortletTab.class,
"app.builder.app.tab.name");

_appDeploymentType = appDeploymentType;
_appName = appName;
_portletName = portletName;
Expand Down Expand Up @@ -95,6 +110,21 @@ public void render(
renderRequest.setAttribute(AppBuilderWebKeys.APP, _appBuilderApp);
renderRequest.setAttribute(
AppBuilderWebKeys.APP_DEPLOYMENT_TYPE, _appDeploymentType);

AppBuilderAppPortletTab appBuilderAppPortletTab =
_appBuilderAppPortletTabTrackerMap.getService(
_appBuilderApp.getScope());

renderRequest.setAttribute(
AppBuilderWebKeys.APP_TAB,
HashMapBuilder.<String, Object>put(
"editEntryPoint", appBuilderAppPortletTab.getEditEntryPoint()
).put(
"listEntryPoint", appBuilderAppPortletTab.getListEntryPoint()
).put(
"viewEntryPoint", appBuilderAppPortletTab.getViewEntryPoint()
).build());

renderRequest.setAttribute(
AppBuilderWebKeys.SHOW_FORM_VIEW, _showFormView);
renderRequest.setAttribute(
Expand All @@ -104,6 +134,8 @@ public void render(
}

private final AppBuilderApp _appBuilderApp;
private final ServiceTrackerMap<String, AppBuilderAppPortletTab>
_appBuilderAppPortletTabTrackerMap;
private final String _appDeploymentType;
private final String _appName;
private final String _portletName;
Expand Down
@@ -0,0 +1,54 @@
/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/

package com.liferay.app.builder.web.internal.portlet.tab;

import com.liferay.app.builder.portlet.tab.AppBuilderAppPortletTab;
import com.liferay.frontend.js.loader.modules.extender.npm.NPMResolver;

import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

/**
* @author Inácio Nery
*/
@Component(
immediate = true, property = "app.builder.app.tab.name=standard",
service = AppBuilderAppPortletTab.class
)
public class StandardAppBuilderAppPortletTab
implements AppBuilderAppPortletTab {

@Override
public String getEditEntryPoint() {
return _npmResolver.resolveModuleName(
"app-builder-web/js/pages/entry/EditEntry.es");
}

@Override
public String getListEntryPoint() {
return _npmResolver.resolveModuleName(
"app-builder-web/js/pages/entry/ListEntries.es");
}

@Override
public String getViewEntryPoint() {
return _npmResolver.resolveModuleName(
"app-builder-web/js/pages/entry/ViewEntry.es");
}

@Reference
private NPMResolver _npmResolver;

}
Expand Up @@ -49,6 +49,8 @@ AppBuilderApp appBuilderApp = (AppBuilderApp)request.getAttribute(AppBuilderWebK
"appDeploymentType", request.getAttribute(AppBuilderWebKeys.APP_DEPLOYMENT_TYPE)
).put(
"appId", appBuilderApp.getAppBuilderAppId()
).put(
"appTab", request.getAttribute(AppBuilderWebKeys.APP_TAB)
).put(
"basePortletURL", String.valueOf(renderResponse.createRenderURL())
).put(
Expand Down
Expand Up @@ -15,12 +15,14 @@
import React from 'react';

import {AppContextProvider} from '../../AppContext.es';
import EditEntry from './EditEntry.es';
import useLazy from '../../hooks/useLazy.es';

export default ({appTab, ...props}) => {
const EditPage = useLazy();

export default (props) => {
return (
<AppContextProvider {...props}>
<EditEntry {...props} />
<EditPage module={appTab.editEntryPoint} props={props} />
</AppContextProvider>
);
};
Expand Up @@ -16,11 +16,20 @@ import React from 'react';
import {HashRouter as Router, Route, Switch} from 'react-router-dom';

import {AppContextProvider} from '../../AppContext.es';
import ListEntries from './ListEntries.es';
import useLazy from '../../hooks/useLazy.es';
import {PermissionsContextProvider} from './PermissionsContext.es';
import ViewEntry from './ViewEntry.es';

export default function (props) {
export default function ({appTab, ...props}) {
const PageComponent = useLazy();

const ListPage = (props) => (
<PageComponent module={appTab.listEntryPoint} props={props} />
);

const ViewPage = (props) => (
<PageComponent module={appTab.viewEntryPoint} props={props} />
);

return (
<div className="app-builder-root">
<AppContextProvider {...props}>
Expand All @@ -29,9 +38,9 @@ export default function (props) {
>
<Router>
<Switch>
<Route component={ListEntries} exact path="/" />
<Route component={ListPage} exact path="/" />
<Route
component={ViewEntry}
component={ViewPage}
path="/entries/:entryIndex(\d+)"
/>
</Switch>
Expand Down
Expand Up @@ -25,6 +25,8 @@
"appDeploymentType", request.getAttribute(AppBuilderWebKeys.APP_DEPLOYMENT_TYPE)
).put(
"appId", appBuilderApp.getAppBuilderAppId()
).put(
"appTab", request.getAttribute(AppBuilderWebKeys.APP_TAB)
).put(
"basePortletURL", String.valueOf(renderResponse.createRenderURL())
).put(
Expand Down
Expand Up @@ -68,10 +68,6 @@ public WorkflowDefinition postWorkflowDefinitionUpdateActive(
Boolean active, String name, String version)
throws Exception;

public WorkflowDefinition postWorkflowDefinitionUpdateTitle(
String name, String title, String version)
throws Exception;

public default void setContextAcceptLanguage(
AcceptLanguage contextAcceptLanguage) {
}
Expand Down
Expand Up @@ -88,15 +88,6 @@ public WorkflowDefinition postWorkflowDefinitionUpdateActive(
Boolean active, String name, String version)
throws Exception;

public WorkflowDefinition postWorkflowDefinitionUpdateTitle(
String name, String title, String version)
throws Exception;

public HttpInvoker.HttpResponse
postWorkflowDefinitionUpdateTitleHttpResponse(
String name, String title, String version)
throws Exception;

public static class Builder {

public Builder authentication(String login, String password) {
Expand Down Expand Up @@ -568,85 +559,6 @@ public WorkflowDefinition postWorkflowDefinitionUpdateActive(
return httpInvoker.invoke();
}

public WorkflowDefinition postWorkflowDefinitionUpdateTitle(
String name, String title, String version)
throws Exception {

HttpInvoker.HttpResponse httpResponse =
postWorkflowDefinitionUpdateTitleHttpResponse(
name, title, version);

String content = httpResponse.getContent();

_logger.fine("HTTP response content: " + content);

_logger.fine("HTTP response message: " + httpResponse.getMessage());
_logger.fine(
"HTTP response status code: " + httpResponse.getStatusCode());

try {
return WorkflowDefinitionSerDes.toDTO(content);
}
catch (Exception e) {
_logger.log(
Level.WARNING,
"Unable to process HTTP response: " + content, e);

throw new Problem.ProblemException(Problem.toDTO(content));
}
}

public HttpInvoker.HttpResponse
postWorkflowDefinitionUpdateTitleHttpResponse(
String name, String title, String version)
throws Exception {

HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();

httpInvoker.body(version.toString(), "application/json");

if (_builder._locale != null) {
httpInvoker.header(
"Accept-Language", _builder._locale.toLanguageTag());
}

for (Map.Entry<String, String> entry :
_builder._headers.entrySet()) {

httpInvoker.header(entry.getKey(), entry.getValue());
}

for (Map.Entry<String, String> entry :
_builder._parameters.entrySet()) {

httpInvoker.parameter(entry.getKey(), entry.getValue());
}

httpInvoker.httpMethod(HttpInvoker.HttpMethod.POST);

if (name != null) {
httpInvoker.parameter("name", String.valueOf(name));
}

if (title != null) {
httpInvoker.parameter("title", String.valueOf(title));
}

if (version != null) {
httpInvoker.parameter("version", String.valueOf(version));
}

httpInvoker.path(
_builder._scheme + "://" + _builder._host + ":" +
_builder._port +
"/o/headless-admin-workflow/v1.0/workflow-definitions/update-title");

httpInvoker.userNameAndPassword(
_builder._login + ":" + _builder._password);

return httpInvoker.invoke();
}

private WorkflowDefinitionResourceImpl(Builder builder) {
_builder = builder;
}
Expand Down
Expand Up @@ -714,37 +714,6 @@ paths:
description:
""
tags: ["WorkflowDefinition"]
"/workflow-definitions/update-title":
post:
operationId: postWorkflowDefinitionUpdateTitle
parameters:
- in: query
name: name
required: true
schema:
type: string
- in: query
name: title
required: true
schema:
type: string
- in: query
name: version
required: true
schema:
type: string
responses:
200:
content:
application/json:
schema:
$ref: "#/components/schemas/WorkflowDefinition"
application/xml:
schema:
$ref: "#/components/schemas/WorkflowDefinition"
description:
""
tags: ["WorkflowDefinition"]
"/workflow-instances":
get:
operationId: getWorkflowInstancesPage
Expand Down