Skip to content

Commit

Permalink
fixes for some cosmetic and validation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
EricWittmann committed Jan 29, 2015
1 parent 1e03da9 commit 8f45f70
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 20 deletions.
Expand Up @@ -32,4 +32,12 @@ public static final String idFromName(String name) {
return name.replaceAll("[^\\w-\\.]", ""); //$NON-NLS-1$ //$NON-NLS-2$
}

/**
* Validates that a version string is OK - doesn't contain any
* illegal characters.
* @param version
*/
public static final boolean isValidVersion(String version) {
return idFromName(version).equals(version);
}
}
Expand Up @@ -15,8 +15,6 @@
*/
package io.apiman.manager.api.beans;

import io.apiman.manager.api.beans.BeanUtils;

import org.junit.Assert;
import org.junit.Test;

Expand All @@ -39,6 +37,10 @@ public void testIdFromName() {
assertIdFromName("Red--Hat", "!Red--Hat?");
assertIdFromName("Org.With.Periods", "Org.With.Periods");
assertIdFromName("my-project", "my-project");
assertIdFromName("MyInjectionimgsrca.fsdn.comsdtopicsspace_64.pngaltSpacetitleSpaceheight64width64",
"My Injection: <img src=\\\"//a.fsdn.com/sd/topics/space_64.png\\\" alt=\\\"Space\\\" title=\\\"Space\\\" height=\\\"64\\\" width=\\\"64\\\">");
assertIdFromName("1.0.7-SNAPSHOT", "1.0.7-SNAPSHOT");
assertIdFromName("2.1.0_Final", "2.1.0_Final");
}

/**
Expand Down
Expand Up @@ -478,6 +478,10 @@ public ApplicationVersionBean createAppVersion(String organizationId, String app
*/
protected ApplicationVersionBean createAppVersionInternal(NewApplicationVersionBean bean,
ApplicationBean application) throws StorageException {
if (!BeanUtils.isValidVersion(bean.getVersion())) {
throw new StorageException("Invalid/illegal application version: " + bean.getVersion()); //$NON-NLS-1$
}

ApplicationVersionBean newVersion = new ApplicationVersionBean();
newVersion.setApplication(application);
newVersion.setCreatedBy(securityContext.getCurrentUser());
Expand Down Expand Up @@ -1157,6 +1161,9 @@ public ServiceVersionBean createServiceVersion(String organizationId, String ser
*/
protected ServiceVersionBean createServiceVersionInternal(NewServiceVersionBean bean,
ServiceBean service, GatewaySummaryBean gateway) throws Exception, StorageException {
if (!BeanUtils.isValidVersion(bean.getVersion())) {
throw new StorageException("Invalid/illegal service version: " + bean.getVersion()); //$NON-NLS-1$
}

ServiceVersionBean newVersion = new ServiceVersionBean();
newVersion.setCreatedBy(securityContext.getCurrentUser());
Expand Down Expand Up @@ -1826,6 +1833,10 @@ public PlanVersionBean createPlanVersion(String organizationId, String planId, N
*/
protected PlanVersionBean createPlanVersionInternal(NewPlanVersionBean bean, PlanBean plan)
throws StorageException {
if (!BeanUtils.isValidVersion(bean.getVersion())) {
throw new StorageException("Invalid/illegal plan version: " + bean.getVersion()); //$NON-NLS-1$
}

PlanVersionBean newVersion = new PlanVersionBean();
newVersion.setCreatedBy(securityContext.getCurrentUser());
newVersion.setCreatedOn(new Date());
Expand Down
Expand Up @@ -53,7 +53,7 @@ public class AppMessages {
public static final String TITLE_NEW_PLAN_VERSION = "page.title.new-plan-version";
@TranslationKey(defaultValue = "apiman - New Contract")
public static final String TITLE_NEW_CONTRACT = "page.title.new-contract";
@TranslationKey(defaultValue = "apiman - New Policy")
@TranslationKey(defaultValue = "apiman - Add Policy")
public static final String TITLE_NEW_POLICY = "page.title.new-policy";
@TranslationKey(defaultValue = "apiman - Edit Policy")
public static final String TITLE_EDIT_POLICY = "page.title.edit-policy";
Expand Down Expand Up @@ -264,7 +264,7 @@ public class AppMessages {

@TranslationKey(defaultValue = "No policies matched the filter criteria. Please try modifying the filter or else create a new policy using the button above.")
public static final String NO_FILTERED_POLICIES_MESSAGE = "no-filtered-policies";
@TranslationKey(defaultValue = "It looks like there aren't (yet) any policies defined! That may be exactly what you want (of course) but if not, you may try defining one using the New Policy button above...")
@TranslationKey(defaultValue = "It looks like there aren't (yet) any policies defined! That may be exactly what you want (of course) but if not, you may try defining one using the Add Policy button above...")
public static final String NO_POLICIES_MESSAGE = "no-policies";
@TranslationKey(defaultValue = "Policy created by")
public static final String POLICY_CREATED_BY = "policy-created-by";
Expand Down Expand Up @@ -563,4 +563,15 @@ public class AppMessages {
@TranslationKey(defaultValue = "Click for additional details about this Service.")
public static String API_MORE_INFO = "app-apis.more-info-about-service";

@TranslationKey(defaultValue = "Locks the Plan so that it can be used in your Services. Once locked, the Plan is final and cannot be modified.")
public static final String LOCK_PLAN_TOOLTIP = "lock-plan.tooltip";
@TranslationKey(defaultValue = "Publishes the Service to the Gateway, making it available to be consumed. Until published, a Service is not available to invoke or create a contract with.")
public static final String PUBLISH_TOOLTIP = "publish.tooltip";
@TranslationKey(defaultValue = "Retires the Service, removing it from the Gateway and breaking any existing consumers.")
public static final String RETIRE_TOOLTIP = "retire.tooltip";
@TranslationKey(defaultValue = "Registers the Application with the Gateway, making it possible to invoke its contracted Services.")
public static final String REGISTER_TOOLTIP = "register.tooltip";
@TranslationKey(defaultValue = "Removes the Application from the Gateway, making it no longer possible to invoke its Services.")
public static final String UNREGISTER_TOOLTIP = "unregister.tooltip";

}
Expand Up @@ -283,6 +283,9 @@ protected void renderPage() {
renderApplicationStatus();

description.setEnabled(hasPermission(PermissionType.appEdit));

registerButton.setTitle(i18n.format(AppMessages.REGISTER_TOOLTIP));
unregisterButton.setTitle(i18n.format(AppMessages.UNREGISTER_TOOLTIP));
}

/**
Expand Down
Expand Up @@ -259,6 +259,8 @@ protected void renderPage() {
createdBy.setHref(toUserHref);

description.setEnabled(hasPermission(PermissionType.planEdit));

lockButton.setTitle(i18n.format(AppMessages.LOCK_PLAN_TOOLTIP));
}

/**
Expand Down
Expand Up @@ -285,6 +285,9 @@ protected void renderPage() {
renderServiceStatus();

description.setEnabled(hasPermission(PermissionType.svcEdit));

publishButton.setTitle(i18n.format(AppMessages.PUBLISH_TOOLTIP));
retireButton.setTitle(i18n.format(AppMessages.RETIRE_TOOLTIP));
}

/**
Expand Down
Expand Up @@ -70,8 +70,6 @@ public class OrgManageMembersPage extends AbstractPage {
@Inject @DataField
Breadcrumb breadcrumb;

@Inject @DataField
Anchor organization;
@Inject @DataField
TextBox searchBox;
@Inject @DataField
Expand Down Expand Up @@ -174,7 +172,6 @@ protected void renderPage() {
super.renderPage();

String orgMembersHref = navHelper.createHrefToPage(OrgMembersPage.class, MultimapUtil.singleItemMap("org", org)); //$NON-NLS-1$
organization.setHref(orgMembersHref);
String newMemberHref = navHelper.createHrefToPage(NewMemberPage.class, MultimapUtil.singleItemMap("org", org)); //$NON-NLS-1$
addMember.setHref(newMemberHref);

Expand Down
Expand Up @@ -51,19 +51,6 @@
</ol>
</div>
</div>
<div class="row">
<div class="col-md-12 apiman-entity-breadcrumb">
<div class="title container-fluid">
<div class="org">
<a data-field="organization" href="org-apps.html" data-role="dummy">JBoss Overlord</a>
</div>
<div class="divider" data-role="dummy"> :: </div>
<div class="entity">
<span data-i18n-key="manage-members">Manage Members</span>
</div>
</div>
</div>
</div>
<div class="row">
<div class="apiman-divider-20"></div>
</div>
Expand Down

0 comments on commit 8f45f70

Please sign in to comment.