| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| Activity |
|
| 0.0;0 | ||||
| Activity$Field |
|
| 0.0;0 |
| 1 | /* | |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one | |
| 3 | * or more contributor license agreements. See the NOTICE file | |
| 4 | * distributed with this work for additional information | |
| 5 | * regarding copyright ownership. The ASF licenses this file | |
| 6 | * to you under the Apache License, Version 2.0 (the | |
| 7 | * "License"); you may not use this file except in compliance | |
| 8 | * with the License. You may obtain a copy of the License at | |
| 9 | * | |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 11 | * | |
| 12 | * Unless required by applicable law or agreed to in writing, | |
| 13 | * software distributed under the License is distributed on an | |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
| 15 | * KIND, either express or implied. See the License for the | |
| 16 | * specific language governing permissions and limitations under the License. | |
| 17 | */ | |
| 18 | ||
| 19 | package org.apache.shindig.social.opensocial.model; | |
| 20 | ||
| 21 | import org.apache.shindig.social.core.model.ActivityImpl; | |
| 22 | ||
| 23 | import com.google.inject.ImplementedBy; | |
| 24 | import java.util.Date; | |
| 25 | import java.util.List; | |
| 26 | import java.util.Map; | |
| 27 | ||
| 28 | /** | |
| 29 | * see http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.Activity.Field for all | |
| 30 | * field meanings. All fields are represented in the js api at this time except for lastUpdated. | |
| 31 | * This field is currently only in the RESTful spec. | |
| 32 | * | |
| 33 | * <p> | |
| 34 | * Representation of an activity. | |
| 35 | * <p> | |
| 36 | * </p> | |
| 37 | * Activities are rendered with a title and an optional activity body. | |
| 38 | * <p> | |
| 39 | * </p> | |
| 40 | * You may set the title and body directly as strings when calling opensocial.newActivity. However, | |
| 41 | * it is usually beneficial to create activities using Message Templates for the title and body. | |
| 42 | * <p> | |
| 43 | * </p> | |
| 44 | * Users will have many activities in their activity streams, and containers will not show every | |
| 45 | * activity that is visible to a user. To help display large numbers of activities, containers will | |
| 46 | * summarize a list of activities from a given source to a single entry. | |
| 47 | * <p> | |
| 48 | * </p> | |
| 49 | * You can provide Activity Summaries to customize the text shown when multiple activities are | |
| 50 | * summarized. If no customization is provided, a container may ignore your activities altogether or | |
| 51 | * provide default text such as "Bob changed his status message + 20 other events like this." | |
| 52 | * <ul> | |
| 53 | * <li> Activity Summaries will always summarize around a specific key in a key/value pair. This is | |
| 54 | * so that the summary can say something concrete (this is clearer in the example below). </li> | |
| 55 | * <li> Other variables will have synthetic "Count" variables created with the total number of items | |
| 56 | * summarized. </li> | |
| 57 | * <li> Message ID of the summary is the message ID of the main template + ":" + the data key </li> | |
| 58 | * </ul> | |
| 59 | * | |
| 60 | * <code><pre> | |
| 61 | * <messagebundle> | |
| 62 | * <msg name="LISTEN_TO_THIS_SONG:Artist"> | |
| 63 | * ${Subject.Count} of your friends have suggested listening to songs | |
| 64 | * by ${Artist}! | |
| 65 | * </msg> | |
| 66 | * <msg name="LISTEN_TO_THIS_SONG:Song"> | |
| 67 | * ${Subject.Count} of your friends have suggested listening to ${Song} | |
| 68 | * !</msg> | |
| 69 | * <msg name="LISTEN_TO_THIS_SONG:Subject"> | |
| 70 | * ${Subject.DisplayName} has recommended ${Song.Count} songs to you. | |
| 71 | * </msg> | |
| 72 | * </messagebundle> | |
| 73 | * </pre></code> | |
| 74 | * | |
| 75 | */ | |
| 76 | @ImplementedBy(ActivityImpl.class) | |
| 77 | @Exportablebean | |
| 78 | public interface Activity { | |
| 79 | ||
| 80 | /** | |
| 81 | * The fields that represent the activity object ion json form. | |
| 82 | * | |
| 83 | * <p> | |
| 84 | * All of the fields that activities can have. | |
| 85 | * </p> | |
| 86 | * <p> | |
| 87 | * It is only OPTIONAL to set one of TITLE_ID or TITLE. In addition, if you are using any | |
| 88 | * variables in your title or title template, you must set TEMPLATE_PARAMS. | |
| 89 | * </p> | |
| 90 | * <p> | |
| 91 | * Other possible fields to set are: URL, MEDIA_ITEMS, BODY_ID, BODY, EXTERNAL_ID, PRIORITY, | |
| 92 | * STREAM_TITLE, STREAM_URL, STREAM_SOURCE_URL, and STREAM_FAVICON_URL. | |
| 93 | * </p> | |
| 94 | * <p> | |
| 95 | * Containers are only OPTIONAL to use TITLE_ID or TITLE, they may ignore additional parameters. | |
| 96 | * </p> | |
| 97 | * | |
| 98 | */ | |
| 99 | 1 | public static enum Field { |
| 100 | /** the json field for appId. */ | |
| 101 | 1 | APP_ID("appId"), |
| 102 | /** the json field for body. */ | |
| 103 | 1 | BODY("body"), |
| 104 | /** the json field for bodyId. */ | |
| 105 | 1 | BODY_ID("bodyId"), |
| 106 | /** the json field for externalId. */ | |
| 107 | 1 | EXTERNAL_ID("externalId"), |
| 108 | /** the json field for id. */ | |
| 109 | 1 | ID("id"), |
| 110 | /** the json field for updated. */ | |
| 111 | 1 | LAST_UPDATED("updated"), /* Needed to support the RESTful api */ |
| 112 | /** the json field for mediaItems. */ | |
| 113 | 1 | MEDIA_ITEMS("mediaItems"), |
| 114 | /** the json field for postedTime. */ | |
| 115 | 1 | POSTED_TIME("postedTime"), |
| 116 | /** the json field for priority. */ | |
| 117 | 1 | PRIORITY("priority"), |
| 118 | /** the json field for streamFaviconUrl. */ | |
| 119 | 1 | STREAM_FAVICON_URL("streamFaviconUrl"), |
| 120 | /** the json field for streamSourceUrl. */ | |
| 121 | 1 | STREAM_SOURCE_URL("streamSourceUrl"), |
| 122 | /** the json field for streamTitle. */ | |
| 123 | 1 | STREAM_TITLE("streamTitle"), |
| 124 | /** the json field for streamUrl. */ | |
| 125 | 1 | STREAM_URL("streamUrl"), |
| 126 | /** the json field for templateParams. */ | |
| 127 | 1 | TEMPLATE_PARAMS("templateParams"), |
| 128 | /** the json field for title. */ | |
| 129 | 1 | TITLE("title"), |
| 130 | /** the json field for titleId. */ | |
| 131 | 1 | TITLE_ID("titleId"), |
| 132 | /** the json field for url. */ | |
| 133 | 1 | URL("url"), |
| 134 | /** the json field for userId. */ | |
| 135 | 1 | USER_ID("userId"); |
| 136 | ||
| 137 | /** | |
| 138 | * The json field that the instance represents. | |
| 139 | */ | |
| 140 | private final String jsonString; | |
| 141 | ||
| 142 | /** | |
| 143 | * create a field base on the a json element. | |
| 144 | * | |
| 145 | * @param jsonString the name of the element | |
| 146 | */ | |
| 147 | 18 | private Field(String jsonString) { |
| 148 | 18 | this.jsonString = jsonString; |
| 149 | 18 | } |
| 150 | ||
| 151 | /** | |
| 152 | * emit the field as a json element. | |
| 153 | * | |
| 154 | * @return the field name | |
| 155 | */ | |
| 156 | @Override | |
| 157 | public String toString() { | |
| 158 | 21 | return jsonString; |
| 159 | } | |
| 160 | } | |
| 161 | ||
| 162 | /** | |
| 163 | * Get a string specifying the application that this activity is associated with. Container | |
| 164 | * support for this field is REQUIRED. | |
| 165 | * | |
| 166 | * @return A string specifying the application that this activity is associated with | |
| 167 | */ | |
| 168 | String getAppId(); | |
| 169 | ||
| 170 | /** | |
| 171 | * Set a string specifying the application that this activity is associated with. Container | |
| 172 | * support for this field is REQUIRED. | |
| 173 | * | |
| 174 | * @param appId A string specifying the application that this activity is associated with | |
| 175 | */ | |
| 176 | void setAppId(String appId); | |
| 177 | ||
| 178 | /** | |
| 179 | * Get a string specifying an optional expanded version of an activity. Container support for this | |
| 180 | * field is OPTIONAL. | |
| 181 | * | |
| 182 | * @return a string specifying an optional expanded version of an activity. | |
| 183 | */ | |
| 184 | String getBody(); | |
| 185 | ||
| 186 | /** | |
| 187 | * Set a string specifying an optional expanded version of an activity. Container support for this | |
| 188 | * field is OPTIONAL. | |
| 189 | * | |
| 190 | * Bodies may only have the following HTML tags:<b> <i>, <a>, <span>. The | |
| 191 | * container may ignore this formatting when rendering the activity. | |
| 192 | * | |
| 193 | * | |
| 194 | * @param body a string specifying an optional expanded version of an activity. | |
| 195 | */ | |
| 196 | void setBody(String body); | |
| 197 | ||
| 198 | /** | |
| 199 | * Get a string specifying the body template message ID in the gadget spec. Container support for | |
| 200 | * this field is OPTIONAL. | |
| 201 | * | |
| 202 | * Bodies may only have the following HTML tags: <b> <i>, <a>, <span>. The | |
| 203 | * container may ignore this formatting when rendering the activity. | |
| 204 | * | |
| 205 | * @return a string specifying the body template message ID in the gadget spec. | |
| 206 | */ | |
| 207 | String getBodyId(); | |
| 208 | ||
| 209 | /** | |
| 210 | * Set a string specifying the body template message ID in the gadget spec. Container support for | |
| 211 | * this field is OPTIONAL. | |
| 212 | * | |
| 213 | * @param bodyId a string specifying the body template message ID in the gadget spec. | |
| 214 | */ | |
| 215 | void setBodyId(String bodyId); | |
| 216 | ||
| 217 | /** | |
| 218 | * Get an optional string ID generated by the posting application. Container support for this | |
| 219 | * field is OPTIONAL. | |
| 220 | * | |
| 221 | * @return An optional string ID generated by the posting application. | |
| 222 | */ | |
| 223 | String getExternalId(); | |
| 224 | ||
| 225 | /** | |
| 226 | * Set an optional string ID generated by the posting application. Container support for this | |
| 227 | * field is OPTIONAL. | |
| 228 | * | |
| 229 | * @param externalId An optional string ID generated by the posting application. | |
| 230 | */ | |
| 231 | void setExternalId(String externalId); | |
| 232 | ||
| 233 | /** | |
| 234 | * Get a string ID that is permanently associated with this activity. Container support for this | |
| 235 | * field is OPTIONAL. | |
| 236 | * | |
| 237 | * @return a string ID that is permanently associated with this activity. | |
| 238 | */ | |
| 239 | String getId(); | |
| 240 | ||
| 241 | /** | |
| 242 | * Set a string ID that is permanently associated with this activity. Container support for this | |
| 243 | * field is OPTIONAL. | |
| 244 | * | |
| 245 | * @param id a string ID that is permanently associated with this activity. | |
| 246 | */ | |
| 247 | void setId(String id); | |
| 248 | ||
| 249 | /** | |
| 250 | * Get the last updated date of the Activity, additional to the Opensocial specification for the | |
| 251 | * REST-API. Container support for this field is OPTIONAL. | |
| 252 | * | |
| 253 | * @return the last updated date | |
| 254 | */ | |
| 255 | Date getUpdated(); | |
| 256 | ||
| 257 | /** | |
| 258 | * . Set the last updated date of the Activity, additional to the Opensocial specification for the | |
| 259 | * REST-API. Container support for this field is OPTIONAL. | |
| 260 | * | |
| 261 | * @param updated the last updated date | |
| 262 | */ | |
| 263 | void setUpdated(Date updated); | |
| 264 | ||
| 265 | /** | |
| 266 | * Get any photos, videos, or images that should be associated with the activity. | |
| 267 | * | |
| 268 | * Container support for this field is OPTIONAL. | |
| 269 | * | |
| 270 | * @return A List of {@link MediaItem} containing any photos, videos, or images that should be | |
| 271 | * associated with the activity. | |
| 272 | */ | |
| 273 | List<MediaItem> getMediaItems(); | |
| 274 | ||
| 275 | /** | |
| 276 | * Set any photos, videos, or images that should be associated with the activity. Container | |
| 277 | * support for this field is OPTIONAL. | |
| 278 | * | |
| 279 | * Higher priority ones are higher in the list. | |
| 280 | * | |
| 281 | * @param mediaItems a list of {@link MediaItem} to be associated with the activity | |
| 282 | */ | |
| 283 | void setMediaItems(List<MediaItem> mediaItems); | |
| 284 | ||
| 285 | /** | |
| 286 | * Get the time at which this activity took place in milliseconds since the epoch. Container | |
| 287 | * support for this field is OPTIONAL. | |
| 288 | * | |
| 289 | * Higher priority ones are higher in the list. | |
| 290 | * | |
| 291 | * @return The time at which this activity took place in milliseconds since the epoch | |
| 292 | */ | |
| 293 | Long getPostedTime(); | |
| 294 | ||
| 295 | /** | |
| 296 | * Set the time at which this activity took place in milliseconds since the epoch Container | |
| 297 | * support for this field is OPTIONAL. | |
| 298 | * | |
| 299 | * This value can not be set by the end user. | |
| 300 | * | |
| 301 | * @param postedTime the time at which this activity took place in milliseconds since the epoch | |
| 302 | */ | |
| 303 | void setPostedTime(Long postedTime); | |
| 304 | ||
| 305 | /** | |
| 306 | * Get the priority, a number between 0 and 1 representing the relative priority of this activity | |
| 307 | * in relation to other activities from the same source. Container support for this field is | |
| 308 | * OPTIONAL. | |
| 309 | * | |
| 310 | * @return a number between 0 and 1 representing the relative priority of this activity in | |
| 311 | * relation to other activities from the same source | |
| 312 | */ | |
| 313 | Float getPriority(); | |
| 314 | ||
| 315 | /** | |
| 316 | * Set the priority, a number between 0 and 1 representing the relative priority of this activity | |
| 317 | * in relation to other activities from the same source. Container support for this field is | |
| 318 | * OPTIONAL. | |
| 319 | * | |
| 320 | * @param priority a number between 0 and 1 representing the relative priority of this activity in | |
| 321 | * relation to other activities from the same source. | |
| 322 | */ | |
| 323 | void setPriority(Float priority); | |
| 324 | ||
| 325 | /** | |
| 326 | * Get a string specifying the URL for the stream's favicon. Container support for this field is | |
| 327 | * OPTIONAL. | |
| 328 | * | |
| 329 | * @return a string specifying the URL for the stream's favicon. | |
| 330 | */ | |
| 331 | String getStreamFaviconUrl(); | |
| 332 | ||
| 333 | /** | |
| 334 | * Set a string specifying the URL for the stream's favicon. Container support for this field is | |
| 335 | * OPTIONAL. | |
| 336 | * | |
| 337 | * @param streamFaviconUrl a string specifying the URL for the stream's favicon. | |
| 338 | */ | |
| 339 | void setStreamFaviconUrl(String streamFaviconUrl); | |
| 340 | ||
| 341 | /** | |
| 342 | * Get a string specifying the stream's source URL. Container support for this field is OPTIONAL. | |
| 343 | * | |
| 344 | * @return a string specifying the stream's source URL. | |
| 345 | */ | |
| 346 | String getStreamSourceUrl(); | |
| 347 | ||
| 348 | /** | |
| 349 | * Set a string specifying the stream's source URL. Container support for this field is OPTIONAL. | |
| 350 | * | |
| 351 | * @param streamSourceUrl a string specifying the stream's source URL. | |
| 352 | */ | |
| 353 | void setStreamSourceUrl(String streamSourceUrl); | |
| 354 | ||
| 355 | /** | |
| 356 | * Get a string specifing the title of the stream. Container support for this field is OPTIONAL. | |
| 357 | * | |
| 358 | * @return a string specifing the title of the stream. | |
| 359 | */ | |
| 360 | String getStreamTitle(); | |
| 361 | ||
| 362 | /** | |
| 363 | * Set a string specifing the title of the stream. Container support for this field is OPTIONAL. | |
| 364 | * | |
| 365 | * @param streamTitle a string specifing the title of the stream. | |
| 366 | */ | |
| 367 | void setStreamTitle(String streamTitle); | |
| 368 | ||
| 369 | /** | |
| 370 | * Get a string specifying the stream's URL. Container support for this field is OPTIONAL. | |
| 371 | * | |
| 372 | * @return a string specifying the stream's URL. | |
| 373 | */ | |
| 374 | String getStreamUrl(); | |
| 375 | ||
| 376 | /** | |
| 377 | * Set a string specifying the stream's URL. Container support for this field is OPTIONAL. | |
| 378 | * | |
| 379 | * @param streamUrl a string specifying the stream's URL. | |
| 380 | */ | |
| 381 | void setStreamUrl(String streamUrl); | |
| 382 | ||
| 383 | /** | |
| 384 | * Get a map of custom key/value pairs associated with this activity. Container support for this | |
| 385 | * field is OPTIONAL. | |
| 386 | * | |
| 387 | * @return a map of custom key/value pairs associated with this activity. | |
| 388 | */ | |
| 389 | Map<String, String> getTemplateParams(); | |
| 390 | ||
| 391 | /** | |
| 392 | * Set a map of custom key/value pairs associated with this activity. The data has type | |
| 393 | * {@link Map<String, Object>}. The object may be either a String or an {@link Person}. When | |
| 394 | * passing in a person with key PersonKey, can use the following replacement variables in the | |
| 395 | * template: | |
| 396 | * <ul> | |
| 397 | * <li>PersonKey.DisplayName - Display name for the person</li> | |
| 398 | * <li>PersonKey.ProfileUrl. URL of the person's profile</li> | |
| 399 | * <li>PersonKey.Id - The ID of the person</li> | |
| 400 | * <li>PersonKey - Container may replace with DisplayName, but may also optionally link to the | |
| 401 | * user.</li> | |
| 402 | * </ul> | |
| 403 | * Container support for this field is OPTIONAL. | |
| 404 | * | |
| 405 | * @param templateParams a map of custom key/value pairs associated with this activity. | |
| 406 | */ | |
| 407 | void setTemplateParams(Map<String, String> templateParams); | |
| 408 | ||
| 409 | /** | |
| 410 | * Get a string specifying the primary text of an activity. Container support for this field is | |
| 411 | * REQUIRED. | |
| 412 | * | |
| 413 | * Titles may only have the following HTML tags: <b> <i>, <a>, <span>. The | |
| 414 | * container may ignore this formatting when rendering the activity. | |
| 415 | * | |
| 416 | * @return astring specifying the primary text of an activity. | |
| 417 | */ | |
| 418 | String getTitle(); | |
| 419 | ||
| 420 | /** | |
| 421 | * Set a string specifying the primary text of an activity. Container support for this field is | |
| 422 | * REQUIRED. | |
| 423 | * | |
| 424 | * Titles may only have the following HTML tags: <b> <i>, <a>, <span>. The | |
| 425 | * container may ignore this formatting when rendering the activity. | |
| 426 | * | |
| 427 | * @param title a string specifying the primary text of an activity. | |
| 428 | */ | |
| 429 | void setTitle(String title); | |
| 430 | ||
| 431 | /** | |
| 432 | * Get a string specifying the title template message ID in the gadget spec. Container support for | |
| 433 | * this field is REQUIRED. | |
| 434 | * | |
| 435 | * The title is the primary text of an activity. Titles may only have the following HTML tags: | |
| 436 | * <<b> <i>, <a>, <span>. The container may ignore this formatting when | |
| 437 | * rendering the activity. | |
| 438 | * | |
| 439 | * @return a string specifying the title template message ID in the gadget spec. | |
| 440 | */ | |
| 441 | String getTitleId(); | |
| 442 | ||
| 443 | /** | |
| 444 | * Set a string specifying the title template message ID in the gadget spec. Container support for | |
| 445 | * this field is REQUIRED. | |
| 446 | * | |
| 447 | * The title is the primary text of an activity. Titles may only have the following HTML tags: | |
| 448 | * <<b> <i>, <a>, <span>. The container may ignore this formatting when | |
| 449 | * rendering the activity. | |
| 450 | * | |
| 451 | * @param titleId a string specifying the title template message ID in the gadget spec. | |
| 452 | */ | |
| 453 | void setTitleId(String titleId); | |
| 454 | ||
| 455 | /** | |
| 456 | * Get a string specifying the URL that represents this activity. Container support for this field | |
| 457 | * is OPTIONAL. | |
| 458 | * | |
| 459 | * @return a string specifying the URL that represents this activity. | |
| 460 | */ | |
| 461 | String getUrl(); | |
| 462 | ||
| 463 | /** | |
| 464 | * Set a string specifying the URL that represents this activity. Container support for this field | |
| 465 | * is OPTIONAL. | |
| 466 | * | |
| 467 | * @param url a string specifying the URL that represents this activity. | |
| 468 | */ | |
| 469 | void setUrl(String url); | |
| 470 | ||
| 471 | /** | |
| 472 | * Get a string ID of the user who this activity is for. Container support for this field is | |
| 473 | * OPTIONAL. | |
| 474 | * | |
| 475 | * @return a string ID of the user who this activity is for. | |
| 476 | */ | |
| 477 | String getUserId(); | |
| 478 | ||
| 479 | /** | |
| 480 | * Get a string ID of the user who this activity is for. Container support for this field is | |
| 481 | * OPTIONAL. | |
| 482 | * | |
| 483 | * @param userId a string ID of the user who this activity is for. | |
| 484 | */ | |
| 485 | void setUserId(String userId); | |
| 486 | } |