Merge changes Id5a40c39,Ifd32fd7f
* changes: Remove duplication of DELETE endpoint with POST for draft changes Add support for plugin REST endpoints without view names
This commit is contained in:
@@ -956,8 +956,6 @@ Delete Draft Change
|
|||||||
~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~
|
||||||
[verse]
|
[verse]
|
||||||
'DELETE /changes/link:#change-id[\{change-id\}]'
|
'DELETE /changes/link:#change-id[\{change-id\}]'
|
||||||
or
|
|
||||||
'POST /changes/link:#change-id[\{change-id\}]/delete'
|
|
||||||
|
|
||||||
Deletes a draft change.
|
Deletes a draft change.
|
||||||
|
|
||||||
@@ -1568,8 +1566,6 @@ Delete Draft Revision
|
|||||||
~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~
|
||||||
[verse]
|
[verse]
|
||||||
'DELETE /changes/link:#change-id[\{change-id\}]/revisions/link:#revision-id[\{revision-id\}]'
|
'DELETE /changes/link:#change-id[\{change-id\}]/revisions/link:#revision-id[\{revision-id\}]'
|
||||||
or
|
|
||||||
'POST /changes/link:#change-id[\{change-id\}]/revisions/link:#revision-id[\{revision-id\}]/delete'
|
|
||||||
|
|
||||||
Deletes a draft revision.
|
Deletes a draft revision.
|
||||||
|
|
||||||
|
@@ -788,8 +788,12 @@ public class RestApiServlet extends HttpServlet {
|
|||||||
|
|
||||||
List<String> p = splitProjection(projection);
|
List<String> p = splitProjection(projection);
|
||||||
if (p.size() == 2) {
|
if (p.size() == 2) {
|
||||||
|
String viewname = p.get(1);
|
||||||
|
if (Strings.isNullOrEmpty(viewname)) {
|
||||||
|
viewname = "/";
|
||||||
|
}
|
||||||
RestView<RestResource> view =
|
RestView<RestResource> view =
|
||||||
views.get(p.get(0), method + "." + p.get(1));
|
views.get(p.get(0), method + "." + viewname);
|
||||||
if (view != null) {
|
if (view != null) {
|
||||||
return new ViewData(p.get(0), view);
|
return new ViewData(p.get(0), view);
|
||||||
}
|
}
|
||||||
|
@@ -34,7 +34,8 @@ import com.google.inject.Provider;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class DeleteDraftChange implements RestModifyView<ChangeResource, Input> {
|
public class DeleteDraftChange implements
|
||||||
|
RestModifyView<ChangeResource, Input>, UiAction<ChangeResource> {
|
||||||
public static class Input {
|
public static class Input {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,15 +75,6 @@ public class DeleteDraftChange implements RestModifyView<ChangeResource, Input>
|
|||||||
return Response.none();
|
return Response.none();
|
||||||
}
|
}
|
||||||
|
|
||||||
static class Action extends DeleteDraftChange implements UiAction<ChangeResource> {
|
|
||||||
@Inject
|
|
||||||
public Action(Provider<ReviewDb> dbProvider,
|
|
||||||
GitRepositoryManager gitManager,
|
|
||||||
GitReferenceUpdated gitRefUpdated,
|
|
||||||
PatchSetInfoFactory patchSetInfoFactory) {
|
|
||||||
super(dbProvider, gitManager, gitRefUpdated, patchSetInfoFactory);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UiAction.Description getDescription(ChangeResource rsrc) {
|
public UiAction.Description getDescription(ChangeResource rsrc) {
|
||||||
try {
|
try {
|
||||||
@@ -95,5 +87,4 @@ public class DeleteDraftChange implements RestModifyView<ChangeResource, Input>
|
|||||||
throw new IllegalStateException(e);
|
throw new IllegalStateException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -38,7 +38,8 @@ import com.google.inject.Provider;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class DeleteDraftPatchSet implements RestModifyView<RevisionResource, Input> {
|
public class DeleteDraftPatchSet implements RestModifyView<RevisionResource, Input>,
|
||||||
|
UiAction<RevisionResource> {
|
||||||
public static class Input {
|
public static class Input {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,6 +81,24 @@ public class DeleteDraftPatchSet implements RestModifyView<RevisionResource, Inp
|
|||||||
return Response.none();
|
return Response.none();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UiAction.Description getDescription(RevisionResource rsrc) {
|
||||||
|
PatchSet.Id current = rsrc.getChange().currentPatchSetId();
|
||||||
|
try {
|
||||||
|
int psCount = dbProvider.get().patchSets()
|
||||||
|
.byChange(rsrc.getChange().getId()).toList().size();
|
||||||
|
return new UiAction.Description()
|
||||||
|
.setTitle(String.format("Delete Draft Revision %d",
|
||||||
|
rsrc.getPatchSet().getPatchSetId()))
|
||||||
|
.setVisible(rsrc.getPatchSet().isDraft()
|
||||||
|
&& rsrc.getPatchSet().getId().equals(current)
|
||||||
|
&& rsrc.getControl().canDeleteDraft(dbProvider.get())
|
||||||
|
&& psCount > 1);
|
||||||
|
} catch (OrmException e) {
|
||||||
|
throw new IllegalStateException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void deleteDraftPatchSet(PatchSet patchSet, Change change)
|
private void deleteDraftPatchSet(PatchSet patchSet, Change change)
|
||||||
throws ResourceNotFoundException, OrmException, IOException {
|
throws ResourceNotFoundException, OrmException, IOException {
|
||||||
try {
|
try {
|
||||||
@@ -139,32 +158,4 @@ public class DeleteDraftPatchSet implements RestModifyView<RevisionResource, Inp
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static class Action extends DeleteDraftPatchSet implements UiAction<RevisionResource> {
|
|
||||||
@Inject
|
|
||||||
public Action(Provider<ReviewDb> dbProvider,
|
|
||||||
GitRepositoryManager gitManager,
|
|
||||||
GitReferenceUpdated gitRefUpdated,
|
|
||||||
PatchSetInfoFactory patchSetInfoFactory) {
|
|
||||||
super(dbProvider, gitManager, gitRefUpdated, patchSetInfoFactory);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UiAction.Description getDescription(RevisionResource rsrc) {
|
|
||||||
PatchSet.Id current = rsrc.getChange().currentPatchSetId();
|
|
||||||
try {
|
|
||||||
int psCount = dbProvider.get().patchSets()
|
|
||||||
.byChange(rsrc.getChange().getId()).toList().size();
|
|
||||||
return new UiAction.Description()
|
|
||||||
.setTitle(String.format("Delete Draft Revision %d",
|
|
||||||
rsrc.getPatchSet().getPatchSetId()))
|
|
||||||
.setVisible(rsrc.getPatchSet().isDraft()
|
|
||||||
&& rsrc.getPatchSet().getId().equals(current)
|
|
||||||
&& rsrc.getControl().canDeleteDraft(dbProvider.get())
|
|
||||||
&& psCount > 1);
|
|
||||||
} catch (OrmException e) {
|
|
||||||
throw new IllegalStateException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -50,7 +50,6 @@ public class Module extends RestApiModule {
|
|||||||
put(CHANGE_KIND, "topic").to(PutTopic.class);
|
put(CHANGE_KIND, "topic").to(PutTopic.class);
|
||||||
delete(CHANGE_KIND, "topic").to(PutTopic.class);
|
delete(CHANGE_KIND, "topic").to(PutTopic.class);
|
||||||
delete(CHANGE_KIND).to(DeleteDraftChange.class);
|
delete(CHANGE_KIND).to(DeleteDraftChange.class);
|
||||||
post(CHANGE_KIND, "delete").to(DeleteDraftChange.Action.class);
|
|
||||||
post(CHANGE_KIND, "abandon").to(Abandon.class);
|
post(CHANGE_KIND, "abandon").to(Abandon.class);
|
||||||
post(CHANGE_KIND, "publish").to(Publish.CurrentRevision.class);
|
post(CHANGE_KIND, "publish").to(Publish.CurrentRevision.class);
|
||||||
post(CHANGE_KIND, "restore").to(Restore.class);
|
post(CHANGE_KIND, "restore").to(Restore.class);
|
||||||
@@ -68,7 +67,6 @@ public class Module extends RestApiModule {
|
|||||||
post(REVISION_KIND, "cherrypick").to(CherryPick.class);
|
post(REVISION_KIND, "cherrypick").to(CherryPick.class);
|
||||||
get(REVISION_KIND, "commit").to(GetCommit.class);
|
get(REVISION_KIND, "commit").to(GetCommit.class);
|
||||||
delete(REVISION_KIND).to(DeleteDraftPatchSet.class);
|
delete(REVISION_KIND).to(DeleteDraftPatchSet.class);
|
||||||
post(REVISION_KIND, "delete").to(DeleteDraftPatchSet.Action.class);
|
|
||||||
get(REVISION_KIND, "mergeable").to(Mergeable.class);
|
get(REVISION_KIND, "mergeable").to(Mergeable.class);
|
||||||
post(REVISION_KIND, "publish").to(Publish.class);
|
post(REVISION_KIND, "publish").to(Publish.class);
|
||||||
get(REVISION_KIND, "related").to(GetRelated.class);
|
get(REVISION_KIND, "related").to(GetRelated.class);
|
||||||
|
Reference in New Issue
Block a user