# HG changeset patch # User Ingo Weinzierl # Date 1308743227 0 # Node ID 031357c3e23e5e6ffe7ae685e4db5e957c46951b # Parent 14e5e51a7de43aa8bc2b98dacbf08622d9b443e4 Added stubs to set the name and ttl of a collection and to delete a collection. flys-client/trunk@2202 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 14e5e51a7de4 -r 031357c3e23e flys-client/ChangeLog --- a/flys-client/ChangeLog Wed Jun 22 10:14:57 2011 +0000 +++ b/flys-client/ChangeLog Wed Jun 22 11:47:07 2011 +0000 @@ -1,3 +1,32 @@ +2011-06-22 Ingo Weinzierl + + * src/main/java/de/intevation/flys/client/client/services/SetCollectionNameServiceAsync.java, + src/main/java/de/intevation/flys/client/client/services/SetCollectionNameService.java, + src/main/java/de/intevation/flys/client/server/SetCollectionNameServiceImpl.java: + New. This service is used to set the name of a collection. Note, that + this is currently just a stub. The ServiceImpl currently throws a "NOT + IMPLEMENTED" exception. + + * src/main/java/de/intevation/flys/client/client/services/SetCollectionTTLServiceAsync.java, + src/main/java/de/intevation/flys/client/client/services/SetCollectionTTLService.java, + src/main/java/de/intevation/flys/client/server/SetCollectionTTLServiceImpl.java: + New. This service is used to set the time-to-live of a collection. Note, + that this is currently just a stub. The ServiceImpl currently throws a + "NOT IMPLEMENTED" exception. + + * src/main/java/de/intevation/flys/client/client/services/DeleteCollectionServiceAsync.java, + src/main/java/de/intevation/flys/client/client/services/DeleteCollectionService.java, + src/main/java/de/intevation/flys/client/server/DeleteCollectionServiceImpl.java: + New. This service is used to delete a collection. Note, that this is + currently just a stub. The ServiceImpl currently throws a "NOT + IMPLEMENTED" exception. + + * src/main/java/de/intevation/flys/client/client/ui/ProjectList.java: + Calls the services SetCollectionTTLService, SetCollectionNameService and + DeleteCollectionService and display a warning if an error occured. + + * src/main/webapp/WEB-INF/web.xml: Registered the new services. + 2011-06-22 Ingo Weinzierl * src/main/java/de/intevation/flys/client/shared/model/DefaultCollection.java, diff -r 14e5e51a7de4 -r 031357c3e23e flys-client/src/main/java/de/intevation/flys/client/client/services/DeleteCollectionService.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/services/DeleteCollectionService.java Wed Jun 22 11:47:07 2011 +0000 @@ -0,0 +1,28 @@ +package de.intevation.flys.client.client.services; + +import com.google.gwt.user.client.rpc.RemoteService; +import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; + +import de.intevation.flys.client.shared.exceptions.ServerException; +import de.intevation.flys.client.shared.model.Collection; + + +/** + * This interface describes the service to add an existing artifact to an + * existing collection. + * + * @author Ingo Weinzierl + */ +@RemoteServiceRelativePath("delete-collection") +public interface DeleteCollectionService extends RemoteService { + + /** + * Deletes a collection. + * + * @param collection The Collection that should be deleted. + * @param url The url of the artifact server. + */ + void delete(Collection collection, String url) + throws ServerException; +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 14e5e51a7de4 -r 031357c3e23e flys-client/src/main/java/de/intevation/flys/client/client/services/DeleteCollectionServiceAsync.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/services/DeleteCollectionServiceAsync.java Wed Jun 22 11:47:07 2011 +0000 @@ -0,0 +1,18 @@ +package de.intevation.flys.client.client.services; + +import com.google.gwt.user.client.rpc.AsyncCallback; + +import de.intevation.flys.client.shared.model.Collection; + + +/** + * @author Ingo Weinzierl + */ +public interface DeleteCollectionServiceAsync { + + public void delete( + Collection collection, + String url, + AsyncCallback callback); +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 14e5e51a7de4 -r 031357c3e23e flys-client/src/main/java/de/intevation/flys/client/client/services/SetCollectionNameService.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/services/SetCollectionNameService.java Wed Jun 22 11:47:07 2011 +0000 @@ -0,0 +1,28 @@ +package de.intevation.flys.client.client.services; + +import com.google.gwt.user.client.rpc.RemoteService; +import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; + +import de.intevation.flys.client.shared.exceptions.ServerException; +import de.intevation.flys.client.shared.model.Collection; + + +/** + * This interface describes the service to add an existing artifact to an + * existing collection. + * + * @author Ingo Weinzierl + */ +@RemoteServiceRelativePath("set-collectionname") +public interface SetCollectionNameService extends RemoteService { + + /** + * Set the name of a collection. + * + * @param collection The Collection that should be extended. + * @param url The url of the artifact server. + */ + void setName(Collection collection, String url) + throws ServerException; +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 14e5e51a7de4 -r 031357c3e23e flys-client/src/main/java/de/intevation/flys/client/client/services/SetCollectionNameServiceAsync.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/services/SetCollectionNameServiceAsync.java Wed Jun 22 11:47:07 2011 +0000 @@ -0,0 +1,18 @@ +package de.intevation.flys.client.client.services; + +import com.google.gwt.user.client.rpc.AsyncCallback; + +import de.intevation.flys.client.shared.model.Collection; + + +/** + * @author Ingo Weinzierl + */ +public interface SetCollectionNameServiceAsync { + + public void setName( + Collection collection, + String url, + AsyncCallback callback); +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 14e5e51a7de4 -r 031357c3e23e flys-client/src/main/java/de/intevation/flys/client/client/services/SetCollectionTTLService.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/services/SetCollectionTTLService.java Wed Jun 22 11:47:07 2011 +0000 @@ -0,0 +1,19 @@ +package de.intevation.flys.client.client.services; + +import com.google.gwt.user.client.rpc.RemoteService; +import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; + +import de.intevation.flys.client.shared.exceptions.ServerException; +import de.intevation.flys.client.shared.model.Collection; + + +/** + * @author Ingo Weinzierl + */ +@RemoteServiceRelativePath("set-collectionttl") +public interface SetCollectionTTLService extends RemoteService { + + void setTTL(Collection c, String url) + throws ServerException; +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 14e5e51a7de4 -r 031357c3e23e flys-client/src/main/java/de/intevation/flys/client/client/services/SetCollectionTTLServiceAsync.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/services/SetCollectionTTLServiceAsync.java Wed Jun 22 11:47:07 2011 +0000 @@ -0,0 +1,18 @@ +package de.intevation.flys.client.client.services; + +import com.google.gwt.user.client.rpc.AsyncCallback; + +import de.intevation.flys.client.shared.model.Collection; + + +/** + * @author Ingo Weinzierl + */ +public interface SetCollectionTTLServiceAsync { + + public void setTTL( + Collection collection, + String url, + AsyncCallback callback); +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 14e5e51a7de4 -r 031357c3e23e flys-client/src/main/java/de/intevation/flys/client/client/ui/ProjectList.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ProjectList.java Wed Jun 22 10:14:57 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ProjectList.java Wed Jun 22 11:47:07 2011 +0000 @@ -2,6 +2,7 @@ import java.util.Date; import java.util.Map; +import java.util.MissingResourceException; import com.google.gwt.core.client.GWT; import com.google.gwt.i18n.client.DateTimeFormat; @@ -43,6 +44,12 @@ import de.intevation.flys.client.client.FLYSConstants; import de.intevation.flys.client.client.event.CollectionChangeEvent; import de.intevation.flys.client.client.event.CollectionChangeHandler; +import de.intevation.flys.client.client.services.DeleteCollectionService; +import de.intevation.flys.client.client.services.DeleteCollectionServiceAsync; +import de.intevation.flys.client.client.services.SetCollectionNameService; +import de.intevation.flys.client.client.services.SetCollectionNameServiceAsync; +import de.intevation.flys.client.client.services.SetCollectionTTLService; +import de.intevation.flys.client.client.services.SetCollectionTTLServiceAsync; import de.intevation.flys.client.client.services.UserCollectionsService; import de.intevation.flys.client.client.services.UserCollectionsServiceAsync; @@ -69,6 +76,18 @@ protected UserCollectionsServiceAsync userCollectionsService = GWT.create(UserCollectionsService.class); + /** The service used to set the name of a project.*/ + protected SetCollectionNameServiceAsync nameService = + GWT.create(SetCollectionNameService.class); + + /** The service used to set the name of a project.*/ + protected SetCollectionTTLServiceAsync ttlService = + GWT.create(SetCollectionTTLService.class); + + /** The service used to set the name of a project.*/ + protected DeleteCollectionServiceAsync deleteService = + GWT.create(DeleteCollectionService.class); + /** A pointer to the FLYS instance.*/ protected FLYS flys; @@ -210,7 +229,7 @@ MenuItem del = new MenuItem(messages.delete_project()); del.addClickHandler(new ClickHandler() { public void onClick(MenuItemClickEvent evt) { - SC.warn("Removing projects is not implemented."); + deleteCollection(record.getCollection()); } }); @@ -303,7 +322,23 @@ GWT.log("Update Collection name: " + c.identifier()); GWT.log("=> New name = " + c.getName()); - // TODO IMPLEMENT ME + Config config = Config.getInstance(); + nameService.setName(c, config.getServerUrl(), new AsyncCallback(){ + public void onFailure(Throwable caught) { + String msg = caught.getMessage(); + + try { + SC.warn(messages.getString(msg)); + } + catch (MissingResourceException mre) { + SC.warn(msg); + } + } + + public void onSuccess(Void v) { + updateUserCollections(); + } + }); } @@ -321,7 +356,55 @@ GWT.log("Update Collection TTL: " + c.identifier()); GWT.log("=> New ttl = " + c.getTTL()); - // TODO IMPLEMENT ME + Config config = Config.getInstance(); + ttlService.setTTL(c, config.getServerUrl(), new AsyncCallback() { + public void onFailure(Throwable caught) { + String msg = caught.getMessage(); + + try { + SC.warn(messages.getString(msg)); + } + catch (MissingResourceException mre) { + SC.warn(msg); + } + } + + public void onSuccess(Void v) { + updateUserCollections(); + } + }); + } + + + /** + * Delete the collection c. + * + * @param c The Collection that should be deleted. + */ + protected void deleteCollection(Collection c) { + if (c == null) { + return; + } + + GWT.log("Delete Collection: " + c.identifier()); + + Config config = Config.getInstance(); + deleteService.delete(c, config.getServerUrl(), new AsyncCallback(){ + public void onFailure(Throwable caught) { + String msg = caught.getMessage(); + + try { + SC.warn(messages.getString(msg)); + } + catch (MissingResourceException mre) { + SC.warn(msg); + } + } + + public void onSuccess(Void v) { + updateUserCollections(); + } + }); } @@ -335,8 +418,14 @@ userCollectionsService.getUserCollections(url, locale, user.identifier(), new AsyncCallback() { public void onFailure(Throwable caught) { - GWT.log("Could not recieve a list of user collections."); - GWT.log(caught.getMessage()); + String msg = caught.getMessage(); + + try { + SC.warn(messages.getString(msg)); + } + catch (MissingResourceException mre) { + SC.warn(msg); + } } public void onSuccess(Collection[] collections) { diff -r 14e5e51a7de4 -r 031357c3e23e flys-client/src/main/java/de/intevation/flys/client/server/DeleteCollectionServiceImpl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/DeleteCollectionServiceImpl.java Wed Jun 22 11:47:07 2011 +0000 @@ -0,0 +1,33 @@ +package de.intevation.flys.client.server; + +import org.w3c.dom.Document; + +import com.google.gwt.user.server.rpc.RemoteServiceServlet; + +import de.intevation.artifacts.common.utils.ClientProtocolUtils; + +import de.intevation.artifacts.httpclient.exceptions.ConnectionException; +import de.intevation.artifacts.httpclient.http.HttpClient; +import de.intevation.artifacts.httpclient.http.HttpClientImpl; +import de.intevation.artifacts.httpclient.http.response.DocumentResponseHandler; + +import de.intevation.flys.client.shared.exceptions.ServerException; +import de.intevation.flys.client.shared.model.Collection; +import de.intevation.flys.client.client.services.DeleteCollectionService; + + +/** + * @author Ingo Weinzierl + */ +public class DeleteCollectionServiceImpl +extends RemoteServiceServlet +implements DeleteCollectionService +{ + public void delete(Collection c, String url) + throws ServerException + { + // TODO IMPLEMENT ME + throw new ServerException("Delete Service NOT IMPLEMENTED"); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 14e5e51a7de4 -r 031357c3e23e flys-client/src/main/java/de/intevation/flys/client/server/SetCollectionNameServiceImpl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/SetCollectionNameServiceImpl.java Wed Jun 22 11:47:07 2011 +0000 @@ -0,0 +1,33 @@ +package de.intevation.flys.client.server; + +import org.w3c.dom.Document; + +import com.google.gwt.user.server.rpc.RemoteServiceServlet; + +import de.intevation.artifacts.common.utils.ClientProtocolUtils; + +import de.intevation.artifacts.httpclient.exceptions.ConnectionException; +import de.intevation.artifacts.httpclient.http.HttpClient; +import de.intevation.artifacts.httpclient.http.HttpClientImpl; +import de.intevation.artifacts.httpclient.http.response.DocumentResponseHandler; + +import de.intevation.flys.client.shared.exceptions.ServerException; +import de.intevation.flys.client.shared.model.Collection; +import de.intevation.flys.client.client.services.SetCollectionNameService; + + +/** + * @author Ingo Weinzierl + */ +public class SetCollectionNameServiceImpl +extends RemoteServiceServlet +implements SetCollectionNameService +{ + public void setName(Collection c, String url) + throws ServerException + { + // TODO IMPLEMENT ME + throw new ServerException("Name Service NOT IMPLEMENTED"); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 14e5e51a7de4 -r 031357c3e23e flys-client/src/main/java/de/intevation/flys/client/server/SetCollectionTTLServiceImpl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/SetCollectionTTLServiceImpl.java Wed Jun 22 11:47:07 2011 +0000 @@ -0,0 +1,33 @@ +package de.intevation.flys.client.server; + +import org.w3c.dom.Document; + +import com.google.gwt.user.server.rpc.RemoteServiceServlet; + +import de.intevation.artifacts.common.utils.ClientProtocolUtils; + +import de.intevation.artifacts.httpclient.exceptions.ConnectionException; +import de.intevation.artifacts.httpclient.http.HttpClient; +import de.intevation.artifacts.httpclient.http.HttpClientImpl; +import de.intevation.artifacts.httpclient.http.response.DocumentResponseHandler; + +import de.intevation.flys.client.shared.exceptions.ServerException; +import de.intevation.flys.client.shared.model.Collection; +import de.intevation.flys.client.client.services.SetCollectionTTLService; + + +/** + * @author Ingo Weinzierl + */ +public class SetCollectionTTLServiceImpl +extends RemoteServiceServlet +implements SetCollectionTTLService +{ + public void setTTL(Collection c, String url) + throws ServerException + { + // TODO IMPLEMENT ME + throw new ServerException("TTL Service NOT IMPLEMENTED"); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 14e5e51a7de4 -r 031357c3e23e flys-client/src/main/webapp/WEB-INF/web.xml --- a/flys-client/src/main/webapp/WEB-INF/web.xml Wed Jun 22 10:14:57 2011 +0000 +++ b/flys-client/src/main/webapp/WEB-INF/web.xml Wed Jun 22 11:47:07 2011 +0000 @@ -187,6 +187,36 @@ /flys/chart-info + + SetCollectionNameService + de.intevation.flys.client.server.SetCollectionNameServiceImpl + + + + SetCollectionNameService + /flys/set-collectionname + + + + SetCollectionTTLService + de.intevation.flys.client.server.SetCollectionTTLServiceImpl + + + + SetCollectionTTLService + /flys/set-collectionttl + + + + DeleteCollectionService + de.intevation.flys.client.server.DeleteCollectionServiceImpl + + + + DeleteCollectionService + /flys/delete-collection + + FLYS.html