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

PAYARA-970 Validation on Request Tracing service "thresholdUnit" value. #1007

Merged
merged 1 commit into from
Aug 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,24 @@ private boolean validate(ActionReport actionReport) {
}

}

if (unit != null) {
try {
if (!unit.equals("NANOSECONDS")
&& !unit.equals("MICROSECONDS")
&& !unit.equals("MILLISECONDS")
&& !unit.equals("SECONDS")
&& !unit.equals("MINUTES")
&& !unit.equals("HOURS")
&& !unit.equals("DAYS")) {
actionReport.failure(logger, unit + " is an invalid time unit");
return result;
}
} catch (IllegalArgumentException iaf) {
actionReport.failure(logger, unit + " is an invalid time unit", iaf);
return result;
}
}

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ and Distribution License("CDDL") (collectively, the "License"). You
import org.glassfish.hk2.api.ServiceLocator;

/**
* Admin command to enable/disable all request tracing services defined in domain.xml.
* Admin command to enable/disable all request tracing services defined in
* domain.xml.
*
* @author mertcaliskan
*/
Expand Down Expand Up @@ -86,7 +87,7 @@ public class RequestTracingConfigurerDas implements AdminCommand {
@Param(name = "thresholdUnit", optional = true, defaultValue = "SECONDS")
private String unit;

@Param(name = "thresholdValue", optional = true, defaultValue = "10")
@Param(name = "thresholdValue", optional = true, defaultValue = "30")
private String value;

@Inject
Expand Down Expand Up @@ -175,6 +176,24 @@ private boolean validate(ActionReport actionReport) {

}

if (unit != null) {
try {
if (!unit.equals("NANOSECONDS")
&& !unit.equals("MICROSECONDS")
&& !unit.equals("MILLISECONDS")
&& !unit.equals("SECONDS")
&& !unit.equals("MINUTES")
&& !unit.equals("HOURS")
&& !unit.equals("DAYS")) {
actionReport.failure(logger, unit + " is an invalid time unit");
return result;
}
} catch (IllegalArgumentException iaf) {
actionReport.failure(logger, unit + " is an invalid time unit", iaf);
return result;
}
}

return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -158,20 +158,18 @@ private void enableRequestTracingNotifierConfigurerOnTarget(ActionReport actionR
inv = runner.getCommandInvocation("requesttracing-configure-notifier", subReport, context.getSubject());
}

ParameterMap params = new ParameterMap();
params.add("dynamic", notifierDynamic.toString());
params.add("target", target);
params.add("notifierName", notifierName);
params.add("notifierEnabled", enabled.toString());
inv.parameters(params);
inv.execute();
// swallow the offline warning as it is not a problem
if (subReport.hasWarnings()) {
subReport.setMessage("");
}
ParameterMap params = new ParameterMap();
params.add("dynamic", notifierDynamic.toString());
params.add("target", target);
params.add("notifierName", notifierName);
params.add("notifierEnabled", enabled.toString());
inv.parameters(params);
inv.execute();
// swallow the offline warning as it is not a problem
if (subReport.hasWarnings()) {
subReport.setMessage("");
}


}

private boolean validate(ActionReport actionReport) {
boolean result = false;
Expand All @@ -189,6 +187,24 @@ private boolean validate(ActionReport actionReport) {

}

if (unit != null) {
try {
if (!unit.equals("NANOSECONDS")
&& !unit.equals("MICROSECONDS")
&& !unit.equals("MILLISECONDS")
&& !unit.equals("SECONDS")
&& !unit.equals("MINUTES")
&& !unit.equals("HOURS")
&& !unit.equals("DAYS")) {
actionReport.failure(logger, unit + " is an invalid time unit");
return result;
}
} catch (IllegalArgumentException iaf) {
actionReport.failure(logger, unit + " is an invalid time unit", iaf);
return result;
}
}

return true;
}
}