Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Update glossary resource, remove delete all options
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Eng committed Oct 16, 2015
1 parent 6b246b8 commit 640428a
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
import javax.ws.rs.core.UriInfo;

import org.zanata.common.LocaleId;
import org.zanata.rest.GlossaryFileUploadForm;
import org.zanata.rest.dto.Glossary;
import org.zanata.rest.dto.GlossaryEntry;

/**
* @author Patrick Huang
Expand All @@ -44,12 +46,20 @@ public Response getEntries() {
}

@Override
public Response getLocaleStatistic() {
public Response getInfo() {
return null;
}

@Override
public Response get(LocaleId localeId, LocaleId localeId1, int i, int i1) {
public Response getEntriesForLocale(LocaleId srcLocale,
LocaleId transLocale, int page, int sizePerPage, String filter,
String sort) {
return MockResourceUtil.notUsedByClient();
}

@Override
public Response getAllEntries(LocaleId srcLocale, int page, int LocaleId, String filter,
String sort) {
return MockResourceUtil.notUsedByClient();
}

Expand All @@ -59,18 +69,28 @@ public Response put(Glossary messageBody) {
}

@Override
public Response deleteGlossary(LocaleId locale) {
return Response.ok().build();
public Response post(Glossary glossary) {
return null;
}

@Override
public Response post(GlossaryEntry glossaryEntry) {
return MockResourceUtil.notUsedByClient();
}

@Override
public Response deleteGlossary(LocaleId localeId, String s) {
public Response upload(GlossaryFileUploadForm glossaryFileUploadForm) {
return null;
}

@Override
public Response deleteEntry(String resId) {
return MockResourceUtil.notUsedByClient();
}

@Override
public Response deleteGlossaries() {
return Response.ok().build();
public Response deleteAllEntries() {
return null;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,12 @@ public GlossaryDeleteCommand(GlossaryDeleteOptions opts) {
public void run() throws Exception {
log.info("Server: {}", getOpts().getUrl());
log.info("Username: {}", getOpts().getUsername());
log.info("Locale to delete: {}", getOpts().getlang());
log.info("Delete entire glossary?: {}", getOpts().getAllGlossary());
log.info("Entry resId to delete: {}", getOpts().getResId());

if (getOpts().getAllGlossary()) {
glossaryClient.deleteAll();
} else if (!StringUtils.isEmpty(getOpts().getlang())) {
glossaryClient.delete(new LocaleId(getOpts()
.getlang()));
if (!StringUtils.isEmpty(getOpts().getResId())) {
glossaryClient.delete(getOpts().getResId());
} else {
throw new RuntimeException("Option 'zanata.lang' is required.");
throw new RuntimeException("Option 'zanata.resId' is required.");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,5 @@
import org.zanata.client.commands.ConfigurableProjectOptions;

public interface GlossaryDeleteOptions extends ConfigurableProjectOptions {
public String getlang();

public boolean getAllGlossary();
public String getResId();
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,15 @@ public class GlossaryDeleteMojo extends
/**
* Locale of glossary to delete
*
* @parameter expression="${zanata.lang}"
* @parameter expression="${zanata.resId}"
*/
private String lang;

/**
* Delete entire glossaries
*
* @parameter expression="${zanata.allGlossary}" default-value="false"
*/
private boolean allGlossary = false;
private String resId;

@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD",
justification = "Injected by Maven")
@Override
public String getlang() {
return lang;
}

@Override
public boolean getAllGlossary() {
return allGlossary;
public String getResId() {
return resId;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,9 @@ public void put(Glossary glossary) {
webResource().put(glossary);
}

public void delete(LocaleId locale) {
webResource().path(locale.getId())
public void delete(String resId) {
webResource().path("entries/" + resId)
.delete();

}

public void deleteAll() {
webResource().delete();
}

private WebResource webResource() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Test;
import org.zanata.common.LocaleId;
import org.zanata.rest.dto.Glossary;
import org.zanata.rest.service.StubbingServerRule;

Expand All @@ -43,19 +42,6 @@ public void setUp() throws Exception {
@Test
public void testPut() throws Exception {
client.put(new Glossary());

MockServerTestUtil.verifyServerRespondSuccessStatus();
}

@Test
public void testDelete() throws Exception {
client.delete(LocaleId.DE);
MockServerTestUtil.verifyServerRespondSuccessStatus();
}

@Test
public void testDeleteAll() throws Exception {
client.deleteAll();
MockServerTestUtil.verifyServerRespondSuccessStatus();
}
}
Expand Down

0 comments on commit 640428a

Please sign in to comment.