1 package org.roller.pojos; 2 3 import org.apache.commons.lang.StringUtils; 4 import org.roller.RollerException; 5 import org.roller.model.Roller; 6 import org.roller.model.RollerFactory; 7 import org.roller.util.PojoUtil; 8 9 import java.util.Locale ; 10 import java.util.TimeZone ; 11 20 public class WebsiteData extends org.roller.pojos.PersistentObject 21 implements java.io.Serializable 22 { 23 static final long serialVersionUID = 206437645033737127L; 24 protected java.lang.String id; 25 protected java.lang.String name; 26 protected java.lang.String description; 27 protected java.lang.String defaultPageId; 28 protected java.lang.String weblogDayPageId; 29 protected java.lang.Boolean enableBloggerApi; 30 protected WeblogCategoryData bloggerCategory; 31 protected WeblogCategoryData defaultCategory; 32 protected java.lang.String editorPage; 33 protected java.lang.String ignoreWords; 34 protected java.lang.Boolean allowComments; 35 protected java.lang.Boolean emailComments; 36 protected java.lang.String emailFromAddress; 37 protected java.lang.String editorTheme; 38 protected java.lang.String locale; 39 protected java.lang.String timezone; 40 protected java.lang.String mDefaultPlugins; 41 protected java.lang.Boolean isEnabled; 42 43 protected UserData mUser = null; 44 45 public WebsiteData() 46 { 47 } 48 49 public WebsiteData(final java.lang.String id, 50 final java.lang.String name, 51 final java.lang.String description, 52 final UserData user, 53 final java.lang.String defaultPageId, 54 final java.lang.String weblogDayPageId, 55 final java.lang.Boolean enableBloggerApi, 56 final WeblogCategoryData bloggerCategory, 57 final WeblogCategoryData defaultCategory, 58 final java.lang.String editorPage, 59 final java.lang.String ignoreWords, 60 final java.lang.Boolean allowComments, 61 final java.lang.Boolean emailComments, 62 final java.lang.String emailFromAddress, 63 final java.lang.Boolean isEnabled) 64 { 65 this.id = id; 66 this.name = name; 67 this.description = description; 68 this.mUser = user; 69 this.defaultPageId = defaultPageId; 70 this.weblogDayPageId = weblogDayPageId; 71 this.enableBloggerApi = enableBloggerApi; 72 this.bloggerCategory = bloggerCategory; 73 this.defaultCategory = defaultCategory; 74 this.editorPage = editorPage; 75 this.ignoreWords = ignoreWords; 76 this.allowComments = allowComments; 77 this.emailComments = emailComments; 78 this.emailFromAddress = emailFromAddress; 79 this.isEnabled = isEnabled; 80 } 81 82 public WebsiteData(WebsiteData otherData) 83 { 84 this.setData(otherData); 85 } 86 87 93 public java.lang.String getId() 94 { 95 return this.id; 96 } 97 98 99 public void setId(java.lang.String id) 100 { 101 this.id = id; 102 } 103 104 109 public java.lang.String getName() 110 { 111 return this.name; 112 } 113 114 115 public void setName(java.lang.String name) 116 { 117 this.name = name; 118 } 119 120 125 public java.lang.String getDescription() 126 { 127 return this.description; 128 } 129 130 131 public void setDescription(java.lang.String description) 132 { 133 this.description = description; 134 } 135 136 141 public org.roller.pojos.UserData getUser() 142 { 143 return mUser; 144 } 145 146 147 public void setUser( org.roller.pojos.UserData ud ) 148 { 149 mUser = ud; 150 } 151 152 156 public java.lang.String getDefaultPageId() 157 { 158 return this.defaultPageId; 159 } 160 161 164 public void setDefaultPageId(java.lang.String defaultPageId) 165 { 166 this.defaultPageId = defaultPageId; 167 } 168 169 174 public java.lang.String getWeblogDayPageId() 175 { 176 return this.weblogDayPageId; 177 } 178 179 183 public void setWeblogDayPageId(java.lang.String weblogDayPageId) 184 { 185 this.weblogDayPageId = weblogDayPageId; 186 } 187 188 192 public java.lang.Boolean getEnableBloggerApi() 193 { 194 return this.enableBloggerApi; 195 } 196 197 198 public void setEnableBloggerApi(java.lang.Boolean enableBloggerApi) 199 { 200 this.enableBloggerApi = enableBloggerApi; 201 } 202 203 208 public WeblogCategoryData getBloggerCategory() 209 { 210 return bloggerCategory; 211 } 212 213 214 public void setBloggerCategory(WeblogCategoryData bloggerCategory) 215 { 216 this.bloggerCategory = bloggerCategory; 217 } 218 219 228 public WeblogCategoryData getDefaultCategory() 229 { 230 return defaultCategory; 231 } 232 233 234 public void setDefaultCategory(WeblogCategoryData defaultCategory) 235 { 236 this.defaultCategory = defaultCategory; 237 } 238 239 243 public java.lang.String getEditorPage() 244 { 245 return this.editorPage; 246 } 247 248 249 public void setEditorPage(java.lang.String editorPage) 250 { 251 this.editorPage = editorPage; 252 } 253 254 258 public java.lang.String getIgnoreWords() 259 { 260 return this.ignoreWords; 261 } 262 263 264 public void setIgnoreWords(java.lang.String ignoreWords) 265 { 266 this.ignoreWords = ignoreWords; 267 } 268 269 273 public java.lang.Boolean getAllowComments() 274 { 275 return this.allowComments; 276 } 277 278 279 public void setAllowComments(java.lang.Boolean allowComments) 280 { 281 this.allowComments = allowComments; 282 } 283 284 288 public java.lang.Boolean getEmailComments() 289 { 290 return this.emailComments; 291 } 292 293 294 public void setEmailComments(java.lang.Boolean emailComments) 295 { 296 this.emailComments = emailComments; 297 } 298 299 303 public java.lang.String getEmailFromAddress() 304 { 305 return this.emailFromAddress; 306 } 307 308 309 public void setEmailFromAddress(java.lang.String emailFromAddress) 310 { 311 this.emailFromAddress = emailFromAddress; 312 } 313 314 319 public java.lang.String getEditorTheme() 320 { 321 return this.editorTheme; 322 } 323 324 325 public void setEditorTheme(java.lang.String editorTheme) 326 { 327 this.editorTheme = editorTheme; 328 } 329 330 335 public java.lang.String getLocale() 336 { 337 return this.locale; 338 } 339 340 341 public void setLocale(java.lang.String locale) 342 { 343 this.locale = locale; 344 } 345 346 351 public java.lang.String getTimezone() 352 { 353 return this.timezone; 354 } 355 356 357 public void setTimezone(java.lang.String timezone) 358 { 359 this.timezone = timezone; 360 } 361 362 367 public java.lang.String getDefaultPlugins() 368 { 369 return mDefaultPlugins; 370 } 371 372 373 public void setDefaultPlugins(java.lang.String string) 374 { 375 mDefaultPlugins = string; 376 } 377 378 382 public java.lang.Boolean getIsEnabled() 383 { 384 return this.isEnabled; 385 } 386 387 388 public void setIsEnabled(java.lang.Boolean isEnabled) 389 { 390 this.isEnabled = isEnabled; 391 } 392 393 public String toString() 394 { 395 StringBuffer str = new StringBuffer ("{"); 396 397 str.append("id=" + id + " " + "name=" + name + " " + "description=" + 398 description + " " + 399 "defaultPageId=" + defaultPageId + " " + 400 "weblogDayPageId=" + weblogDayPageId + " " + 401 "enableBloggerApi=" + enableBloggerApi + " " + 402 "bloggerCategory=" + bloggerCategory + " " + 403 "defaultCategory=" + defaultCategory + " " + 404 "editorPage=" + editorPage + " " + 405 "ignoreWords=" + ignoreWords + " " + 406 "allowComments=" + allowComments + " " + 407 "emailComments=" + emailComments + " " + 408 "emailFromAddress=" + emailFromAddress + " " + 409 "editorTheme=" + editorTheme + " " + 410 "locale=" + locale + " " + 411 "timezone=" + timezone + " " + 412 "defaultPlugins=" + mDefaultPlugins); 413 str.append('}'); 414 415 return (str.toString()); 416 } 417 418 public boolean equals(Object pOther) 419 { 420 if (pOther instanceof WebsiteData) 421 { 422 WebsiteData lTest = (WebsiteData) pOther; 423 boolean lEquals = true; 424 425 lEquals = PojoUtil.equals(lEquals, this.id, lTest.id); 426 427 lEquals = PojoUtil.equals(lEquals, this.name, lTest.name); 428 429 lEquals = PojoUtil.equals(lEquals, this.description, lTest.description); 430 431 lEquals = PojoUtil.equals(lEquals, this.mUser, lTest.mUser); 432 433 lEquals = PojoUtil.equals(lEquals, this.defaultPageId, lTest.defaultPageId); 434 435 lEquals = PojoUtil.equals(lEquals, this.weblogDayPageId, lTest.weblogDayPageId); 436 437 lEquals = PojoUtil.equals(lEquals, this.enableBloggerApi, lTest.enableBloggerApi); 438 439 lEquals = PojoUtil.equals(lEquals, this.bloggerCategory.getId(), lTest.bloggerCategory.getId()); 440 441 lEquals = PojoUtil.equals(lEquals, this.defaultCategory.getId(), lTest.defaultCategory.getId()); 442 443 lEquals = PojoUtil.equals(lEquals, this.editorPage, lTest.editorPage); 444 445 lEquals = PojoUtil.equals(lEquals, this.ignoreWords, lTest.ignoreWords); 446 447 lEquals = PojoUtil.equals(lEquals, this.allowComments, lTest.allowComments); 448 449 lEquals = PojoUtil.equals(lEquals, this.emailComments, lTest.emailComments); 450 451 lEquals = PojoUtil.equals(lEquals, this.emailFromAddress, lTest.emailFromAddress); 452 453 lEquals = PojoUtil.equals(lEquals, this.editorTheme, lTest.editorTheme); 454 455 lEquals = PojoUtil.equals(lEquals, this.locale, lTest.locale); 456 457 lEquals = PojoUtil.equals(lEquals, this.timezone, lTest.timezone); 458 459 lEquals = PojoUtil.equals(lEquals, this.mDefaultPlugins, lTest.mDefaultPlugins); 460 461 return lEquals; 462 } 463 else 464 { 465 return false; 466 } 467 } 468 469 public int hashCode() 470 { 471 int result = 17; 472 result = PojoUtil.addHashCode(result, this.id); 473 result = PojoUtil.addHashCode(result, this.name); 474 result = PojoUtil.addHashCode(result, this.description); 475 result = PojoUtil.addHashCode(result, this.mUser); 476 result = PojoUtil.addHashCode(result, this.defaultPageId); 477 result = PojoUtil.addHashCode(result, this.weblogDayPageId); 478 result = PojoUtil.addHashCode(result, this.enableBloggerApi); 479 result = PojoUtil.addHashCode(result, this.editorPage); 482 result = PojoUtil.addHashCode(result, this.ignoreWords); 483 result = PojoUtil.addHashCode(result, this.allowComments); 484 result = PojoUtil.addHashCode(result, this.emailComments); 485 result = PojoUtil.addHashCode(result, this.emailFromAddress); 486 result = PojoUtil.addHashCode(result, this.editorTheme); 487 result = PojoUtil.addHashCode(result, this.locale); 488 result = PojoUtil.addHashCode(result, this.timezone); 489 result = PojoUtil.addHashCode(result, this.mDefaultPlugins); 490 491 return result; 492 } 493 494 497 public void setData(org.roller.pojos.PersistentObject otherData) 498 { 499 WebsiteData other = (WebsiteData)otherData; 500 501 this.id = other.id; 502 this.name = other.name; 503 this.description = other.description; 504 this.mUser = other.mUser; 505 this.defaultPageId = other.defaultPageId; 506 this.weblogDayPageId = other.weblogDayPageId; 507 this.enableBloggerApi = other.enableBloggerApi; 508 this.bloggerCategory = other.bloggerCategory; 509 this.defaultCategory = other.defaultCategory; 510 this.editorPage = other.editorPage; 511 this.ignoreWords = other.ignoreWords; 512 this.allowComments = other.allowComments; 513 this.emailComments = other.emailComments; 514 this.emailFromAddress = other.emailFromAddress; 515 this.editorTheme = other.editorTheme; 516 this.locale = other.locale; 517 this.timezone = other.timezone; 518 this.mDefaultPlugins = other.mDefaultPlugins; 519 this.isEnabled = other.isEnabled; 520 } 521 522 527 public Locale getLocaleInstance() 528 { 529 if (locale != null) 530 { 531 String [] localeStr = StringUtils.split(locale,"_"); 532 if (localeStr.length == 1) 533 { 534 if (localeStr[0] == null) localeStr[0] = ""; 535 return new Locale (localeStr[0]); 536 } 537 else if (localeStr.length == 2) 538 { 539 if (localeStr[0] == null) localeStr[0] = ""; 540 if (localeStr[1] == null) localeStr[1] = ""; 541 return new Locale (localeStr[0], localeStr[1]); 542 } 543 else if (localeStr.length == 3) 544 { 545 if (localeStr[0] == null) localeStr[0] = ""; 546 if (localeStr[1] == null) localeStr[1] = ""; 547 if (localeStr[2] == null) localeStr[2] = ""; 548 return new Locale (localeStr[0], localeStr[1], localeStr[2]); 549 } 550 } 551 return Locale.getDefault(); 552 } 553 554 559 public TimeZone getTimeZoneInstance() 560 { 561 if (timezone == null) 562 { 563 if (TimeZone.getDefault() != null) 564 { 565 this.setTimezone( TimeZone.getDefault().getID() ); 566 } 567 else 568 { 569 this.setTimezone("America/New_York"); 570 } 571 } 572 return TimeZone.getTimeZone(timezone); 573 } 574 575 578 public void remove() throws RollerException 579 { 580 RollerFactory.getRoller().getUserManager().removeWebsiteContents(this); 581 super.remove(); 582 } 583 584 public boolean canSave() throws RollerException 585 { 586 Roller roller = RollerFactory.getRoller(); 587 if (roller.getUser().equals(UserData.SYSTEM_USER)) 588 { 589 return true; 590 } 591 if (roller.getUser().equals(getUser())) 592 { 593 return true; 594 } 595 return false; 596 } 597 598 } | Popular Tags |