Search in sources :

Example 11 with RestApi

use of com.google.gerrit.client.rpc.RestApi in project gerrit by GerritCodeReview.

the class ChangeApi method createChange.

/**
   * Create a new change.
   *
   * <p>The new change is created as DRAFT unless the draft workflow is disabled by
   * `change.allowDrafts = false` in the configuration, in which case the new change is created as
   * NEW.
   */
public static void createChange(String project, String branch, String topic, String subject, String base, AsyncCallback<ChangeInfo> cb) {
    CreateChangeInput input = CreateChangeInput.create();
    input.project(emptyToNull(project));
    input.branch(emptyToNull(branch));
    input.topic(emptyToNull(topic));
    input.subject(emptyToNull(subject));
    input.baseChange(emptyToNull(base));
    if (Gerrit.info().change().allowDrafts()) {
        input.status(Change.Status.DRAFT.toString());
    }
    new RestApi("/changes/").post(input, cb);
}
Also used : RestApi(com.google.gerrit.client.rpc.RestApi)

Example 12 with RestApi

use of com.google.gerrit.client.rpc.RestApi in project gerrit by GerritCodeReview.

the class ChangeList method query.

public static void query(String query, Set<ListChangesOption> options, AsyncCallback<ChangeList> callback, int start, int limit) {
    RestApi call = newQuery(query);
    if (limit > 0) {
        call.addParameter("n", limit);
    }
    addOptions(call, options);
    if (start != 0) {
        call.addParameter("S", start);
    }
    call.get(callback);
}
Also used : RestApi(com.google.gerrit.client.rpc.RestApi)

Example 13 with RestApi

use of com.google.gerrit.client.rpc.RestApi in project gerrit by GerritCodeReview.

the class ChangeList method queryMultiple.

/** Run multiple queries in a single remote invocation. */
public static void queryMultiple(final AsyncCallback<JsArray<ChangeList>> callback, Set<ListChangesOption> options, String... queries) {
    if (queries.length == 0) {
        return;
    }
    RestApi call = new RestApi(URI);
    for (String q : queries) {
        call.addParameterRaw("q", KeyUtil.encode(q));
    }
    addOptions(call, options);
    if (queries.length == 1) {
        // Server unwraps a single query, so wrap it back in an array for the
        // callback.
        call.get(new AsyncCallback<ChangeList>() {

            @Override
            public void onSuccess(ChangeList result) {
                JsArray<ChangeList> wrapped = JsArray.createArray(1).cast();
                wrapped.set(0, result);
                callback.onSuccess(wrapped);
            }

            @Override
            public void onFailure(Throwable caught) {
                callback.onFailure(caught);
            }
        });
    } else {
        call.get(callback);
    }
}
Also used : JsArray(com.google.gwt.core.client.JsArray) RestApi(com.google.gerrit.client.rpc.RestApi)

Example 14 with RestApi

use of com.google.gerrit.client.rpc.RestApi in project gerrit by GerritCodeReview.

the class StarredChanges method startRequest.

private static void startRequest() {
    busy = true;
    final Change.Id id = pending.keySet().iterator().next();
    final boolean starred = pending.remove(id);
    RestApi call = AccountApi.self().view("starred.changes").id(id.get());
    AsyncCallback<JavaScriptObject> cb = new AsyncCallback<JavaScriptObject>() {

        @Override
        public void onSuccess(JavaScriptObject none) {
            if (pending.isEmpty()) {
                busy = false;
            } else {
                startRequest();
            }
        }

        @Override
        public void onFailure(Throwable caught) {
            if (!starred && RestApi.isStatus(caught, 404)) {
                onSuccess(null);
                return;
            }
            fireChangeStarEvent(id, !starred);
            for (Map.Entry<Change.Id, Boolean> e : pending.entrySet()) {
                fireChangeStarEvent(e.getKey(), !e.getValue());
            }
            pending.clear();
            busy = false;
        }
    };
    if (starred) {
        call.put(cb);
    } else {
        call.delete(cb);
    }
}
Also used : RestApi(com.google.gerrit.client.rpc.RestApi) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) Change(com.google.gerrit.reviewdb.client.Change) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 15 with RestApi

use of com.google.gerrit.client.rpc.RestApi in project gerrit by GerritCodeReview.

the class ConfigServerApi method confirmEmail.

public static void confirmEmail(String token, AsyncCallback<VoidResult> cb) {
    EmailConfirmationInput input = EmailConfirmationInput.create();
    input.setToken(token);
    new RestApi("/config/server/email.confirm").put(input, cb);
}
Also used : RestApi(com.google.gerrit.client.rpc.RestApi)

Aggregations

RestApi (com.google.gerrit.client.rpc.RestApi)42 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)8 ChangeInfo (com.google.gerrit.client.info.ChangeInfo)3 EditInfo (com.google.gerrit.client.info.ChangeInfo.EditInfo)2 CallbackGroup (com.google.gerrit.client.rpc.CallbackGroup)2 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)2 Anchor (com.google.gwt.user.client.ui.Anchor)2 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)2 InlineLabel (com.google.gwt.user.client.ui.InlineLabel)2 ArrayList (java.util.ArrayList)2 GerritUiExtensionPoint (com.google.gerrit.client.GerritUiExtensionPoint)1 ActionInfo (com.google.gerrit.client.info.ActionInfo)1 RevisionInfo (com.google.gerrit.client.info.ChangeInfo.RevisionInfo)1 GerritCallback (com.google.gerrit.client.rpc.GerritCallback)1 NativeMap (com.google.gerrit.client.rpc.NativeMap)1 NativeString (com.google.gerrit.client.rpc.NativeString)1 ListChangesOption (com.google.gerrit.extensions.client.ListChangesOption)1 Change (com.google.gerrit.reviewdb.client.Change)1 Project (com.google.gerrit.reviewdb.client.Project)1 JsArray (com.google.gwt.core.client.JsArray)1