modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleNotFoundException.java | 49 ++++++++++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleGroupsStep.java | 1 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleUploadDistroFileStep.java | 12 +- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesListView.java | 4 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/upload/BundleDistributionFileUploadForm.java | 18 +-- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleDistributionFileUploadServlet.java | 5 - modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java | 7 + modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleNotFoundException.java | 49 ---------- 8 files changed, 77 insertions(+), 68 deletions(-)
New commits: commit 5f567aed7720e20b98bdf5e8fd0abbdc2fdcc956 Author: Jay Shaughnessy jshaughn@redhat.com Date: Mon Aug 19 16:09:31 2013 -0400
Fix non-global bundle create workflow using the "token" approach - move BundleNotFoundException to domain so we have a good ApplicationException to use that is also recognized in the GUI. - add radio button form to bundleGroups wizard step (needs a lot of TLC still) - temporarily fix New bundle button authz, remove MANAGE_BUNDLE
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleNotFoundException.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleNotFoundException.java new file mode 100644 index 0000000..803412e --- /dev/null +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleNotFoundException.java @@ -0,0 +1,49 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2013 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.core.domain.bundle; + +import javax.ejb.ApplicationException; + +/** + * Indicates a required RHQ bundle did not exist. This class is defined in the in the domain module instead + * of the server/jar module because it needs to be accessible by the UI. Note that this is an ApplicationException + * and when throwing this from an EJB it will not be wrapped as an EJBException, and as annotated, it will not rollback + * an ongoing transaction. + */ +@ApplicationException(rollback = false, inherited = true) +public class BundleNotFoundException extends RuntimeException { + private static final long serialVersionUID = 1L; + + // Default no-arg constructor required by JAXB + public BundleNotFoundException() { + } + + /** + * Create an exception indicating the resource with the specified id was not found. + * + * @param bundleId a bundle id + */ + public BundleNotFoundException(int bundleId) { + super("A Bundle with id " + bundleId + " does not exist."); + } + + public BundleNotFoundException(String message) { + super(message); + } +} \ No newline at end of file diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleGroupsStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleGroupsStep.java index 2d6ebbc..e330e3f 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleGroupsStep.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleGroupsStep.java @@ -128,6 +128,7 @@ public class BundleGroupsStep extends AbstractWizardStep {
formItems.add(radioGroupItem); formItems.add(new SpacerItem()); + radioForm.setItems(formItems.toArray(new FormItem[formItems.size()])); canvas.addMember(radioForm);
// go get the assignable/assigned bundle groups for this new bundle version, initial or not diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleUploadDistroFileStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleUploadDistroFileStep.java index 9344fb6..3e19936 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleUploadDistroFileStep.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleUploadDistroFileStep.java @@ -37,6 +37,7 @@ import com.smartgwt.client.widgets.form.fields.TextItem; import com.smartgwt.client.widgets.form.fields.events.ClickEvent; import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
+import org.rhq.core.domain.bundle.BundleNotFoundException; import org.rhq.core.domain.bundle.BundleVersion; import org.rhq.core.domain.bundle.composite.BundleGroupAssignmentComposite; import org.rhq.core.domain.criteria.BundleVersionCriteria; @@ -281,8 +282,8 @@ public class BundleUploadDistroFileStep extends AbstractWizardStep { @Override public void onFailure(Throwable caught) { // This signals that the bundle does not yet exist - if (caught instanceof IllegalStateException) { - handleIllegalStateException((IllegalStateException) caught); + if (caught instanceof BundleNotFoundException) { + handleBundleNotFoundException((BundleNotFoundException) caught);
} else { // Escape it, since it contains the URL, which the user entered. @@ -296,10 +297,10 @@ public class BundleUploadDistroFileStep extends AbstractWizardStep { }); }
- private void handleIllegalStateException(IllegalStateException e) { + private void handleBundleNotFoundException(BundleNotFoundException e) { String token = e.getMessage(); if (null == token || token.isEmpty()) { - wizard.getView().showMessage("IllegalStateException: Unexpected failure creating bundle version."); + wizard.getView().showMessage("BundleNotFound: Unexpected failure creating bundle version."); CoreGUI.getErrorHandler().handleError(MSG.view_bundle_createWizard_createFailure(), e); wizard.setBundleVersion(null); setButtonsDisableMode(false); @@ -361,7 +362,8 @@ public class BundleUploadDistroFileStep extends AbstractWizardStep { } }); } else if (null != uploadDistroForm.getCreateInitialBundleVersionToken()) { - handleIllegalStateException(new IllegalStateException(uploadDistroForm.getCreateInitialBundleVersionToken())); + handleBundleNotFoundException(new BundleNotFoundException( + uploadDistroForm.getCreateInitialBundleVersionToken()));
} else { String errorMessage = uploadDistroForm.getUploadError(); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesListView.java index 296a070..756e4f7 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesListView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundlesListView.java @@ -131,7 +131,9 @@ public class BundlesListView extends Table<BundlesWithLatestVersionDataSource> { // only show the buttons if we were given a set of permissions - passing in null is a way to say you only want the list, no actions if (this.permissions != null) {
- boolean hasAuth = permissions.contains(Permission.MANAGE_BUNDLE); + // TODO NEW BUNDLE ENABLEMENT + // boolean hasAuth = permissions.contains(Permission._BUNDLE); + boolean hasAuth = true;
addTableAction(MSG.common_button_new(), null, new AbstractTableAction( (hasAuth) ? TableActionEnablement.ALWAYS : TableActionEnablement.NEVER) { diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/upload/BundleDistributionFileUploadForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/upload/BundleDistributionFileUploadForm.java index 04fcbf0..e57b852 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/upload/BundleDistributionFileUploadForm.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/upload/BundleDistributionFileUploadForm.java @@ -46,7 +46,7 @@ public class BundleDistributionFileUploadForm extends FileUploadForm {
/** * If this component uploaded a bundle distribution file but failed to create the bundle version - * due to an IllegalStateException (signaling bundle not found), this will return the token necessary to then call + * due to a BundleNotFoundException, this will return the token necessary to then call * createInitialBundleVersionViaToken(). Otherwise, null is returned. * * @return the token required for a a subsequent call to createInitialBundleVersionViaToken(). @@ -63,16 +63,16 @@ public class BundleDistributionFileUploadForm extends FileUploadForm { private int parseResponse(String results) { // the upload servlet will respond with "BundleNotFoundException [createInitialBundleVersionToken]" to indicate // that the BV create failed because the bundle does not yet exist. - String IllegalStateMsgPrefix = "IllegalStateException ["; - int startIllegalStateMsgPrefix = results.indexOf(IllegalStateMsgPrefix); - if (startIllegalStateMsgPrefix >= 0) { - int endIllegalStateMsgPrefix = startIllegalStateMsgPrefix + IllegalStateMsgPrefix.length(); - int startIllegalStateMsgPostfix = results.indexOf(']', endIllegalStateMsgPrefix); - if (startIllegalStateMsgPostfix < 0) { + String bundleNotFoundMsgPrefix = "BundleNotFoundException ["; + int startBundleNotFoundMsgPrefix = results.indexOf(bundleNotFoundMsgPrefix); + if (startBundleNotFoundMsgPrefix >= 0) { + int endBundleNotFoundMsgPrefix = startBundleNotFoundMsgPrefix + bundleNotFoundMsgPrefix.length(); + int startBundleNotFoundMsgPostfix = results.indexOf(']', endBundleNotFoundMsgPrefix); + if (startBundleNotFoundMsgPostfix < 0) { return 0; // this should never happen, we should always have the ending "]" bracket } - this.createInitialBundleVersionToken = results.substring(endIllegalStateMsgPrefix, - startIllegalStateMsgPostfix); + this.createInitialBundleVersionToken = results.substring(endBundleNotFoundMsgPrefix, + startBundleNotFoundMsgPostfix); return 0; }
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleDistributionFileUploadServlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleDistributionFileUploadServlet.java index 91043c6..b4bd2e9 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleDistributionFileUploadServlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleDistributionFileUploadServlet.java @@ -27,6 +27,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;
import org.rhq.core.domain.auth.Subject; +import org.rhq.core.domain.bundle.BundleNotFoundException; import org.rhq.core.domain.bundle.BundleVersion; import org.rhq.enterprise.server.bundle.BundleManagerLocal; import org.rhq.enterprise.server.util.LookupUtil; @@ -54,8 +55,8 @@ public class BundleDistributionFileUploadServlet extends FileUploadServlet { BundleVersion bundleVersion = bundleManager.createOrStoreBundleVersionViaFile(subject, file); successMsg = "success [" + bundleVersion.getId() + "]";
- } catch (IllegalStateException e) { - writeExceptionResponse(response, "IllegalStateException [" + e.getMessage() + "]", e); // clients will look for this string! + } catch (BundleNotFoundException e) { + writeExceptionResponse(response, "BundleNotFoundException " + e.getMessage(), e); // clients will look for this string! return; } catch (Exception e) { writeExceptionResponse(response, "Failed to upload bundle distribution file", e); // clients will look for this string! diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java index eb96add..886e118 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java @@ -73,6 +73,7 @@ import org.rhq.core.domain.bundle.BundleDeploymentStatus; import org.rhq.core.domain.bundle.BundleDestination; import org.rhq.core.domain.bundle.BundleFile; import org.rhq.core.domain.bundle.BundleGroup; +import org.rhq.core.domain.bundle.BundleNotFoundException; import org.rhq.core.domain.bundle.BundleResourceDeployment; import org.rhq.core.domain.bundle.BundleResourceDeploymentHistory; import org.rhq.core.domain.bundle.BundleType; @@ -617,7 +618,8 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
} catch (PermissionException e) { if (null != e.getCause() && e.getCause() instanceof BundleNotFoundException) { - throw new IllegalStateException("[" + distributionFile.getName() + "]"); + // This application exception indicates the special token handling workflow + throw new BundleNotFoundException("[" + distributionFile.getName() + "]"); } else { throw e; } @@ -740,7 +742,8 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot } catch (PermissionException e) { if (null != e.getCause() && e.getCause() instanceof BundleNotFoundException) { deleteFile = false; - throw new IllegalStateException("[" + file.getName() + "]"); + // This application exception indicates the special token handling workflow + throw new BundleNotFoundException("[" + file.getName() + "]"); } else { throw e; } diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleNotFoundException.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleNotFoundException.java deleted file mode 100644 index 0563832..0000000 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleNotFoundException.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2013 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.server.bundle; - -import javax.ejb.ApplicationException; - -/** - * Indicates a required RHQ bundle did not exist. Note, we intentionally do not provide - * constructors that take a cause, since the three screen long Hibernate stack trace doesn't add any value here.<br/> - * Declare this an {@link ApplicationException} because we don't want these to be wrapped or to rollback an ongoing - * transaction. - */ -@ApplicationException(rollback = false, inherited = true) -public class BundleNotFoundException extends RuntimeException { - private static final long serialVersionUID = 1L; - - // Default no-arg constructor required by JAXB - public BundleNotFoundException() { - } - - /** - * Create an exception indicating the resource with the specified id was not found. - * - * @param bundleId a bundle id - */ - public BundleNotFoundException(int bundleId) { - super("A Bundle with id " + bundleId + " does not exist."); - } - - public BundleNotFoundException(String message) { - super(message); - } -} \ No newline at end of file
rhq-commits@lists.fedorahosted.org