Skip to content

Commit

Permalink
Implement draft deletion API (support-project#1116)
Browse files Browse the repository at this point in the history
  • Loading branch information
y-okumura-isp committed Jun 19, 2021
1 parent b4608be commit a8b8d8d
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
import org.support.project.common.log.Log;
import org.support.project.common.log.LogFactory;
import org.support.project.common.util.PropertyUtil;
import org.support.project.common.util.StringUtils;
import org.support.project.di.DI;
import org.support.project.di.Instance;
import org.support.project.knowledge.dao.DraftItemValuesDao;
import org.support.project.knowledge.dao.DraftKnowledgesDao;
import org.support.project.knowledge.entity.DraftKnowledgesEntity;
import org.support.project.knowledge.vo.api.Draft;
Expand Down Expand Up @@ -52,4 +54,28 @@ public Boundary getSingle(String id) {
// TODO Auto-generated method stub
return null;
}

@Delete(path="api/drafts", checkReferer=false, subscribeToken="")
public Boundary delete() {
// TODO: almost same as DraftControl.delete().
// TODO: Can we unify these?

String draftIdStr = super.getPathString("");
if(StringUtils.isEmpty(draftIdStr)) {
send(HttpStatus.SC_204_NO_CONTENT);
}
Long draftId = Long.valueOf(draftIdStr);
DraftKnowledgesEntity draft = DraftKnowledgesDao.get().selectOnKey(draftId);
// アクセス可能かチェック
if (draft == null) {
return send(HttpStatus.SC_404_NOT_FOUND, "NOT FOUND");
}
if (draft.getInsertUser().intValue() != getLoginUserId().intValue()) {
return send(HttpStatus.SC_403_FORBIDDEN, "FORBIDDEN");
}
DraftKnowledgesDao.get().physicalDelete(draft);
DraftItemValuesDao.get().deleteOnDraftId(draftId);

return send(HttpStatus.SC_200_OK);
}
}

0 comments on commit a8b8d8d

Please sign in to comment.