提交 afe303bc 编写于 作者: K kohsuke

exposing more objects and properties.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@3043 71c3de6d-444a-0410-be80-ed276b4c234a
上级 e01074b2
...@@ -179,6 +179,7 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs ...@@ -179,6 +179,7 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
* *
* @return never null. * @return never null.
*/ */
@Exposed
public ChangeLogSet<? extends Entry> getChangeSet() { public ChangeLogSet<? extends Entry> getChangeSet() {
if(scm==null) if(scm==null)
scm = new CVSChangeLogParser(); scm = new CVSChangeLogParser();
......
...@@ -197,6 +197,7 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run ...@@ -197,6 +197,7 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
/** /**
* Returns true if the build is not completed yet. * Returns true if the build is not completed yet.
*/ */
@Exposed
public boolean isBuilding() { public boolean isBuilding() {
return state!=State.COMPLETED; return state!=State.COMPLETED;
} }
...@@ -220,6 +221,7 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run ...@@ -220,6 +221,7 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
* *
* This is used as a signal to the {@link LogRotator}. * This is used as a signal to the {@link LogRotator}.
*/ */
@Exposed
public final boolean isKeepLog() { public final boolean isKeepLog() {
return getWhyKeepLog()!=null; return getWhyKeepLog()!=null;
} }
...@@ -249,6 +251,7 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run ...@@ -249,6 +251,7 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
return timestamp; return timestamp;
} }
@Exposed
public String getDescription() { public String getDescription() {
return description; return description;
} }
......
...@@ -4,6 +4,7 @@ import hudson.model.AbstractBuild; ...@@ -4,6 +4,7 @@ import hudson.model.AbstractBuild;
import hudson.model.User; import hudson.model.User;
import hudson.scm.CVSChangeLogSet.CVSChangeLog; import hudson.scm.CVSChangeLogSet.CVSChangeLog;
import hudson.util.IOException2; import hudson.util.IOException2;
import hudson.api.Exposed;
import org.apache.commons.digester.Digester; import org.apache.commons.digester.Digester;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
...@@ -125,6 +126,7 @@ public final class CVSChangeLogSet extends ChangeLogSet<CVSChangeLog> { ...@@ -125,6 +126,7 @@ public final class CVSChangeLogSet extends ChangeLogSet<CVSChangeLog> {
f.parent = this; f.parent = this;
} }
@Exposed
public String getDate() { public String getDate() {
return date; return date;
} }
...@@ -133,6 +135,7 @@ public final class CVSChangeLogSet extends ChangeLogSet<CVSChangeLog> { ...@@ -133,6 +135,7 @@ public final class CVSChangeLogSet extends ChangeLogSet<CVSChangeLog> {
this.date = date; this.date = date;
} }
@Exposed
public String getTime() { public String getTime() {
return time; return time;
} }
...@@ -141,6 +144,7 @@ public final class CVSChangeLogSet extends ChangeLogSet<CVSChangeLog> { ...@@ -141,6 +144,7 @@ public final class CVSChangeLogSet extends ChangeLogSet<CVSChangeLog> {
this.time = time; this.time = time;
} }
@Exposed
public User getAuthor() { public User getAuthor() {
return author; return author;
} }
...@@ -161,10 +165,12 @@ public final class CVSChangeLogSet extends ChangeLogSet<CVSChangeLog> { ...@@ -161,10 +165,12 @@ public final class CVSChangeLogSet extends ChangeLogSet<CVSChangeLog> {
this.author = User.get(author); this.author = User.get(author);
} }
@Exposed
public String getUser() {// digester wants read/write property, even though it never reads. Duh. public String getUser() {// digester wants read/write property, even though it never reads. Duh.
return author.getDisplayName(); return author.getDisplayName();
} }
@Exposed
public String getMsg() { public String getMsg() {
return msg; return msg;
} }
...@@ -178,6 +184,7 @@ public final class CVSChangeLogSet extends ChangeLogSet<CVSChangeLog> { ...@@ -178,6 +184,7 @@ public final class CVSChangeLogSet extends ChangeLogSet<CVSChangeLog> {
files.add(f); files.add(f);
} }
@Exposed
public List<File> getFiles() { public List<File> getFiles() {
return files; return files;
} }
...@@ -198,6 +205,7 @@ public final class CVSChangeLogSet extends ChangeLogSet<CVSChangeLog> { ...@@ -198,6 +205,7 @@ public final class CVSChangeLogSet extends ChangeLogSet<CVSChangeLog> {
* <p> * <p>
* The path is relative to the workspace root. * The path is relative to the workspace root.
*/ */
@Exposed
public String getName() { public String getName() {
return name; return name;
} }
...@@ -210,6 +218,7 @@ public final class CVSChangeLogSet extends ChangeLogSet<CVSChangeLog> { ...@@ -210,6 +218,7 @@ public final class CVSChangeLogSet extends ChangeLogSet<CVSChangeLog> {
* Unlike {@link #getName()}, this method returns * Unlike {@link #getName()}, this method returns
* a full name from the root of the CVS repository. * a full name from the root of the CVS repository.
*/ */
@Exposed
public String getFullName() { public String getFullName() {
if(fullName==null) { if(fullName==null) {
// Hudson < 1.91 doesn't record full path name for CVS, // Hudson < 1.91 doesn't record full path name for CVS,
...@@ -250,6 +259,7 @@ public final class CVSChangeLogSet extends ChangeLogSet<CVSChangeLog> { ...@@ -250,6 +259,7 @@ public final class CVSChangeLogSet extends ChangeLogSet<CVSChangeLog> {
this.name = name; this.name = name;
} }
@Exposed
public String getRevision() { public String getRevision() {
return revision; return revision;
} }
...@@ -258,6 +268,7 @@ public final class CVSChangeLogSet extends ChangeLogSet<CVSChangeLog> { ...@@ -258,6 +268,7 @@ public final class CVSChangeLogSet extends ChangeLogSet<CVSChangeLog> {
this.revision = revision; this.revision = revision;
} }
@Exposed
public String getPrevrevision() { public String getPrevrevision() {
return prevrevision; return prevrevision;
} }
...@@ -266,6 +277,7 @@ public final class CVSChangeLogSet extends ChangeLogSet<CVSChangeLog> { ...@@ -266,6 +277,7 @@ public final class CVSChangeLogSet extends ChangeLogSet<CVSChangeLog> {
this.prevrevision = prevrevision; this.prevrevision = prevrevision;
} }
@Exposed
public boolean isDead() { public boolean isDead() {
return dead; return dead;
} }
...@@ -274,6 +286,7 @@ public final class CVSChangeLogSet extends ChangeLogSet<CVSChangeLog> { ...@@ -274,6 +286,7 @@ public final class CVSChangeLogSet extends ChangeLogSet<CVSChangeLog> {
this.dead = true; this.dead = true;
} }
@Exposed
public EditType getEditType() { public EditType getEditType() {
// see issue #73. Can't do much better right now // see issue #73. Can't do much better right now
if(dead) if(dead)
......
...@@ -2,11 +2,15 @@ package hudson.scm; ...@@ -2,11 +2,15 @@ package hudson.scm;
import hudson.MarkupText; import hudson.MarkupText;
import hudson.Util; import hudson.Util;
import hudson.api.ExposedBean;
import hudson.api.Exposed;
import hudson.model.AbstractBuild; import hudson.model.AbstractBuild;
import hudson.model.User; import hudson.model.User;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List;
import java.util.ArrayList;
/** /**
* Represents SCM change list. * Represents SCM change list.
...@@ -16,6 +20,7 @@ import java.util.Collections; ...@@ -16,6 +20,7 @@ import java.util.Collections;
* *
* @author Kohsuke Kawaguchi * @author Kohsuke Kawaguchi
*/ */
@ExposedBean
public abstract class ChangeLogSet<T extends ChangeLogSet.Entry> implements Iterable<T> { public abstract class ChangeLogSet<T extends ChangeLogSet.Entry> implements Iterable<T> {
/** /**
...@@ -32,6 +37,18 @@ public abstract class ChangeLogSet<T extends ChangeLogSet.Entry> implements Iter ...@@ -32,6 +37,18 @@ public abstract class ChangeLogSet<T extends ChangeLogSet.Entry> implements Iter
*/ */
public abstract boolean isEmptySet(); public abstract boolean isEmptySet();
/**
* All changes in the change set.
*/
// method for the remote API.
@Exposed
public final Object[] getItems() {
List<T> r = new ArrayList<T>();
for (T t : this)
r.add(t);
return r.toArray();
}
/** /**
* Constant instance that represents no changes. * Constant instance that represents no changes.
*/ */
...@@ -39,6 +56,7 @@ public abstract class ChangeLogSet<T extends ChangeLogSet.Entry> implements Iter ...@@ -39,6 +56,7 @@ public abstract class ChangeLogSet<T extends ChangeLogSet.Entry> implements Iter
return new CVSChangeLogSet(build,Collections.<CVSChangeLogSet.CVSChangeLog>emptyList()); return new CVSChangeLogSet(build,Collections.<CVSChangeLogSet.CVSChangeLog>emptyList());
} }
@ExposedBean
public static abstract class Entry { public static abstract class Entry {
private ChangeLogSet parent; private ChangeLogSet parent;
......
package hudson.scm; package hudson.scm;
import hudson.api.CustomExposureBean;
/** /**
* Designates the SCM operation. * Designates the SCM operation.
* *
* @author Kohsuke Kawaguchi * @author Kohsuke Kawaguchi
*/ */
public final class EditType { public final class EditType implements CustomExposureBean {
private String name; private String name;
private String description; private String description;
...@@ -22,6 +24,10 @@ public final class EditType { ...@@ -22,6 +24,10 @@ public final class EditType {
return description; return description;
} }
public Object toExposedObject() {
return name;
}
public static final EditType ADD = new EditType("add","The file was added"); public static final EditType ADD = new EditType("add","The file was added");
public static final EditType EDIT = new EditType("edit","The file was modified"); public static final EditType EDIT = new EditType("edit","The file was modified");
public static final EditType DELETE = new EditType("delete","The file was removed"); public static final EditType DELETE = new EditType("delete","The file was removed");
......
...@@ -3,6 +3,7 @@ package hudson.scm; ...@@ -3,6 +3,7 @@ package hudson.scm;
import hudson.model.AbstractBuild; import hudson.model.AbstractBuild;
import hudson.model.User; import hudson.model.User;
import hudson.scm.SubversionChangeLogSet.LogEntry; import hudson.scm.SubversionChangeLogSet.LogEntry;
import hudson.api.Exposed;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -79,6 +80,7 @@ public final class SubversionChangeLogSet extends ChangeLogSet<LogEntry> { ...@@ -79,6 +80,7 @@ public final class SubversionChangeLogSet extends ChangeLogSet<LogEntry> {
* If the commit made the repository revision 1532, this * If the commit made the repository revision 1532, this
* method returns 1532. * method returns 1532.
*/ */
@Exposed
public int getRevision() { public int getRevision() {
return revision; return revision;
} }
...@@ -108,10 +110,12 @@ public final class SubversionChangeLogSet extends ChangeLogSet<LogEntry> { ...@@ -108,10 +110,12 @@ public final class SubversionChangeLogSet extends ChangeLogSet<LogEntry> {
this.author = User.get(author); this.author = User.get(author);
} }
@Exposed
public String getUser() {// digester wants read/write property, even though it never reads. Duh. public String getUser() {// digester wants read/write property, even though it never reads. Duh.
return author.getDisplayName(); return author.getDisplayName();
} }
@Exposed
public String getDate() { public String getDate() {
return date; return date;
} }
...@@ -120,7 +124,7 @@ public final class SubversionChangeLogSet extends ChangeLogSet<LogEntry> { ...@@ -120,7 +124,7 @@ public final class SubversionChangeLogSet extends ChangeLogSet<LogEntry> {
this.date = date; this.date = date;
} }
@Override @Override @Exposed
public String getMsg() { public String getMsg() {
return msg; return msg;
} }
...@@ -139,6 +143,7 @@ public final class SubversionChangeLogSet extends ChangeLogSet<LogEntry> { ...@@ -139,6 +143,7 @@ public final class SubversionChangeLogSet extends ChangeLogSet<LogEntry> {
* @return * @return
* can be empty but never null. * can be empty but never null.
*/ */
@Exposed
public List<Path> getPaths() { public List<Path> getPaths() {
return paths; return paths;
} }
...@@ -169,6 +174,7 @@ public final class SubversionChangeLogSet extends ChangeLogSet<LogEntry> { ...@@ -169,6 +174,7 @@ public final class SubversionChangeLogSet extends ChangeLogSet<LogEntry> {
/** /**
* Path in the repository. Such as <tt>/test/trunk/foo.c</tt> * Path in the repository. Such as <tt>/test/trunk/foo.c</tt>
*/ */
@Exposed(name="path")
public String getValue() { public String getValue() {
return value; return value;
} }
...@@ -177,6 +183,7 @@ public final class SubversionChangeLogSet extends ChangeLogSet<LogEntry> { ...@@ -177,6 +183,7 @@ public final class SubversionChangeLogSet extends ChangeLogSet<LogEntry> {
this.value = value; this.value = value;
} }
@Exposed
public EditType getEditType() { public EditType getEditType() {
if( action=='A' ) if( action=='A' )
return EditType.ADD; return EditType.ADD;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册