http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/com/google/wave/api/event/WaveletParticipantsChangedEvent.java ---------------------------------------------------------------------- diff --git a/wave/src/main/java/com/google/wave/api/event/WaveletParticipantsChangedEvent.java b/wave/src/main/java/com/google/wave/api/event/WaveletParticipantsChangedEvent.java deleted file mode 100644 index f4e4b99..0000000 --- a/wave/src/main/java/com/google/wave/api/event/WaveletParticipantsChangedEvent.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package com.google.wave.api.event; - -import com.google.wave.api.Wavelet; -import com.google.wave.api.impl.EventMessageBundle; - -import java.util.ArrayList; -import java.util.List; - -/** - * Event triggered when participants are added and/or removed from a wavelet. - */ -public class WaveletParticipantsChangedEvent extends AbstractEvent { - - /** The newly added participants. */ - private final List<String> participantsAdded; - - /** The removed participants. */ - private final List<String> participantsRemoved; - - /** - * Constructor. - * - * @param wavelet the wavelet in which the participants were added or removed. - * @param bundle the message bundle this event belongs to. - * @param modifiedBy the id of the participant that triggered this event. - * @param timestamp the timestamp of this event. - * @param rootBlipId the root blip id of the wavelet where this event occurs. - * @param participantsAdded the added participants. - * @param participantsRemoved the removed participants. - */ - public WaveletParticipantsChangedEvent(Wavelet wavelet, EventMessageBundle bundle, - String modifiedBy, Long timestamp, String rootBlipId, List<String> participantsAdded, - List<String> participantsRemoved) { - super(EventType.WAVELET_PARTICIPANTS_CHANGED, wavelet, bundle, modifiedBy, timestamp, - rootBlipId); - this.participantsAdded = new ArrayList<String>(participantsAdded); - this.participantsRemoved = new ArrayList<String>(participantsRemoved); - } - - /** - * Constructor for deserialization. - */ - WaveletParticipantsChangedEvent() { - this.participantsAdded = null; - this.participantsRemoved = null; - } - - /** - * Returns a list of the new participants. - * - * @return the added participants. - */ - public List<String> getParticipantsAdded() { - return participantsAdded; - } - - /** - * Returns a list of the removed participants. - * - * @return the removed participants. - */ - public List<String> getParticipantsRemoved() { - return participantsRemoved; - } - - /** - * Helper method for type conversion. - * - * @return the concrete type of this event, or {@code null} if it is of a - * different event type. - */ - public static WaveletParticipantsChangedEvent as(Event event) { - if (!(event instanceof WaveletParticipantsChangedEvent)) { - return null; - } - return WaveletParticipantsChangedEvent.class.cast(event); - } -}
http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/com/google/wave/api/event/WaveletSelfAddedEvent.java ---------------------------------------------------------------------- diff --git a/wave/src/main/java/com/google/wave/api/event/WaveletSelfAddedEvent.java b/wave/src/main/java/com/google/wave/api/event/WaveletSelfAddedEvent.java deleted file mode 100644 index 2275724..0000000 --- a/wave/src/main/java/com/google/wave/api/event/WaveletSelfAddedEvent.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package com.google.wave.api.event; - -import com.google.wave.api.Wavelet; -import com.google.wave.api.impl.EventMessageBundle; - -/** - * Event triggered when a robot is added to a wavelet. - */ -public class WaveletSelfAddedEvent extends AbstractEvent { - - /** - * Constructor. - * - * @param wavelet the wavelet in which this robot was added. - * @param bundle the message bundle this event belongs to. - * @param modifiedBy the id of the participant that added this robot. - * @param timestamp the timestamp of this event. - * @param rootBlipId the root blip id of the wavelet where this event occurs. - */ - public WaveletSelfAddedEvent(Wavelet wavelet, EventMessageBundle bundle, String modifiedBy, - Long timestamp, String rootBlipId) { - super(EventType.WAVELET_SELF_ADDED, wavelet, bundle, modifiedBy, timestamp, rootBlipId); - } - - /** - * Constructor for deserialization. - */ - WaveletSelfAddedEvent() {} - - /** - * Helper method for type conversion. - * - * @return the concrete type of this event, or {@code null} if it is of a - * different event type. - */ - public static WaveletSelfAddedEvent as(Event event) { - if (!(event instanceof WaveletSelfAddedEvent)) { - return null; - } - return WaveletSelfAddedEvent.class.cast(event); - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/com/google/wave/api/event/WaveletSelfRemovedEvent.java ---------------------------------------------------------------------- diff --git a/wave/src/main/java/com/google/wave/api/event/WaveletSelfRemovedEvent.java b/wave/src/main/java/com/google/wave/api/event/WaveletSelfRemovedEvent.java deleted file mode 100644 index 125e916..0000000 --- a/wave/src/main/java/com/google/wave/api/event/WaveletSelfRemovedEvent.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package com.google.wave.api.event; - -import com.google.wave.api.Wavelet; -import com.google.wave.api.impl.EventMessageBundle; - -/** - * Event triggered when a robot is removed from a wavelet. - */ -public class WaveletSelfRemovedEvent extends AbstractEvent { - - /** - * Constructor. - * - * @param wavelet the wavelet in which this robot was removed. - * @param bundle the message bundle this event belongs to. - * @param modifiedBy the id of the participant that removed this robot. - * @param timestamp the timestamp of this event. - * @param rootBlipId the root blip id of the wavelet where this event occurs. - */ - public WaveletSelfRemovedEvent(Wavelet wavelet, EventMessageBundle bundle, String modifiedBy, - Long timestamp, String rootBlipId) { - super(EventType.WAVELET_SELF_REMOVED, wavelet, bundle, modifiedBy, timestamp, rootBlipId); - } - - /** - * Constructor for deserialization. - */ - WaveletSelfRemovedEvent() {} - - /** - * Helper method for type conversion. - * - * @return the concrete type of this event, or {@code null} if it is of a - * different event type. - */ - public static WaveletSelfRemovedEvent as(Event event) { - if (!(event instanceof WaveletSelfRemovedEvent)) { - return null; - } - return WaveletSelfRemovedEvent.class.cast(event); - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/com/google/wave/api/event/WaveletTagsChangedEvent.java ---------------------------------------------------------------------- diff --git a/wave/src/main/java/com/google/wave/api/event/WaveletTagsChangedEvent.java b/wave/src/main/java/com/google/wave/api/event/WaveletTagsChangedEvent.java deleted file mode 100644 index bb76fca..0000000 --- a/wave/src/main/java/com/google/wave/api/event/WaveletTagsChangedEvent.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package com.google.wave.api.event; - -import com.google.wave.api.Wavelet; -import com.google.wave.api.impl.EventMessageBundle; - -/** - * Event triggered when the tags on a wavelet change. - */ -public class WaveletTagsChangedEvent extends AbstractEvent { - - /** - * Constructor. - * - * @param wavelet the wavelet where this event occurred. - * @param bundle the message bundle this event belongs to. - * @param modifiedBy the id of the participant that triggered this event. - * @param timestamp the timestamp of this event. - * @param blipId the id of the submitted blip. - */ - public WaveletTagsChangedEvent(Wavelet wavelet, EventMessageBundle bundle, String modifiedBy, - Long timestamp, String blipId) { - super(EventType.WAVELET_TAGS_CHANGED, wavelet, bundle, modifiedBy, timestamp, blipId); - } - - /** - * Constructor for deserialization. - */ - public WaveletTagsChangedEvent() {} - - /** - * Helper method for type conversion. - * - * @return the concrete type of this event, or {@code null} if it is of a - * different event type. - */ - public static WaveletTagsChangedEvent as(Event event) { - if (!(event instanceof WaveletTagsChangedEvent)) { - return null; - } - return WaveletTagsChangedEvent.class.cast(event); - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/com/google/wave/api/event/WaveletTitleChangedEvent.java ---------------------------------------------------------------------- diff --git a/wave/src/main/java/com/google/wave/api/event/WaveletTitleChangedEvent.java b/wave/src/main/java/com/google/wave/api/event/WaveletTitleChangedEvent.java deleted file mode 100644 index 49a2123..0000000 --- a/wave/src/main/java/com/google/wave/api/event/WaveletTitleChangedEvent.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package com.google.wave.api.event; - -import com.google.wave.api.Wavelet; -import com.google.wave.api.impl.EventMessageBundle; - -/** - * Event triggered when the title of the wavelet has changed. - */ -public class WaveletTitleChangedEvent extends AbstractEvent { - - /** The new title. */ - private final String title; - - /** - * Constructor. - * - * @param wavelet the wavelet which title was changed. - * @param bundle the message bundle this event belongs to. - * @param modifiedBy the id of the participant that changed the title. - * @param timestamp the timestamp of this event. - * @param rootBlipId the root blip id of the wavelet where this event occurs. - * @param title the new title. - */ - public WaveletTitleChangedEvent(Wavelet wavelet, EventMessageBundle bundle, String modifiedBy, - Long timestamp, String rootBlipId, String title) { - super(EventType.WAVELET_TITLE_CHANGED, wavelet, bundle, modifiedBy, timestamp, rootBlipId); - this.title = title; - } - - /** - * Constructor for deserialization. - */ - WaveletTitleChangedEvent() { - this.title = null; - } - - /** - * Returns the new title. - * - * @return the new title. - */ - public String getTitle() { - return title; - } - - /** - * Helper method for type conversion. - * - * @return the concrete type of this event, or {@code null} if it is of a - * different event type. - */ - public static WaveletTitleChangedEvent as(Event event) { - if (!(event instanceof WaveletTitleChangedEvent)) { - return null; - } - return WaveletTitleChangedEvent.class.cast(event); - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/com/google/wave/api/impl/DocumentModifyAction.java ---------------------------------------------------------------------- diff --git a/wave/src/main/java/com/google/wave/api/impl/DocumentModifyAction.java b/wave/src/main/java/com/google/wave/api/impl/DocumentModifyAction.java deleted file mode 100644 index 1bcee55..0000000 --- a/wave/src/main/java/com/google/wave/api/impl/DocumentModifyAction.java +++ /dev/null @@ -1,148 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package com.google.wave.api.impl; - -import com.google.wave.api.Element; - -import java.util.ArrayList; -import java.util.List; - - -/** - * DocumentModifyAction is a class specific to how operations of type - * DOCUMENT_MODIFY are serialized. DocumentModifyAction specifies what should - * happen to matched bits of the document. - * - */ - -public class DocumentModifyAction { - - public enum ModifyHow { - DELETE, REPLACE, INSERT, INSERT_AFTER, ANNOTATE, CLEAR_ANNOTATION, UPDATE_ELEMENT; - } - - /** - * Initial annotations to be applied to the document modification range. - */ - static public class BundledAnnotation { - public String key; - public String value; - - - /** - * Convenience method to create a list of bundled annotations with - * the even values passed being the keys, the uneven ones the values. - */ - public static List<BundledAnnotation> listOf(String... values) { - if (values.length % 2 != 0) { - throw new IllegalArgumentException("listOf takes an even number of parameters"); - } - List<BundledAnnotation> res = new ArrayList<BundledAnnotation>(values.length / 2); - for (int i = 0; i < values.length - 1; i += 2) { - BundledAnnotation next = new BundledAnnotation(); - next.key = values[i]; - next.value = values[i + 1]; - res.add(next); - } - return res; - } - } - - private ModifyHow modifyHow; - private List<String> values; - private String annotationKey; - private List<Element> elements; - private List<BundledAnnotation> bundledAnnotations; - private boolean useMarkup; - - public DocumentModifyAction(ModifyHow modifyHow, List<String> values, String annotationKey, - List<Element> elements, List<BundledAnnotation> initialAnnotations, boolean useMarkup) { - this.modifyHow = modifyHow; - this.values = values; - this.annotationKey = annotationKey; - this.elements = elements; - this.useMarkup = useMarkup; - this.bundledAnnotations = initialAnnotations; - } - - // No parameter constructor for serialization - public DocumentModifyAction() { - this.modifyHow = null; - this.values = null; - this.annotationKey = null; - this.elements = null; - this.useMarkup = false; - this.bundledAnnotations = null; - } - - public ModifyHow getModifyHow() { - return modifyHow; - } - - public List<String> getValues() { - return values; - } - - public String getAnnotationKey() { - return annotationKey; - } - - public List<Element> getElements() { - return elements; - } - - public boolean isUseMarkup() { - return useMarkup; - } - - /** - * @return the value from values (wrapping around) for the given index. - */ - public String getValue(int valueIndex) { - if (values == null || values.isEmpty()) { - return null; - } - return values.get(valueIndex % values.size()); - } - - /** - * @return the element from elements (wrapping around) for the given index. - */ - public Element getElement(int valueIndex) { - if (elements == null || elements.isEmpty()) { - return null; - } - return elements.get(valueIndex % elements.size()); - } - - /** - * @return whether there is text at the specified index - */ - public boolean hasTextAt(int valueIndex) { - if (values == null || values.isEmpty()) { - return false; - } - return values.get(valueIndex % values.size()) != null; - } - - public List<BundledAnnotation> getBundledAnnotations() { - return bundledAnnotations; - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/com/google/wave/api/impl/DocumentModifyQuery.java ---------------------------------------------------------------------- diff --git a/wave/src/main/java/com/google/wave/api/impl/DocumentModifyQuery.java b/wave/src/main/java/com/google/wave/api/impl/DocumentModifyQuery.java deleted file mode 100644 index 9892edd..0000000 --- a/wave/src/main/java/com/google/wave/api/impl/DocumentModifyQuery.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package com.google.wave.api.impl; - -import com.google.wave.api.ElementType; - -import java.util.Map; - -/** - * DocumentModifyQuery is a class specific to how operations of type - * DOCUMENT_MODIFY are serialized. DocumentModifyQuery specifies which - * bit of a blip is matched. - * - * The query specifies either a textMatch in which case the blip is - * searched for that string literal, or an elementMatch is specified in - * which case the blip is searched of an instance of that element. In the - * latter case restrictions can also be set to restrict the elements matched - * by attribute value. In either case maxRes can be specified to restrict - * how many matches are returned; specify -1 for as many as possible. - */ -public class DocumentModifyQuery { - - private ElementType elementMatch; - private int maxRes; - private String textMatch; - private Map<String, String> restrictions; - - public DocumentModifyQuery( - ElementType elementMatch, Map<String, String> restrictions, int maxRes) { - this.textMatch = null; - this.elementMatch = elementMatch; - this.restrictions = restrictions; - this.maxRes = maxRes; - } - - public DocumentModifyQuery(String stringMatch, int maxRes) { - this.textMatch = stringMatch; - this.elementMatch = null; - this.restrictions = null; - this.maxRes = maxRes; - } - - // No Parameter constructor for serialization: - public DocumentModifyQuery() { - this.textMatch = null; - this.elementMatch = null; - this.restrictions = null; - this.maxRes = -1; - } - - /** - * @return textMatch if any is set or null if not. - */ - public String getTextMatch() { - return textMatch; - } - - /** - * @return elementMatch if any is set or null if not. - */ - public ElementType getElementMatch() { - return elementMatch; - } - - public Map<String, String> getRestrictions() { - return restrictions; - } - - public int getMaxRes() { - return maxRes; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/com/google/wave/api/impl/ElementGsonAdaptor.java ---------------------------------------------------------------------- diff --git a/wave/src/main/java/com/google/wave/api/impl/ElementGsonAdaptor.java b/wave/src/main/java/com/google/wave/api/impl/ElementGsonAdaptor.java deleted file mode 100644 index 7313c3b..0000000 --- a/wave/src/main/java/com/google/wave/api/impl/ElementGsonAdaptor.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package com.google.wave.api.impl; - -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.JsonPrimitive; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; -import com.google.wave.api.Attachment; -import com.google.wave.api.Element; -import com.google.wave.api.ElementType; -import com.google.wave.api.FormElement; -import com.google.wave.api.Gadget; -import com.google.wave.api.Image; -import com.google.wave.api.Line; - -import org.apache.commons.codec.binary.Base64; - -import java.io.UnsupportedEncodingException; -import java.lang.reflect.Type; -import java.util.Map; -import java.util.Map.Entry; - -/** - * Gson adaptor to serialize and deserialize {@link Element}. - * - * @author [email protected] (Marcel Prasetya) - */ -public class ElementGsonAdaptor implements JsonDeserializer<Element>, - JsonSerializer<Element> { - - protected static final String TYPE_TAG = "type"; - protected static final String PROPERTIES_TAG = "properties"; - - @Override - public Element deserialize(JsonElement json, Type typeOfT, - JsonDeserializationContext context) throws JsonParseException { - Element result = null; - ElementType type = ElementType.valueOfIgnoreCase( - json.getAsJsonObject().get(TYPE_TAG).getAsString()); - - Map<String, String> properties = context.deserialize( - json.getAsJsonObject().get(PROPERTIES_TAG), GsonFactory.STRING_MAP_TYPE); - - if (FormElement.getFormElementTypes().contains(type)) { - result = new FormElement(type, properties); - } else if (type == ElementType.GADGET) { - result = new Gadget(properties); - } else if (type == ElementType.IMAGE) { - result = new Image(properties); - } else if (type == ElementType.ATTACHMENT) { - byte[] data = null; - String encodedData = properties.get(Attachment.DATA); - if (encodedData != null) { - try { - data = Base64.decodeBase64(encodedData.getBytes("UTF-8")); - } catch (UnsupportedEncodingException e) { - throw new JsonParseException("Couldn't convert to utf-8", e); - } - } - result = new Attachment(properties, data); - } else if (type == ElementType.LINE) { - result = new Line(properties); - } else { - result = new Element(type, properties); - } - return result; - } - - @Override - public JsonElement serialize(Element src, Type typeOfSrc, JsonSerializationContext context) { - JsonObject jsonObject = new JsonObject(); - jsonObject.addProperty(TYPE_TAG, src.getType().toString()); - JsonObject properties = new JsonObject(); - if (src.isAttachment()) { - Attachment attachment = (Attachment) src; - if (attachment.hasData()) { - byte[] encodedData = Base64.encodeBase64(attachment.getData()); - try { - properties.add(Attachment.DATA, new JsonPrimitive( - new String(encodedData, "UTF-8"))); - } catch (UnsupportedEncodingException e) { - // this shouldn't happen, so let it slide. - } - } - } - for (Entry<String, String> entry : src.getProperties().entrySet()) { - // Note: Gson's JsonObject and MapTypeAdapter don't escape the key - // automatically, so we have to manually escape it here by calling - // JsonSerializationContext.serialize(). Also, unfortunately, calling - // JsonPrimitive.toString() wraps the text inside double quotes, that we - // need to strip out. - String quotedKey = context.serialize(entry.getKey()).toString(); - String key = quotedKey.substring(1, quotedKey.length() - 1); - - JsonElement value = context.serialize(entry.getValue()); - properties.add(key, value); - } - - jsonObject.add(PROPERTIES_TAG, properties); - return jsonObject; - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/com/google/wave/api/impl/EventMessageBundle.java ---------------------------------------------------------------------- diff --git a/wave/src/main/java/com/google/wave/api/impl/EventMessageBundle.java b/wave/src/main/java/com/google/wave/api/impl/EventMessageBundle.java deleted file mode 100644 index 67ddb08..0000000 --- a/wave/src/main/java/com/google/wave/api/impl/EventMessageBundle.java +++ /dev/null @@ -1,209 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package com.google.wave.api.impl; - -import com.google.wave.api.BlipData; -import com.google.wave.api.Context; -import com.google.wave.api.BlipThread; -import com.google.wave.api.Wavelet; -import com.google.wave.api.event.Event; -import com.google.wave.api.event.EventType; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * A container for a bundle of messages to be sent to a robot. - * - * @author [email protected] (Seth Covitz) - */ -public class EventMessageBundle { - - private List<Event> events; - private WaveletData waveletData; - private Wavelet wavelet; - private Map<String, BlipData> blipData; - private Map<String, BlipThread> threads; - private Map<String, Set<Context>> requiredBlips; - private String proxyingFor; - private final String robotAddress; - private final String rpcServerUrl; - - public EventMessageBundle(String robotAddress, String rpcServerUrl) { - this.robotAddress = robotAddress; - events = new ArrayList<Event>(); - this.rpcServerUrl = rpcServerUrl; - blipData = new HashMap<String, BlipData>(); - requiredBlips = new HashMap<String, Set<Context>>(); - threads = new HashMap<String, BlipThread>(); - } - - public Map<String, Set<Context>> getRequiredBlips() { - return requiredBlips; - } - - /** - * Require the availability of the specified blipId for this bundle. - * - * @param blipId the id of the blip that is required. - * @param contexts we need for this blip. - */ - public void requireBlip(String blipId, List<Context> contexts) { - Set<Context> contextSet = requiredBlips.get(blipId); - if (contextSet == null) { - contextSet = new HashSet<Context>(); - requiredBlips.put(blipId, contextSet); - } - for (Context context : contexts) { - contextSet.add(context); - } - } - - /** - * Add an event to the events that are tracked. - * @param event to add. - */ - public void addEvent(Event event) { - events.add(event); - } - - public boolean hasMessages() { - return !events.isEmpty(); - } - - public List<Event> getEvents() { - return events; - } - - public WaveletData getWaveletData() { - return waveletData; - } - - public Wavelet getWavelet() { - return wavelet; - } - - public Map<String, BlipData> getBlipData() { - return blipData; - } - - public Map<String, BlipThread> getThreads() { - return threads; - } - - public void setEvents(List<Event> events) { - this.events = events; - } - - public void setWaveletData(WaveletData waveletData) { - this.waveletData = waveletData; - } - - public void setWavelet(Wavelet wavelet) { - this.wavelet = wavelet; - } - - public void setBlipData(Map<String, BlipData> blipData) { - this.blipData = blipData; - } - - public void setThreads(Map<String, BlipThread> threads) { - this.threads = threads; - } - - public void clear() { - events.clear(); - blipData.clear(); - requiredBlips.clear(); - waveletData = null; - } - - /** - * Return whether a blip is already in the blipdata - * - * @param id of the blip - * @return whether it is in blipData - */ - public boolean hasBlipId(String id) { - return blipData.containsKey(id); - } - - /** - * Add a blip to the blipdata - * - * @param id - * @param blip - */ - public void addBlip(String id, BlipData blip) { - blipData.put(id, blip); - } - - /** - * Add a thread to the map of threads. - * - * @param id the thread id. - * @param thread the thread to add. - */ - public void addThread(String id, BlipThread thread) { - threads.put(id, thread); - } - - /** - * Check whether a given thread has been added to the thread map or not. - * - * @param id the id of the thread to check. - * @return {@code true} if the map contains the given thread id. - */ - public boolean hasThreadId(String id) { - return threads.containsKey(id); - } - - /** - * Return whether the lookingFor event is contained in this bundle. - */ - public boolean hasEvent(EventType eventType) { - for (Event event : events) { - if (event.getType() == eventType) { - return true; - } - } - return false; - } - - public String getProxyingFor() { - return proxyingFor; - } - - public void setProxyingFor(String proxyingFor) { - this.proxyingFor = proxyingFor; - } - - public String getRobotAddress() { - return robotAddress; - } - - public String getRpcServerUrl() { - return rpcServerUrl; - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/com/google/wave/api/impl/EventMessageBundleGsonAdaptor.java ---------------------------------------------------------------------- diff --git a/wave/src/main/java/com/google/wave/api/impl/EventMessageBundleGsonAdaptor.java b/wave/src/main/java/com/google/wave/api/impl/EventMessageBundleGsonAdaptor.java deleted file mode 100644 index 9db7bc5..0000000 --- a/wave/src/main/java/com/google/wave/api/impl/EventMessageBundleGsonAdaptor.java +++ /dev/null @@ -1,163 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package com.google.wave.api.impl; - -import com.google.gson.InstanceCreator; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; -import com.google.wave.api.Blip; -import com.google.wave.api.BlipData; -import com.google.wave.api.OperationQueue; -import com.google.wave.api.OperationRequest; -import com.google.wave.api.BlipThread; -import com.google.wave.api.Wavelet; -import com.google.wave.api.event.Event; -import com.google.wave.api.event.EventSerializationException; -import com.google.wave.api.event.EventSerializer; - -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -/** - * Gson adaptor to serialize and deserialize {@link EventMessageBundle}. - * - * @author [email protected] (Douwe Osinga) - */ -public class EventMessageBundleGsonAdaptor implements - InstanceCreator<EventMessageBundle>, - JsonSerializer<EventMessageBundle>, - JsonDeserializer<EventMessageBundle> { - - public static final String EVENTS_TAG = "events"; - public static final String WAVELET_TAG = "wavelet"; - public static final String BLIPS_TAG = "blips"; - public static final String THREADS_TAG = "threads"; - private static final String PROXYING_FOR_TAG = "proxyingFor"; - private static final String ROBOT_ADDRESS_TAG = "robotAddress"; - private static final String RPC_SERVER_URL_TAG = "rpcServerUrl"; - - @Override - public EventMessageBundle createInstance(Type type) { - return new EventMessageBundle("", "http://opensocial.example.com"); - } - - @Override - public JsonElement serialize(EventMessageBundle src, Type typeOfSrc, - JsonSerializationContext context) { - JsonObject result = new JsonObject(); - - JsonArray events = new JsonArray(); - for (Event event : src.getEvents()) { - try { - events.add(EventSerializer.serialize(event, context)); - } catch (EventSerializationException e) { - throw new JsonParseException(e); - } - } - result.add(EVENTS_TAG, events); - - result.add(WAVELET_TAG, context.serialize(src.getWaveletData())); - result.add(BLIPS_TAG, context.serialize(src.getBlipData())); - result.add(THREADS_TAG, context.serialize(src.getThreads())); - result.addProperty(ROBOT_ADDRESS_TAG, src.getRobotAddress()); - - String proxyingFor = src.getProxyingFor(); - if (proxyingFor != null && !proxyingFor.isEmpty()) { - result.addProperty(PROXYING_FOR_TAG, proxyingFor); - } - - String rpcServerUrl = src.getRpcServerUrl(); - if (rpcServerUrl != null && !rpcServerUrl.isEmpty()) { - result.addProperty(RPC_SERVER_URL_TAG, rpcServerUrl); - } - return result; - } - - @Override - public EventMessageBundle deserialize(JsonElement json, Type typeOfT, - JsonDeserializationContext context) throws JsonParseException { - JsonObject jsonObj = json.getAsJsonObject(); - String robotAddress = jsonObj.get(ROBOT_ADDRESS_TAG).getAsString(); - String rpcServerUrl = ""; - if (jsonObj.has(RPC_SERVER_URL_TAG)) { - rpcServerUrl = jsonObj.get(RPC_SERVER_URL_TAG).getAsString(); - } - EventMessageBundle result = new EventMessageBundle(robotAddress, rpcServerUrl); - - OperationQueue operationQueue; - if (jsonObj.has(PROXYING_FOR_TAG)) { - result.setProxyingFor(jsonObj.get(PROXYING_FOR_TAG).getAsString()); - operationQueue = new OperationQueue(new ArrayList<OperationRequest>(), - result.getProxyingFor()); - } else { - operationQueue = new OperationQueue(); - } - - // Deserialize wavelet. - WaveletData waveletData = context.deserialize(jsonObj.get(WAVELET_TAG), WaveletData.class); - result.setWaveletData(waveletData); - Map<String, Blip> blips = new HashMap<String, Blip>(); - Map<String, BlipThread> threads = new HashMap<String, BlipThread>(); - Wavelet wavelet = Wavelet.deserialize(operationQueue, blips, threads, waveletData); - wavelet.setRobotAddress(robotAddress); - result.setWavelet(wavelet); - - // Deserialize threads. - Map<String, BlipThread> tempThreads = context.deserialize(jsonObj.get(THREADS_TAG), - GsonFactory.THREAD_MAP_TYPE); - for (Entry<String, BlipThread> entry : tempThreads.entrySet()) { - BlipThread thread = entry.getValue(); - threads.put(entry.getKey(), new BlipThread(thread.getId(), thread.getLocation(), - thread.getBlipIds(), blips)); - } - - // Deserialize blips. - Map<String, BlipData> blipDatas = context.deserialize(jsonObj.get(BLIPS_TAG), - GsonFactory.BLIP_MAP_TYPE); - result.setBlipData(blipDatas); - for(Entry<String, BlipData> entry : blipDatas.entrySet()) { - blips.put(entry.getKey(), Blip.deserialize(operationQueue, wavelet, entry.getValue())); - } - - // Deserialize events. - JsonArray eventsArray = jsonObj.get(EVENTS_TAG).getAsJsonArray(); - List<Event> events = new ArrayList<Event>(eventsArray.size()); - for (JsonElement element : eventsArray) { - JsonObject eventObject = element.getAsJsonObject(); - try { - events.add(EventSerializer.deserialize(wavelet, result, eventObject, context)); - } catch (EventSerializationException e) { - throw new JsonParseException(e.getMessage()); - } - } - result.setEvents(events); - return result; - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/com/google/wave/api/impl/GsonFactory.java ---------------------------------------------------------------------- diff --git a/wave/src/main/java/com/google/wave/api/impl/GsonFactory.java b/wave/src/main/java/com/google/wave/api/impl/GsonFactory.java deleted file mode 100644 index fd9dce1..0000000 --- a/wave/src/main/java/com/google/wave/api/impl/GsonFactory.java +++ /dev/null @@ -1,252 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package com.google.wave.api.impl; - -import com.google.common.collect.Lists; -import com.google.gson.*; -import com.google.gson.reflect.TypeToken; -import com.google.wave.api.Annotation; -import com.google.wave.api.Attachment; -import com.google.wave.api.BlipData; -import com.google.wave.api.Element; -import com.google.wave.api.JsonRpcResponse; -import com.google.wave.api.NonJsonSerializable; -import com.google.wave.api.OperationRequest; -import com.google.wave.api.Range; -import com.google.wave.api.BlipThread; -import com.google.wave.api.SearchResult; - -import org.apache.commons.codec.binary.Base64; -import org.waveprotocol.wave.model.id.WaveletId; - -import java.lang.reflect.Type; -import java.util.*; -import java.util.Map.Entry; -import java.io.UnsupportedEncodingException; - -/** - * A factory to instantiate a {@link Gson} instance, with pre-registered type - * adapters for serializing and deserializing Wave API classes that are used - * as data transfer objects. - */ -public class GsonFactory { - - public static final Type BLIP_MAP_TYPE = new TypeToken<Map<String, BlipData>>(){}.getType(); - public static final Type PARTICIPANT_LIST_TYPE = new TypeToken<List<String>>(){}.getType(); - public static final Type THREAD_MAP_TYPE = new TypeToken<Map<String, BlipThread>>(){}.getType(); - public static final Type STRING_MAP_TYPE = new TypeToken<Map<String, String>>(){}.getType(); - public static final Type WAVELET_ID_LIST_TYPE = new TypeToken<List<WaveletId>>(){}.getType(); - public static final Type RAW_DELTAS_TYPE = new TypeToken<List<byte[]>>(){}.getType(); - public static final Type RAW_ATTACHMENT_MAP_TYPE = new TypeToken<Map<String, RawAttachmentData>>(){} - .getType(); - public static final Type OPERATION_REQUEST_LIST_TYPE = new TypeToken<List<OperationRequest>>(){} - .getType(); - public static final Type JSON_RPC_RESPONSE_LIST_TYPE = new TypeToken<List<JsonRpcResponse>>(){} - .getType(); - - /** Additional type adapters. */ - private final Map<Type, Object> customTypeAdapters = new LinkedHashMap<Type, Object>(); - - /** - * Registers a custom type adapter. - * - * @param type the type that will be handled by the given adapter. - * @param typeAdapter the adapter that performs the serialization and - * deserialization. - */ - public void registerTypeAdapter(Type type, Object typeAdapter) { - customTypeAdapters.put(type, typeAdapter); - } - - /** - * Creates a {@link Gson} instance, with additional type adapters for these - * types: - * <ul> - * <li>{@link EventMessageBundle}</li> - * <li>{@link OperationRequest}</li> - * <li>{@link Element}</li> - * </ul> - * - * @return an instance of {@link Gson} with pre-registered type adapters. - */ - public Gson create() { - return create(""); - } - - /** - * Creates a {@link Gson} instance, with additional type adapters for these - * types: - * <ul> - * <li>{@link EventMessageBundle}</li> - * <li>{@link OperationRequest}</li> - * <li>{@link Element}</li> - * <li>{@link JsonRpcResponse}</li> - * </ul> - * - * @param opNamespace prefix that should be prepended to the operation during - * serialization. - * @return an instance of {@link Gson} with pre-registered type adapters. - */ - public Gson create(String opNamespace) { - ElementGsonAdaptor elementGsonAdaptor = new ElementGsonAdaptor(); - GsonBuilder builder = new GsonBuilder() - .setExclusionStrategies(new NonSerializableExclusionStrategy()) - .registerTypeAdapter(EventMessageBundle.class, new EventMessageBundleGsonAdaptor()) - .registerTypeAdapter(OperationRequest.class, new OperationRequestGsonAdaptor(opNamespace)) - .registerTypeAdapter(Element.class, elementGsonAdaptor) - .registerTypeAdapter(Attachment.class, elementGsonAdaptor) - .registerTypeAdapter(JsonRpcResponse.class, new JsonRpcResponseGsonAdaptor()) - .registerTypeAdapter(Annotation.class, new AnnotationInstanceCreator()) - .registerTypeAdapter(Range.class, new RangeInstanceCreator()) - .registerTypeAdapter(BlipThread.class, new ThreadInstanceCreator()) - .registerTypeAdapter(SearchResult.class, new SearchResultInstanceCreator()) - .registerTypeAdapter(SearchResult.Digest.class, new SearchResultDigestInstanceCreator()) - .registerTypeAdapter(WaveletId.class, new WaveletIdInstanceCreator()) - .registerTypeAdapter(RawAttachmentData.class, new AttachmentDataInstanceCreator()) - .registerTypeAdapter(byte[].class, new ByteArrayGsonAdaptor()); - - // Register custom type adapters. - for (Entry<Type, Object> entry : customTypeAdapters.entrySet()) { - builder.registerTypeAdapter(entry.getKey(), entry.getValue()); - } - - return builder.serializeNulls().create(); - } - - /** - * A strategy definition that excludes all fields that are annotated with - * {@link NonJsonSerializable}. - */ - private static class NonSerializableExclusionStrategy implements ExclusionStrategy { - - @Override - public boolean shouldSkipClass(Class<?> clazz) { - return false; - } - - @Override - public boolean shouldSkipField(FieldAttributes f) { - return f.getAnnotation(NonJsonSerializable.class) != null; - } - } - - /** - * An instance creator that creates an empty {@link Annotation}. - */ - private static class AnnotationInstanceCreator implements InstanceCreator<Annotation> { - @Override - public Annotation createInstance(Type type) { - return new Annotation("", "", -1, -1); - } - } - - /** - * An instance creator that creates an empty {@link Annotation}. - */ - private static class RangeInstanceCreator implements InstanceCreator<Range> { - @Override - public Range createInstance(Type type) { - return new Range(-1, -1); - } - } - - /** - * An instance creator that creates an empty {@link BlipThread}. - */ - private static class ThreadInstanceCreator implements InstanceCreator<BlipThread> { - @Override - public BlipThread createInstance(Type type) { - return new BlipThread(null, -1, null, null); - } - } - - /** - * An instance creator that creates an empty {@link SearchResult}. - */ - private static class SearchResultInstanceCreator implements InstanceCreator<SearchResult> { - @Override - public SearchResult createInstance(Type type) { - return new SearchResult(""); - } - } - - /** - * An instance creator that creates an empty {@link SearchResult.Digest}. - */ - private static class SearchResultDigestInstanceCreator implements - InstanceCreator<SearchResult.Digest> { - @Override - public SearchResult.Digest createInstance(Type type) { - List<String> participants = Lists.newLinkedList(); - return new SearchResult.Digest("", "", "", participants, -1, -1, -1, -1); - } - } - - /** - * An instance creator that creates an empty {@link WaveletId}. - */ - private static class WaveletIdInstanceCreator implements - InstanceCreator<WaveletId> { - @Override - public WaveletId createInstance(Type type) { - return WaveletId.of("dummy", "dummy"); - } - } - - /** - * An instance creator that creates an empty {@link AttachmentData}. - */ - private static class AttachmentDataInstanceCreator implements InstanceCreator<RawAttachmentData> { - @Override - public RawAttachmentData createInstance(Type type) { - return new RawAttachmentData("", "", new byte[0]); - } - } - - /** - * An instance creator serializer and deserializer that creates - * serializes and deserializes an empty {@link ByteString}. - */ - private static class ByteArrayGsonAdaptor implements InstanceCreator<byte[]>, - JsonSerializer<byte[]>, JsonDeserializer<byte[]> { - @Override - public byte[] createInstance(Type type) { - return new byte[0]; - } - - @Override - public JsonElement serialize(byte[] bytes, Type type, JsonSerializationContext jsc) { - try { - return new JsonPrimitive(new String(Base64.encodeBase64(bytes), "UTF-8")); - } catch (UnsupportedEncodingException ex) { - throw new RuntimeException(ex); - } - } - - @Override - public byte[] deserialize(JsonElement je, Type type, JsonDeserializationContext jdc) throws JsonParseException { - try { - return Base64.decodeBase64(je.getAsString().getBytes("UTF-8")); - } catch (UnsupportedEncodingException ex) { - throw new RuntimeException(ex); - } - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/com/google/wave/api/impl/JsonRpcResponseGsonAdaptor.java ---------------------------------------------------------------------- diff --git a/wave/src/main/java/com/google/wave/api/impl/JsonRpcResponseGsonAdaptor.java b/wave/src/main/java/com/google/wave/api/impl/JsonRpcResponseGsonAdaptor.java deleted file mode 100644 index f6a02b3..0000000 --- a/wave/src/main/java/com/google/wave/api/impl/JsonRpcResponseGsonAdaptor.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package com.google.wave.api.impl; - -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; - -import com.google.wave.api.JsonRpcResponse; -import com.google.wave.api.JsonRpcConstant.ParamsProperty; -import com.google.wave.api.JsonRpcConstant.ResponseProperty; - -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; - -/** - * Custom serializer and deserializer that serializes and deserializes a - * {@link JsonRpcResponse}. - * - * @author [email protected] (Marcel Prasetya) - */ -public class JsonRpcResponseGsonAdaptor implements JsonDeserializer<JsonRpcResponse>, - JsonSerializer<JsonRpcResponse>{ - - @Override - public JsonRpcResponse deserialize(JsonElement json, Type type, - JsonDeserializationContext context) throws JsonParseException { - JsonObject jsonObject = json.getAsJsonObject(); - - String id = jsonObject.get(ResponseProperty.ID.key()).getAsString(); - if (jsonObject.has(ResponseProperty.ERROR.key())) { - JsonElement errorObject = jsonObject.get(ResponseProperty.ERROR.key()); - String errorMessage = errorObject.getAsJsonObject().get("message").getAsString(); - return JsonRpcResponse.error(id, errorMessage); - } - - // Deserialize the data. - Map<ParamsProperty, Object> properties = new HashMap<ParamsProperty, Object>(); - JsonElement data = jsonObject.get(ResponseProperty.DATA.key()); - if (data != null && data.isJsonObject()) { - for (Entry<String, JsonElement> parameter : data.getAsJsonObject().entrySet()) { - ParamsProperty parameterType = ParamsProperty.fromKey(parameter.getKey()); - if (parameterType == null) { - // Skip this unknown parameter. - continue; - } - Object object = null; - if (parameterType == ParamsProperty.BLIPS) { - object = context.deserialize(parameter.getValue(), GsonFactory.BLIP_MAP_TYPE); - } else if (parameterType == ParamsProperty.PARTICIPANTS_ADDED || - parameterType == ParamsProperty.PARTICIPANTS_REMOVED) { - object = context.deserialize(parameter.getValue(), GsonFactory.PARTICIPANT_LIST_TYPE); - } else if (parameterType == ParamsProperty.THREADS) { - object = context.deserialize(parameter.getValue(), GsonFactory.THREAD_MAP_TYPE); - } else if (parameterType == ParamsProperty.WAVELET_IDS) { - object = context.deserialize(parameter.getValue(), GsonFactory.WAVELET_ID_LIST_TYPE); - } else if (parameterType == ParamsProperty.RAW_DELTAS) { - object = context.deserialize(parameter.getValue(), GsonFactory.RAW_DELTAS_TYPE); - } else { - object = context.deserialize(parameter.getValue(), parameterType.clazz()); - } - properties.put(parameterType, object); - } - } - - return JsonRpcResponse.result(id, properties); - } - - @Override - public JsonElement serialize(JsonRpcResponse src, Type type, JsonSerializationContext context) { - JsonObject result = new JsonObject(); - result.addProperty(ResponseProperty.ID.key(), src.getId()); - if (src.isError()) { - JsonObject error = new JsonObject(); - error.addProperty(ParamsProperty.MESSAGE.key(), src.getErrorMessage()); - result.add(ResponseProperty.ERROR.key(), error); - } else { - JsonObject data = new JsonObject(); - for (Entry<ParamsProperty, Object> properties : src.getData().entrySet()) { - data.add(properties.getKey().key(), context.serialize(properties.getValue())); - } - result.add(ResponseProperty.DATA.key(), data); - } - return result; - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/com/google/wave/api/impl/OperationRequestGsonAdaptor.java ---------------------------------------------------------------------- diff --git a/wave/src/main/java/com/google/wave/api/impl/OperationRequestGsonAdaptor.java b/wave/src/main/java/com/google/wave/api/impl/OperationRequestGsonAdaptor.java deleted file mode 100644 index 11e225f..0000000 --- a/wave/src/main/java/com/google/wave/api/impl/OperationRequestGsonAdaptor.java +++ /dev/null @@ -1,137 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package com.google.wave.api.impl; - -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; -import com.google.wave.api.OperationRequest; -import com.google.wave.api.JsonRpcConstant.ParamsProperty; -import com.google.wave.api.JsonRpcConstant.RequestProperty; -import com.google.wave.api.OperationRequest.Parameter; - -import java.lang.reflect.Type; -import java.util.Map.Entry; - -/** - * Custom serializer and deserializer that serializes and deserializes an - * {@link OperationRequest}. - * - * @author [email protected] (Marcel Prasetya) - */ -public class OperationRequestGsonAdaptor implements JsonSerializer<OperationRequest>, - JsonDeserializer<OperationRequest> { - - /** - * A namespace that should be prepended to the operation method during - * serialization. - */ - private final String operationNamespace; - - /** - * Constructor. - */ - public OperationRequestGsonAdaptor() { - this(""); - } - - /** - * Constructor. - * - * @param operationNamespace namespace that should be prepended to the - * operation method during serialization. - */ - public OperationRequestGsonAdaptor(String operationNamespace) { - if (operationNamespace != null && !operationNamespace.isEmpty() && - !operationNamespace.endsWith(".")) { - operationNamespace += "."; - } - this.operationNamespace = operationNamespace; - } - - @Override - public JsonElement serialize(OperationRequest req, Type type, JsonSerializationContext ctx) { - JsonObject object = new JsonObject(); - object.addProperty(RequestProperty.METHOD.key(), operationNamespace + req.getMethod()); - object.addProperty(RequestProperty.ID.key(), req.getId()); - - JsonObject parameters = new JsonObject(); - for (Entry<ParamsProperty, Object> entry : req.getParams().entrySet()) { - if (entry.getValue() != null) { - parameters.add(entry.getKey().key(), ctx.serialize(entry.getValue())); - } - } - object.add(RequestProperty.PARAMS.key(), parameters); - return object; - } - - @Override - public OperationRequest deserialize(JsonElement json, Type type, JsonDeserializationContext ctx) - throws JsonParseException { - JsonObject jsonObject = json.getAsJsonObject(); - JsonObject parameters = jsonObject.getAsJsonObject(RequestProperty.PARAMS.key()); - - OperationRequest request = new OperationRequest( - jsonObject.get(RequestProperty.METHOD.key()).getAsString(), - jsonObject.get(RequestProperty.ID.key()).getAsString(), - getPropertyAsStringThenRemove(parameters, ParamsProperty.WAVE_ID), - getPropertyAsStringThenRemove(parameters, ParamsProperty.WAVELET_ID), - getPropertyAsStringThenRemove(parameters, ParamsProperty.BLIP_ID)); - - for (Entry<String, JsonElement> parameter : parameters.entrySet()) { - ParamsProperty parameterType = ParamsProperty.fromKey(parameter.getKey()); - if (parameterType != null) { - Object object; - if (parameterType == ParamsProperty.RAW_DELTAS) { - object = ctx.deserialize(parameter.getValue(), GsonFactory.RAW_DELTAS_TYPE); - } else { - object = ctx.deserialize(parameter.getValue(), parameterType.clazz()); - } - request.addParameter(Parameter.of(parameterType, object)); - } - } - - return request; - } - - /** - * Returns a property of {@code JsonObject} as a {@link String}, then remove - * that property. - * - * @param jsonObject the {@code JsonObject} to get the property from. - * @param key the key of the property. - * @return the property as {@link String}, or {@code null} if not found. - */ - private static String getPropertyAsStringThenRemove(JsonObject jsonObject, ParamsProperty key) { - JsonElement property = jsonObject.get(key.key()); - if (property != null) { - jsonObject.remove(key.key()); - if (property.isJsonNull()) { - return null; - } - return property.getAsString(); - } - return null; - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/com/google/wave/api/impl/RawAttachmentData.java ---------------------------------------------------------------------- diff --git a/wave/src/main/java/com/google/wave/api/impl/RawAttachmentData.java b/wave/src/main/java/com/google/wave/api/impl/RawAttachmentData.java deleted file mode 100644 index b291086..0000000 --- a/wave/src/main/java/com/google/wave/api/impl/RawAttachmentData.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package com.google.wave.api.impl; - -/** - * Attachment data. - * - * @author [email protected] (Andrew Kaplanov) - */ -public class RawAttachmentData { - private final String fileName; - private final String creator; - private final byte[] data; - - /** - * Exported raw attachment data. - * - * @param fileName attachment file name. - * @param creator attachment creator. - * @param data attachment data. - */ - public RawAttachmentData(String fileName, String creator, byte[] data) { - this.fileName = fileName; - this.creator = creator; - this.data = data; - } - - public String getFileName() { - return fileName; - } - - public String getCreator() { - return creator; - } - - public byte[] getData() { - return data; - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/com/google/wave/api/impl/RawDeltas.java ---------------------------------------------------------------------- diff --git a/wave/src/main/java/com/google/wave/api/impl/RawDeltas.java b/wave/src/main/java/com/google/wave/api/impl/RawDeltas.java deleted file mode 100644 index ace58c4..0000000 --- a/wave/src/main/java/com/google/wave/api/impl/RawDeltas.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package com.google.wave.api.impl; - -import java.util.List; - -/** - * Exported raw wavelet data. - * - * @author [email protected] (Andrew Kaplanov) - */ -public class RawDeltas { - - private final List<byte[]> rawDeltas; - - /** - * @param rawDeltas serialized ProtocolWaveletDelta. - */ - public RawDeltas(List<byte[]> rawDeltas) { - this.rawDeltas = rawDeltas; - } - - public List<byte[]> getDeltas() { - return rawDeltas; - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/com/google/wave/api/impl/RawDeltasListener.java ---------------------------------------------------------------------- diff --git a/wave/src/main/java/com/google/wave/api/impl/RawDeltasListener.java b/wave/src/main/java/com/google/wave/api/impl/RawDeltasListener.java deleted file mode 100644 index 662e165..0000000 --- a/wave/src/main/java/com/google/wave/api/impl/RawDeltasListener.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package com.google.wave.api.impl; - -import java.util.List; - -/** - * Listener to receive exported deltas. - * - * @author [email protected] (Andrew Kaplanov) - */ -public interface RawDeltasListener { - - /** - * @param rawDeltas serialized ProtocolWaveletDelta. - * @param rawTargetVersion serialized ProtocolHashedVersion. - */ - public void onSuccess(List<byte[]> rawDeltas, byte[] rawTargetVersion); - - public void onFailire(String message); -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/com/google/wave/api/impl/Tuple.java ---------------------------------------------------------------------- diff --git a/wave/src/main/java/com/google/wave/api/impl/Tuple.java b/wave/src/main/java/com/google/wave/api/impl/Tuple.java deleted file mode 100644 index af1040f..0000000 --- a/wave/src/main/java/com/google/wave/api/impl/Tuple.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package com.google.wave.api.impl; - -import java.util.Arrays; - -/** - * An immutable tuple of values that can be accessed using {@link #get} method. - * - * @author [email protected] (Marcel Prasetya) - * @param <A> Type of the tuple element. - */ -public class Tuple<A> { - - /** - * The elements of the tuple. - */ - private final A[] elements; - - /** - * Factory method to create a tuple. - * - * @param <A> Type of the tuple element. - * @param elements The elements of the tuple - * @return A new tuple that contains {@code elements} - */ - @SuppressWarnings("unchecked") - public static <A> Tuple<A> of(A ... elements) { - return new Tuple<A>(elements); - } - - /** - * Constructor. - * - * @param elements The elements of the tuple. - */ - @SuppressWarnings("unchecked") - public Tuple(A ... elements) { - this.elements = elements; - } - - /** - * Returns the {@code index}th element of the tuple. - * - * @param index The index of the element. - * @return The {@code index}th element of the tuple. - */ - public A get(int index) { - return elements[index]; - } - - /** - * Returns the number of elements in the tuple. - * - * @return the number of elements in the tuple. - */ - public int size() { - return elements.length; - } - - @SuppressWarnings("unchecked") - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - - if (o == null || o.getClass() != this.getClass()) { - return false; - } - - Tuple<A> o2 = (Tuple<A>) o; - return Arrays.equals(elements, o2.elements); - } - - @Override - public int hashCode() { - return Arrays.hashCode(elements); - } - - @Override - public String toString() { - return Arrays.toString(elements); - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/com/google/wave/api/impl/WaveletData.java ---------------------------------------------------------------------- diff --git a/wave/src/main/java/com/google/wave/api/impl/WaveletData.java b/wave/src/main/java/com/google/wave/api/impl/WaveletData.java deleted file mode 100644 index 778d316..0000000 --- a/wave/src/main/java/com/google/wave/api/impl/WaveletData.java +++ /dev/null @@ -1,210 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package com.google.wave.api.impl; - -import com.google.wave.api.BlipThread; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * The data representation of Wavelet metadata used to serialize and send to - * the Robot. - * - * @author [email protected] (Seth Covitz) - */ -public class WaveletData { - - private long creationTime = -1L; - private long lastModifiedTime = -1L; - private long version = -1L; - private List<String> participants = new ArrayList<String>(); - private Map<String, String> participantRoles = new HashMap<String, String>(); - private Map<String, String> dataDocuments = new HashMap<String, String>(); - private List<String> tags = new ArrayList<String>(); - private String creator; - private String rootBlipId; - private String title; - private String waveId; - private String waveletId; - private BlipThread rootThread; - - public WaveletData() { - // TODO(mprasetya): Please remove this ctor. It is currently being used for - // deserialization. - } - - public WaveletData(String waveId, String waveletId, String rootBlipId, - BlipThread rootThread) { - this.waveId = waveId; - this.waveletId = waveletId; - this.rootBlipId = rootBlipId; - this.rootThread = rootThread; - } - - public WaveletData(WaveletData wavelet) { - this.creationTime = wavelet.getCreationTime(); - this.creator = wavelet.getCreator(); - this.lastModifiedTime = wavelet.getLastModifiedTime(); - this.participants = wavelet.getParticipants(); - this.participantRoles = new HashMap<String, String>(wavelet.getParticipantRoles()); - this.rootBlipId = wavelet.getRootBlipId(); - this.title = wavelet.getTitle(); - this.version = wavelet.getVersion(); - this.waveId = wavelet.getWaveId(); - this.waveletId = wavelet.getWaveletId(); - this.dataDocuments = new HashMap<String, String>(wavelet.getDataDocuments()); - this.tags = new ArrayList<String>(wavelet.getTags()); - } - - /** - * @returns a map of participantId to role for participants that don't have - * the default role. - */ - public Map<String, String> getParticipantRoles() { - return participantRoles; - } - - public long getCreationTime() { - return creationTime; - } - - public String getCreator() { - return creator; - } - - public long getLastModifiedTime() { - return lastModifiedTime; - } - - public List<String> getParticipants() { - return participants; - } - - public String getRootBlipId() { - return rootBlipId; - } - - public String getTitle() { - return title; - } - - public long getVersion() { - return version; - } - - public String getWaveId() { - return waveId; - } - - public String getWaveletId() { - return waveletId; - } - - public void setCreationTime(long creationTime) { - this.creationTime = creationTime; - } - - public void setCreator(String creator) { - this.creator = creator; - } - - public void setLastModifiedTime(long lastModifiedTime) { - this.lastModifiedTime = lastModifiedTime; - } - - public void setParticipants(List<String> participants) { - this.participants = participants; - } - - public void setRootBlipId(String rootBlipId) { - this.rootBlipId = rootBlipId; - } - - public void setTitle(String title) { - this.title = title; - } - - public void setVersion(long version) { - this.version = version; - } - - public void setWaveId(String waveId) { - this.waveId = waveId; - } - - public void setWaveletId(String waveletId) { - this.waveletId = waveletId; - } - - public Map<String, String> getDataDocuments() { - return dataDocuments; - } - - public void setDataDocuments(Map<String, String> dataDocuments) { - this.dataDocuments = new HashMap<String, String>(dataDocuments); - } - - public void setDataDocument(String name, String data) { - dataDocuments.put(name, data); - } - - public String getDataDocument(String name) { - if (dataDocuments == null) { - return null; - } else { - return dataDocuments.get(name); - } - } - - public List<String> getTags() { - return tags; - } - - public void setTags(List<String> tags) { - this.tags = new ArrayList<String>(tags); - } - - public void addTag(String tag) { - tags.add(tag); - } - - public void removeTag(String tag) { - tags.remove(tag); - } - - public void addParticipant(String participant) { - participants.add(participant); - } - - public void setParticipantRole(String participant, String role) { - participantRoles.put(participant, role); - } - - public BlipThread getRootThread() { - return rootThread; - } - - public void setRootThread(BlipThread rootThread) { - this.rootThread = rootThread; - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/com/google/wave/api/oauth/LoginFormHandler.java ---------------------------------------------------------------------- diff --git a/wave/src/main/java/com/google/wave/api/oauth/LoginFormHandler.java b/wave/src/main/java/com/google/wave/api/oauth/LoginFormHandler.java deleted file mode 100644 index d1c9ae8..0000000 --- a/wave/src/main/java/com/google/wave/api/oauth/LoginFormHandler.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package com.google.wave.api.oauth; - -import com.google.wave.api.Wavelet; - -/** - * Interface that handles the rendering in the wave of a login form in the wave - * to direct the user to authorize access to the service provider's resources. - * - * @author [email protected] (Elizabeth Ford) - */ -public interface LoginFormHandler { - - /** - * Renders a link to the service provider's login page and a confirmation - * button to press when login is complete. - * - * @param userRecordKey The user id. - * @param wavelet The wavelet to which the robot is added. - */ - void renderLogin(String userRecordKey, Wavelet wavelet); -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/com/google/wave/api/oauth/OAuthService.java ---------------------------------------------------------------------- diff --git a/wave/src/main/java/com/google/wave/api/oauth/OAuthService.java b/wave/src/main/java/com/google/wave/api/oauth/OAuthService.java deleted file mode 100644 index faf3813..0000000 --- a/wave/src/main/java/com/google/wave/api/oauth/OAuthService.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package com.google.wave.api.oauth; - -import com.google.wave.api.Wavelet; -import com.google.wave.api.oauth.impl.OAuthServiceException; - -import java.util.Map; - -/** - * Generic OAuthService to handle OAuth tokens and to form OAuth urls. - * - * @author [email protected] (Elizabeth Ford) - * @author [email protected] (Kimberly White) - */ -public interface OAuthService { - - /** - * Verifies that the user profile contains a request token (i.e. user has - * logged in). If user profile does not exist or does not contain a request - * token, fetches a request token and renders the login form so the request - * token can be signed. - * - * If the user profile contains a request token and "confirmed" is true, - * exchanges the signed request token with the service provider for an access - * token. - * - * @param wavelet The wavelet on which the robot resides. - * @param loginForm the form that handles user authorization in wave. - * @return boolean True if user is authorized, false if rendering a login form - * to authorize the user is required. - */ - boolean checkAuthorization(Wavelet wavelet, LoginFormHandler loginForm); - - /** - * Checks if the user is authorized. - * - * @return True if the user has an access token. - */ - boolean hasAuthorization(); - - /** - * Performs HTTP POST to the Service provider. - * - * @param url Service provider url to post data. - * @param parameters Service provider parameters. - * @return String of the response message. - * @throws com.google.wave.api.oauth.impl.OAuthServiceException; - */ - String post(String url, Map<String, String> parameters) - throws OAuthServiceException; - - /** - * Performs HTTP GET from the Service provider. - * - * @param url Service provider url to fetch resources. - * @param parameters Service provider parameters. - * @return String of the response message. - * @throws com.google.wave.api.oauth.impl.OAuthServiceException; - */ - String get(String url, Map<String, String> parameters) - throws OAuthServiceException; -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/com/google/wave/api/oauth/impl/OAuthServiceException.java ---------------------------------------------------------------------- diff --git a/wave/src/main/java/com/google/wave/api/oauth/impl/OAuthServiceException.java b/wave/src/main/java/com/google/wave/api/oauth/impl/OAuthServiceException.java deleted file mode 100644 index 704155f..0000000 --- a/wave/src/main/java/com/google/wave/api/oauth/impl/OAuthServiceException.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package com.google.wave.api.oauth.impl; - -/** - * A checked exception thrown by the Java robot oauth library. - * - * @author [email protected] (Kimberly White) - */ -public class OAuthServiceException extends Exception { - - /* - * Class constructor. - */ - public OAuthServiceException() { - } - - /* - * Overloaded constructor. - * - * @param message The exception message. - */ - public OAuthServiceException(String message) { - super(message); - } - - /* - * Overloaded constructor. - * - * @param cause The exception cause. - */ - public OAuthServiceException(Throwable cause) { - super(cause); - } - - /* - * Overloaded constructor. - * - * @param message The exception message. - * @param cause The exception cause. - */ - public OAuthServiceException(String message, Throwable cause) { - super(message, cause); - } -}
