提交 77a97460 编写于 作者: K Kohsuke Kawaguchi

various trivial nit-picking

上级 83bc1142
......@@ -474,8 +474,7 @@ public class Util {
}
public static String nullify(String v) {
if(v!=null && v.length()==0) v=null;
return v;
return fixEmpty(v);
}
public static String removeTrailingSlash(String s) {
......
......@@ -153,7 +153,7 @@ public abstract class AbstractItem extends Actionable implements Item, HttpDelet
}
public void setDisplayName(String displayName) throws IOException {
this.displayName = displayName;
this.displayName = Util.fixEmpty(displayName);
save();
}
......
......@@ -941,21 +941,6 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
return null;
}
/**
* Takes the displayName request parameter and sets it into the the
* displayName member variable. If the displayName request parameter is a
* 0 length string, then set the displayName member variable to null.
* @param req
* @throws IOException
*/
void setDisplayNameFromRequest(StaplerRequest req) throws IOException {
String displayName = req.getParameter("displayName");
// if displayName is an empty string, just make it null so that we
// use the project name
displayName = Util.nullify(displayName);
setDisplayName(displayName);
}
//
//
// actions
......@@ -973,11 +958,11 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
keepDependencies = req.getParameter("keepDependencies") != null;
setDisplayNameFromRequest(req);
try {
JSONObject json = req.getSubmittedForm();
setDisplayName(json.optString("displayNameOrNull"));
if (req.getParameter("logrotate") != null)
logRotator = LogRotator.DESCRIPTOR.newInstance(req,json.getJSONObject("logrotate"));
else
......
......@@ -64,9 +64,8 @@ THE SOFTWARE.
<p:config-blockWhenUpstreamBuilding />
<p:config-blockWhenDownstreamBuilding />
<st:include page="configure-advanced.jelly" optional="true" />
<f:entry title="${%Display Name}" help="/help/project-config/displayName.html">
<f:textbox name="displayName" value="${it.displayNameOrNull}"
checkUrl="'${rootURL}/checkDisplayName?displayName='+escape(this.value)+'&amp;jobName=${it.name}'"/>
<f:entry title="${%Display Name}" field="displayNameOrNull">
<f:textbox checkUrl="'${rootURL}/checkDisplayName?displayName='+escape(this.value)+'&amp;jobName=${it.name}'"/>
</f:entry>
</f:advanced>
......
......@@ -15,13 +15,10 @@ public class JobTest {
@Test
public void testSetDisplayName() throws Exception {
final String displayName = "testSetDisplayName";
// create a mock stapler request that returns a display name
StaplerRequest req = Mockito.mock(StaplerRequest.class);
Mockito.when(req.getParameter(DISPLAY_NAME_PARAMETER_NAME)).thenReturn(displayName);
StubJob j = new StubJob();
// call setDisplayNameFromRequest
j.setDisplayNameFromRequest(req);
j.setDisplayNameOrNull(displayName);
// make sure the displayname has been set
Assert.assertEquals(displayName, j.getDisplayName());
......@@ -29,14 +26,10 @@ public class JobTest {
@Test
public void testSetDisplayNameZeroLength() throws Exception {
// create a mock stapler request that returns a ""
StaplerRequest req = Mockito.mock(StaplerRequest.class);
Mockito.when(req.getParameter(DISPLAY_NAME_PARAMETER_NAME)).thenReturn("");
StubJob j = new StubJob();
StubJob j = new StubJob();
// call setDisplayNameFromRequest
j.setDisplayNameFromRequest(req);
j.setDisplayNameOrNull("");
// make sure the getDisplayName returns the project name
Assert.assertEquals(StubJob.DEFAULT_STUB_JOB_NAME, j.getDisplayName());
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册