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-39465 #1966

Closed
wants to merge 1 commit 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
Expand Up @@ -68,61 +68,65 @@
*/
public class AppManagerPortlet extends MVCPortlet {

public void installLocalApp(
public void installApp(
ActionRequest actionRequest, ActionResponse actionResponse)
throws Exception {

UploadPortletRequest uploadPortletRequest =
PortalUtil.getUploadPortletRequest(actionRequest);

String fileName = GetterUtil.getString(
uploadPortletRequest.getFileName("file"));
String installMethod = ParamUtil.getString(
uploadPortletRequest, "installMethod");

File file = uploadPortletRequest.getFile("file");
if (installMethod.equals("local")) {
String fileName = GetterUtil.getString(
uploadPortletRequest.getFileName("file"));

byte[] bytes = FileUtil.getBytes(file);
File file = uploadPortletRequest.getFile("file");

if (ArrayUtil.isEmpty(bytes)) {
SessionErrors.add(actionRequest, UploadException.class.getName());
}
else {
String deployDir = PrefsPropsUtil.getString(
PropsKeys.AUTO_DEPLOY_DEPLOY_DIR);

FileUtil.copyFile(
file.toString(), deployDir + StringPool.SLASH + fileName);

SessionMessages.add(actionRequest, "pluginUploaded");
}
byte[] bytes = FileUtil.getBytes(file);

String redirect = ParamUtil.getString(uploadPortletRequest, "redirect");
if (ArrayUtil.isEmpty(bytes)) {
SessionErrors.add(
actionRequest, UploadException.class.getName());
}
else {
String deployDir = PrefsPropsUtil.getString(
PropsKeys.AUTO_DEPLOY_DEPLOY_DIR);

actionResponse.sendRedirect(redirect);
}
FileUtil.copyFile(
file.toString(), deployDir + StringPool.SLASH + fileName);

public void installRemoteApp(
ActionRequest actionRequest, ActionResponse actionResponse)
throws Exception {
SessionMessages.add(actionRequest, "pluginUploaded");
}
}
else {
try {
String url = ParamUtil.getString(uploadPortletRequest, "url");

try {
String url = ParamUtil.getString(actionRequest, "url");
URL urlObj = new URL(url);

URL urlObj = new URL(url);
String host = urlObj.getHost();

String host = urlObj.getHost();
if (host.endsWith("sf.net") ||
host.endsWith("sourceforge.net")) {

if (host.endsWith("sf.net") || host.endsWith("sourceforge.net")) {
doInstallSourceForgeApp(urlObj.getPath(), actionRequest);
doInstallSourceForgeApp(
urlObj.getPath(), uploadPortletRequest, actionRequest);
}
else {
doInstallRemoteApp(
url, uploadPortletRequest, actionRequest, true);
}
}
else {
doInstallRemoteApp(url, actionRequest, true);
catch (MalformedURLException murle) {
SessionErrors.add(actionRequest, "invalidUrl", murle);
}
}
catch (MalformedURLException murle) {
SessionErrors.add(actionRequest, "invalidUrl", murle);
}

sendRedirect(actionRequest, actionResponse);
String redirect = ParamUtil.getString(uploadPortletRequest, "redirect");

actionResponse.sendRedirect(redirect);
}

public void uninstallApp(
Expand Down Expand Up @@ -248,13 +252,14 @@ public void updatePluginSettings(
}

protected int doInstallRemoteApp(
String url, ActionRequest actionRequest, boolean failOnError)
String url, UploadPortletRequest uploadPortletRequest,
ActionRequest actionRequest, boolean failOnError)
throws Exception {

int responseCode = HttpServletResponse.SC_OK;

String deploymentContext = ParamUtil.getString(
actionRequest, "deploymentContext");
uploadPortletRequest, "deploymentContext");

try {
String fileName = null;
Expand All @@ -280,7 +285,7 @@ protected int doInstallRemoteApp(
options.setPost(false);

String progressId = ParamUtil.getString(
actionRequest, Constants.PROGRESS_ID);
uploadPortletRequest, Constants.PROGRESS_ID);

options.setProgressId(progressId);

Expand Down Expand Up @@ -324,7 +329,8 @@ protected int doInstallRemoteApp(
}

protected void doInstallSourceForgeApp(
String path, ActionRequest actionRequest)
String path, UploadPortletRequest uploadPortletRequest,
ActionRequest actionRequest)
throws Exception {

String[] sourceForgeMirrors = PropsUtil.getArray(
Expand All @@ -341,7 +347,7 @@ protected void doInstallSourceForgeApp(
}

int responseCode = doInstallRemoteApp(
url, actionRequest, failOnError);
url, uploadPortletRequest, actionRequest, failOnError);

if (responseCode == HttpServletResponse.SC_OK) {
return;
Expand Down
@@ -1,9 +1,9 @@
all-apps=All Apps
app-manager=App Manager
are-you-sure-you-want-to-uninstall-this-product=Are you sure you want to uninstall this product?
are-you-sure-you-want-to-uninstall-this=Are you sure you want to uninstall this?
are-you-sure-you-want-to-uninstall-this-product=Are you sure you want to uninstall this product?
could-not-connect-to-the-liferay-marketplace=Could not connect to the Liferay Marketplace.
lpkg-or-war-file=LPKG or WAR File
file-upload-lpkg-or-war-file=File Upload (LPKG or WAR File)
reindex-search=Reindex Search
there-are-no-configurable-plugins-for-this-app=There are no configurable plugins for this app.
this-app-contains=This app contains:
Expand Down
4 changes: 4 additions & 0 deletions portlets/marketplace-portlet/docroot/app_manager/css/main.css
Expand Up @@ -96,4 +96,8 @@
}
}
}

.install-apps .control-group {
margin-left: 20px;
}
}
61 changes: 35 additions & 26 deletions portlets/marketplace-portlet/docroot/app_manager/install_apps.jspf
Expand Up @@ -14,39 +14,48 @@
*/
--%>

<div class="row">
<div class="span6">
<portlet:actionURL name="installLocalApp" var="installLocalAppURL" />
<portlet:actionURL name="installApp" var="installAppURL" />

<aui:form action="<%= installLocalAppURL %>" enctype="multipart/form-data" method="post" name="fm1">
<aui:input name="redirect" type="hidden" value="<%= portletURL.toString() %>" />
<aui:form action="<%= installAppURL %>" cssClass="install-apps" enctype="multipart/form-data" method="post" name="fm1">
<aui:input name="redirect" type="hidden" value="<%= portletURL.toString() %>" />

<aui:fieldset label="file-upload">
<liferay-ui:success key="pluginUploaded" message="the-plugin-was-uploaded-successfully-and-is-now-being-installed" />
<aui:fieldset label="install">
<liferay-ui:success key="pluginUploaded" message="the-plugin-was-uploaded-successfully-and-is-now-being-installed" />

<liferay-ui:error exception="<%= UploadException.class %>" message="an-unexpected-error-occurred-while-uploading-your-file" />
<liferay-ui:success key="pluginDownloaded" message="the-plugin-was-downloaded-successfully-and-is-now-being-installed" />

<aui:input label="lpkg-or-war-file" name="file" type="file" />
<div class="install-method local">
<liferay-ui:error exception="<%= UploadException.class %>" message="an-unexpected-error-occurred-while-uploading-your-file" />

<aui:button type="submit" value="install" />
</aui:fieldset>
</aui:form>
</div>
<div class="span6">
<portlet:actionURL name="installRemoteApp" var="installRemoteAppURL" />
<aui:input label="file-upload-lpkg-or-war-file" name="installMethod" type="radio" value="local" />

<aui:form action="<%= installRemoteAppURL %>" method="post" name="fm2">
<aui:input name="redirect" type="hidden" value="<%= portletURL.toString() %>" />
<aui:input cssClass="file-input" label="" name="file" type="file" />
</div>

<aui:fieldset label="url">
<liferay-ui:success key="pluginDownloaded" message="the-plugin-was-downloaded-successfully-and-is-now-being-installed" />
<div class="install-method remote">
<liferay-ui:error key="invalidUrl" message="please-enter-a-valid-url" />

<liferay-ui:error key="invalidUrl" message="please-enter-a-valid-url" />
<aui:input label="url" name="installMethod" type="radio" value="remote" />

<aui:input name="url" type="text" />
<aui:input cssClass="file-input" label="" name="url" type="text" />
</div>

<aui:button type="submit" value="install" />
</aui:fieldset>
</aui:form>
</div>
</div>
<aui:button type="submit" value="install" />
</aui:fieldset>
</aui:form>

<aui:script use="aui-base">
A.one('.marketplace-portlet .install-method.local .file-input').on(
'change',
function(event) {
A.one('.marketplace-portlet .install-method.local input[type=radio]').attr('checked', true);
}
);

A.one('.marketplace-portlet .install-method.remote .file-input').on(
'click',
function(event) {
A.one('.marketplace-portlet .install-method.remote input[type=radio]').attr('checked', true);
}
);
</aui:script>