1 /* 2 * Copyright (c) 2002-2014, Mairie de Paris 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright notice 10 * and the following disclaimer. 11 * 12 * 2. Redistributions in binary form must reproduce the above copyright notice 13 * and the following disclaimer in the documentation and/or other materials 14 * provided with the distribution. 15 * 16 * 3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its 17 * contributors may be used to endorse or promote products derived from 18 * this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 * POSSIBILITY OF SUCH DAMAGE. 31 * 32 * License 1.0 33 */ 34 package fr.paris.lutece.portal.service.mail; 35 36 import fr.paris.lutece.portal.service.daemon.AppDaemonService; 37 import fr.paris.lutece.portal.service.daemon.Daemon; 38 import fr.paris.lutece.portal.service.datastore.DatastoreService; 39 import fr.paris.lutece.portal.service.portal.PortalService; 40 import fr.paris.lutece.portal.service.spring.SpringContextService; 41 import fr.paris.lutece.portal.service.util.AppPathService; 42 import fr.paris.lutece.portal.service.util.AppPropertiesService; 43 import fr.paris.lutece.util.mail.FileAttachment; 44 import fr.paris.lutece.util.mail.UrlAttachment; 45 46 import java.util.List; 47 48 49 /** 50 * Application Mail Service 51 */ 52 public final class MailService 53 { 54 private static final String KEY_NO_REPLY_EMAIL = "portal.site.site_property.noreply_email"; 55 private static final String PROPERTY_MAIL_NOREPLY_EMAIL = "mail.noreply.email"; 56 private static final String BEAN_MAIL_QUEUE = "mailQueue"; 57 58 /** Creates a new instance of AppMailService */ 59 private MailService( ) 60 { 61 } 62 63 /** 64 * Send a message asynchronously. The message is queued until a daemon 65 * thread send all awaiting messages 66 * @param strRecipient The recipient email. 67 * @param strSenderName The sender name. 68 * @param strSenderEmail The sender email address. 69 * @param strSubject The message subject. 70 * @param strMessage The message. 71 * @deprecated Use 72 * {@link #sendMailText(String strRecipient, String strSenderName, String strSenderEmail, String strSubject, String strMessage)} 73 * instead 74 */ 75 @Deprecated 76 public static void sendMail( String strRecipient, String strSenderName, String strSenderEmail, String strSubject, 77 String strMessage ) 78 { 79 sendMailText( strRecipient, strSenderName, strSenderEmail, strSubject, strMessage ); 80 } 81 82 /** 83 * Send a HTML message asynchronously. The message is queued until a daemon 84 * thread send all awaiting messages 85 * 86 * @param strRecipientsTo The list of the main recipients email.Every 87 * recipient 88 * must be separated by the mail separator define in 89 * config.properties 90 * @param strSenderName The sender name. 91 * @param strSenderEmail The sender email address. 92 * @param strSubject The message subject. 93 * @param strMessage The message. 94 */ 95 public static void sendMailHtml( String strRecipientsTo, String strSenderName, String strSenderEmail, 96 String strSubject, String strMessage ) 97 { 98 sendMailHtml( strRecipientsTo, null, null, strSenderName, strSenderEmail, strSubject, strMessage ); 99 } 100 101 /** 102 * Send a HTML message asynchronously. The message is queued until a daemon 103 * thread send all awaiting messages 104 * 105 * @param strRecipientsTo The list of the main recipients email.Every 106 * recipient 107 * must be separated by the mail separator defined in 108 * config.properties 109 * @param strRecipientsCc The recipients list of the carbon copies . 110 * @param strRecipientsBcc The recipients list of the blind carbon copies . 111 * @param strSenderName The sender name. 112 * @param strSenderEmail The sender email address. 113 * @param strSubject The message subject. 114 * @param strMessage The message. 115 */ 116 public static void sendMailHtml( String strRecipientsTo, String strRecipientsCc, String strRecipientsBcc, 117 String strSenderName, String strSenderEmail, String strSubject, String strMessage ) 118 { 119 sendMailHtml( strRecipientsTo, strRecipientsCc, strRecipientsBcc, strSenderName, strSenderEmail, strSubject, 120 strMessage, false ); 121 } 122 123 /** 124 * Send a HTML message asynchronously. The message is queued until a daemon 125 * thread send all awaiting messages 126 * 127 * @param strRecipientsTo The list of the main recipients email.Every 128 * recipient 129 * must be separated by the mail separator defined in 130 * config.properties 131 * @param strRecipientsCc The recipients list of the carbon copies . 132 * @param strRecipientsBcc The recipients list of the blind carbon copies . 133 * @param strSenderName The sender name. 134 * @param strSenderEmail The sender email address. 135 * @param strSubject The message subject. 136 * @param strMessage The message. 137 * @param bUniqueRecipientTo true if the mail must be send unitarily for 138 * each recipient 139 */ 140 public static void sendMailHtml( String strRecipientsTo, String strRecipientsCc, String strRecipientsBcc, 141 String strSenderName, String strSenderEmail, String strSubject, String strMessage, boolean bUniqueRecipientTo ) 142 { 143 MailItem item = new MailItem( ); 144 item.setRecipientsTo( strRecipientsTo ); 145 item.setRecipientsCc( strRecipientsCc ); 146 item.setRecipientsBcc( strRecipientsBcc ); 147 item.setSenderName( strSenderName ); 148 item.setSenderEmail( strSenderEmail ); 149 item.setSubject( strSubject ); 150 item.setMessage( strMessage ); 151 item.setFormat( MailItem.FORMAT_HTML ); 152 item.setUniqueRecipientTo( bUniqueRecipientTo ); 153 154 IMailQueue queue = (IMailQueue) SpringContextService.getBean( BEAN_MAIL_QUEUE ); 155 queue.send( item ); 156 } 157 158 /** 159 * Send a HTML message asynchronously with the attachments associated to 160 * the message . The message is queued until a daemon 161 * thread send all awaiting messages 162 * 163 * @param strRecipientsTo The list of the main recipients email.Every 164 * recipient 165 * must be separated by the mail separator defined in 166 * config.properties 167 * @param strSenderName The sender name. 168 * @param strSenderEmail The sender email address. 169 * @param strSubject The message subject. 170 * @param strMessage The message. 171 * @param urlsAttachement The List of UrlAttachement Object, containing the 172 * URL of attachments associated with their content-location. 173 */ 174 public static void sendMailMultipartHtml( String strRecipientsTo, String strSenderName, String strSenderEmail, 175 String strSubject, String strMessage, List<UrlAttachment> urlsAttachement ) 176 { 177 sendMailMultipartHtml( strRecipientsTo, null, null, strSenderName, strSenderEmail, strSubject, strMessage, 178 urlsAttachement, null ); 179 } 180 181 /** 182 * Send a HTML message asynchronously with the attachments associated to 183 * the message and attached files . The message is queued until a daemon 184 * thread send all awaiting messages 185 * 186 * @param strRecipientsTo The list of the main recipients email.Every 187 * recipient 188 * must be separated by the mail separator defined in 189 * config.properties 190 * @param strRecipientsCc The recipients list of the carbon copies . 191 * @param strRecipientsBcc The recipients list of the blind carbon copies . 192 * @param strSenderName The sender name. 193 * @param strSenderEmail The sender email address. 194 * @param strSubject The message subject. 195 * @param strMessage The message. 196 * @param urlsAttachement The List of UrlAttachement Object, containing the 197 * URL of attachments associated with their content-location 198 * @param filesAttachement The list of attached files. 199 */ 200 public static void sendMailMultipartHtml( String strRecipientsTo, String strRecipientsCc, String strRecipientsBcc, 201 String strSenderName, String strSenderEmail, String strSubject, String strMessage, 202 List<UrlAttachment> urlsAttachement, List<FileAttachment> filesAttachement ) 203 { 204 sendMailMultipartHtml( strRecipientsTo, strRecipientsCc, strRecipientsBcc, strSenderName, strSenderEmail, 205 strSubject, strMessage, urlsAttachement, filesAttachement, false ); 206 } 207 208 /** 209 * Send a HTML message asynchronously with the attachments associated to 210 * the message and attached files . The message is queued until a daemon 211 * thread send all awaiting messages 212 * 213 * @param strRecipientsTo The list of the main recipients email.Every 214 * recipient 215 * must be separated by the mail separator defined in 216 * config.properties 217 * @param strRecipientsCc The recipients list of the carbon copies . 218 * @param strRecipientsBcc The recipients list of the blind carbon copies . 219 * @param strSenderName The sender name. 220 * @param strSenderEmail The sender email address. 221 * @param strSubject The message subject. 222 * @param strMessage The message. 223 * @param urlsAttachement The List of UrlAttachement Object, containing the 224 * URL of attachments associated with their content-location 225 * @param filesAttachement The list of attached files. 226 * @param bUniqueRecipientTo true if the mail must be send unitarily for 227 * each recipient 228 */ 229 public static void sendMailMultipartHtml( String strRecipientsTo, String strRecipientsCc, String strRecipientsBcc, 230 String strSenderName, String strSenderEmail, String strSubject, String strMessage, 231 List<UrlAttachment> urlsAttachement, List<FileAttachment> filesAttachement, boolean bUniqueRecipientTo ) 232 { 233 MailItem item = new MailItem( ); 234 item.setRecipientsTo( strRecipientsTo ); 235 item.setRecipientsCc( strRecipientsCc ); 236 item.setRecipientsBcc( strRecipientsBcc ); 237 item.setSenderName( strSenderName ); 238 item.setSenderEmail( strSenderEmail ); 239 item.setSubject( strSubject ); 240 item.setMessage( strMessage ); 241 item.setFormat( MailItem.FORMAT_MULTIPART_HTML ); 242 item.setUrlsAttachement( urlsAttachement ); 243 item.setFilesAttachement( filesAttachement ); 244 item.setUniqueRecipientTo( bUniqueRecipientTo ); 245 246 IMailQueue queue = (IMailQueue) SpringContextService.getBean( BEAN_MAIL_QUEUE ); 247 queue.send( item ); 248 } 249 250 /** 251 * Send a calendar message asynchronously. The message is queued until a 252 * daemon thread send all awaiting messages 253 * @param strRecipientsTo The list of the main recipients email. Every 254 * recipient must be separated by the mail separator defined in 255 * config.properties 256 * @param strSenderName The sender name. 257 * @param strSenderEmail The sender email address. 258 * @param strSubject The message subject. 259 * @param strMessage The message. 260 * @param strCalendarMessage The calendar message 261 * @param bCreateEvent True to create the calendar event, false to remove it 262 */ 263 public static void sendMailCalendar( String strRecipientsTo, String strSenderName, String strSenderEmail, 264 String strSubject, String strMessage, String strCalendarMessage, boolean bCreateEvent ) 265 { 266 sendMailCalendar( strRecipientsTo, null, null, strSenderName, strSenderEmail, strSubject, strMessage, 267 strCalendarMessage, bCreateEvent ); 268 } 269 270 /** 271 * Send a calendar message asynchronously. The message is queued until a 272 * daemon thread send all awaiting messages 273 * @param strRecipientsTo The list of the main recipients email. Every 274 * recipient must be separated by the mail separator defined in 275 * config.properties 276 * @param strRecipientsCc The recipients list of the carbon copies . 277 * @param strRecipientsBcc The recipients list of the blind carbon copies . 278 * @param strSenderName The sender name. 279 * @param strSenderEmail The sender email address. 280 * @param strSubject The message subject. 281 * @param strMessage The message. 282 * @param strCalendarMessage The calendar message 283 * @param bCreateEvent True to create the calendar event, false to remove it 284 */ 285 public static void sendMailCalendar( String strRecipientsTo, String strRecipientsCc, String strRecipientsBcc, 286 String strSenderName, String strSenderEmail, String strSubject, String strMessage, String strCalendarMessage, 287 boolean bCreateEvent ) 288 { 289 sendMailCalendar( strRecipientsTo, strRecipientsCc, strRecipientsBcc, strSenderName, strSenderEmail, 290 strSubject, strMessage, strCalendarMessage, bCreateEvent, false ); 291 } 292 293 /** 294 * Send a calendar message asynchronously. The message is queued until a 295 * daemon thread send all awaiting messages 296 * @param strRecipientsTo The list of the main recipients email. Every 297 * recipient must be separated by the mail separator defined in 298 * config.properties 299 * @param strRecipientsCc The recipients list of the carbon copies . 300 * @param strRecipientsBcc The recipients list of the blind carbon copies . 301 * @param strSenderName The sender name. 302 * @param strSenderEmail The sender email address. 303 * @param strSubject The message subject. 304 * @param strMessage The message. 305 * @param strCalendarMessage The calendar message 306 * @param bCreateEvent True to create the calendar event, false to remove it 307 * @param bUniqueRecipientTo true if the mail must be send unitarily for 308 * each recipient 309 */ 310 public static void sendMailCalendar( String strRecipientsTo, String strRecipientsCc, String strRecipientsBcc, 311 String strSenderName, String strSenderEmail, String strSubject, String strMessage, String strCalendarMessage, 312 boolean bCreateEvent, boolean bUniqueRecipientTo ) 313 { 314 MailItem item = new MailItem( ); 315 item.setRecipientsTo( strRecipientsTo ); 316 item.setRecipientsCc( strRecipientsCc ); 317 item.setRecipientsBcc( strRecipientsBcc ); 318 item.setSenderName( strSenderName ); 319 item.setSenderEmail( strSenderEmail ); 320 item.setSubject( strSubject ); 321 item.setMessage( strMessage ); 322 item.setCalendarMessage( strCalendarMessage ); 323 item.setCreateEvent( bCreateEvent ); 324 item.setFormat( MailItem.FORMAT_CALENDAR ); 325 item.setUniqueRecipientTo( bUniqueRecipientTo ); 326 327 IMailQueue queue = (IMailQueue) SpringContextService.getBean( BEAN_MAIL_QUEUE ); 328 queue.send( item ); 329 } 330 331 /** 332 * Send a text message asynchronously. The message is queued until a daemon 333 * thread send all awaiting messages 334 * @param strRecipientsTo The list of the main recipients email. Every 335 * recipient must be separated by the mail separator defined in 336 * config.properties 337 * @param strSenderName The sender name. 338 * @param strSenderEmail The sender email address. 339 * @param strSubject The message subject. 340 * @param strMessage The message. 341 */ 342 public static void sendMailText( String strRecipientsTo, String strSenderName, String strSenderEmail, 343 String strSubject, String strMessage ) 344 { 345 sendMailText( strRecipientsTo, null, null, strSenderName, strSenderEmail, strSubject, strMessage ); 346 } 347 348 /** 349 * Send a text message asynchronously. The message is queued until a daemon 350 * thread send all awaiting messages 351 * @param strRecipientsTo The list of the main recipients email. Every 352 * recipient must be separated by the mail separator defined in 353 * config.properties 354 * @param strRecipientsCc The recipients list of the carbon copies . 355 * @param strRecipientsBcc The recipients list of the blind carbon copies . 356 * @param strSenderName The sender name. 357 * @param strSenderEmail The sender email address. 358 * @param strSubject The message subject. 359 * @param strMessage The message. 360 */ 361 public static void sendMailText( String strRecipientsTo, String strRecipientsCc, String strRecipientsBcc, 362 String strSenderName, String strSenderEmail, String strSubject, String strMessage ) 363 { 364 sendMailText( strRecipientsTo, strRecipientsCc, strRecipientsBcc, strSenderName, strSenderEmail, strSubject, 365 strMessage, false ); 366 } 367 368 /** 369 * Send a text message asynchronously. The message is queued until a daemon 370 * thread send all awaiting messages 371 * @param strRecipientsTo The list of the main recipients email. Every 372 * recipient must be separated by the mail separator defined in 373 * config.properties 374 * @param strRecipientsCc The recipients list of the carbon copies . 375 * @param strRecipientsBcc The recipients list of the blind carbon copies . 376 * @param strSenderName The sender name. 377 * @param strSenderEmail The sender email address. 378 * @param strSubject The message subject. 379 * @param strMessage The message. 380 * @param bUniqueRecipientTo true if the mail must be send unitarily for 381 * each recipient 382 */ 383 public static void sendMailText( String strRecipientsTo, String strRecipientsCc, String strRecipientsBcc, 384 String strSenderName, String strSenderEmail, String strSubject, String strMessage, boolean bUniqueRecipientTo ) 385 { 386 MailItem item = new MailItem( ); 387 item.setRecipientsTo( strRecipientsTo ); 388 item.setRecipientsCc( strRecipientsCc ); 389 item.setRecipientsBcc( strRecipientsBcc ); 390 item.setSenderName( strSenderName ); 391 item.setSenderEmail( strSenderEmail ); 392 item.setSubject( strSubject ); 393 item.setMessage( strMessage ); 394 item.setFormat( MailItem.FORMAT_TEXT ); 395 item.setUniqueRecipientTo( bUniqueRecipientTo ); 396 397 IMailQueue queue = (IMailQueue) SpringContextService.getBean( BEAN_MAIL_QUEUE ); 398 queue.send( item ); 399 } 400 401 /** 402 * Send a text message asynchronously with attached files. The message is 403 * queued until a daemon 404 * thread send all awaiting messages 405 * 406 * @param strRecipientsTo The list of the main recipients email.Every 407 * recipient 408 * must be separated by the mail separator defined in 409 * config.properties 410 * @param strSenderName The sender name. 411 * @param strSenderEmail The sender email address. 412 * @param strSubject The message subject. 413 * @param strMessage The message. 414 * @param filesAttachement The list of attached files. 415 */ 416 public static void sendMailMultipartText( String strRecipientsTo, String strSenderName, String strSenderEmail, 417 String strSubject, String strMessage, List<FileAttachment> filesAttachement ) 418 { 419 sendMailMultipartText( strRecipientsTo, null, null, strSenderName, strSenderEmail, strSubject, strMessage, 420 filesAttachement ); 421 } 422 423 /** 424 * Send a text message asynchronously with attached files. The message is 425 * queued until a daemon 426 * thread send all awaiting messages 427 * @param strRecipientsTo The list of the main recipients email.Every 428 * recipient 429 * must be separated by the mail separator defined in 430 * config.properties 431 * @param strRecipientsCc The recipients list of the carbon copies . 432 * @param strRecipientsBcc The recipients list of the blind carbon copies . 433 * @param strSenderName The sender name. 434 * @param strSenderEmail The sender email address. 435 * @param strSubject The message subject. 436 * @param strMessage The message. 437 * @param filesAttachement The list of attached files. 438 */ 439 public static void sendMailMultipartText( String strRecipientsTo, String strRecipientsCc, String strRecipientsBcc, 440 String strSenderName, String strSenderEmail, String strSubject, String strMessage, 441 List<FileAttachment> filesAttachement ) 442 { 443 sendMailMultipartText( strRecipientsTo, strRecipientsCc, strRecipientsBcc, strSenderName, strSenderEmail, 444 strSubject, strMessage, filesAttachement, false ); 445 } 446 447 /** 448 * Send a text message asynchronously with attached files. The message is 449 * queued until a daemon 450 * thread send all awaiting messages 451 * @param strRecipientsTo The list of the main recipients email.Every 452 * recipient 453 * must be separated by the mail separator defined in 454 * config.properties 455 * @param strRecipientsCc The recipients list of the carbon copies . 456 * @param strRecipientsBcc The recipients list of the blind carbon copies . 457 * @param strSenderName The sender name. 458 * @param strSenderEmail The sender email address. 459 * @param strSubject The message subject. 460 * @param strMessage The message. 461 * @param filesAttachement The list of attached files. 462 * @param bUniqueRecipientTo true if the mail must be send unitarily for 463 * each recipient 464 */ 465 public static void sendMailMultipartText( String strRecipientsTo, String strRecipientsCc, String strRecipientsBcc, 466 String strSenderName, String strSenderEmail, String strSubject, String strMessage, 467 List<FileAttachment> filesAttachement, boolean bUniqueRecipientTo ) 468 { 469 MailItem item = new MailItem( ); 470 item.setRecipientsTo( strRecipientsTo ); 471 item.setRecipientsCc( strRecipientsCc ); 472 item.setRecipientsBcc( strRecipientsBcc ); 473 item.setSenderName( strSenderName ); 474 item.setSenderEmail( strSenderEmail ); 475 item.setSubject( strSubject ); 476 item.setMessage( strMessage ); 477 item.setFormat( MailItem.FORMAT_MULTIPART_TEXT ); 478 item.setFilesAttachement( filesAttachement ); 479 item.setUniqueRecipientTo( bUniqueRecipientTo ); 480 481 IMailQueue queue = (IMailQueue) SpringContextService.getBean( BEAN_MAIL_QUEUE ); 482 queue.send( item ); 483 } 484 485 /** 486 * Shutdown the service 487 */ 488 public static void shutdown( ) 489 { 490 // if there is mails that have not been sent call the daemon to flush the list 491 Daemon daemon = AppDaemonService.getDaemon( "mailSender" ); 492 493 if ( daemon != null ) 494 { 495 daemon.run( ); 496 } 497 } 498 499 /** 500 * Returns a no reply email address defined in config.properties 501 * @return A no reply email 502 */ 503 public static String getNoReplyEmail( ) 504 { 505 String strDefault = AppPropertiesService.getProperty( PROPERTY_MAIL_NOREPLY_EMAIL ); 506 507 return DatastoreService.getDataValue( KEY_NO_REPLY_EMAIL, strDefault ); 508 } 509 510 /** 511 * Returns the mail queue 512 * @return the mail queue 513 */ 514 public static IMailQueue getQueue( ) 515 { 516 IMailQueue queue = (IMailQueue) SpringContextService.getBean( BEAN_MAIL_QUEUE ); 517 518 return queue; 519 } 520 521 /** 522 * Extract a collection of elements to be attached to a mail from an HTML 523 * string. 524 * 525 * The collection contains the Url used for created DataHandler for each url 526 * associated with 527 * an HTML tag img, script or link. Those urls must start with the url 528 * strBaseUrl. 529 * 530 * @param strHtml The HTML code. 531 * @param strBaseUrl The base url, can be null in order to extract all urls. 532 * @param useAbsoluteUrl Determine if we use absolute or relative url for 533 * attachement content-location 534 * @return a collection of UrlAttachment Object for created DataHandler 535 * associated with attachment urls. 536 */ 537 public static List<UrlAttachment> getUrlAttachmentList( String strHtml, String strBaseUrl, boolean useAbsoluteUrl ) 538 { 539 return MailUtil.getUrlAttachmentList( strHtml, strBaseUrl, useAbsoluteUrl ); 540 } 541 542 /** 543 * Return a String that contains a list of recipients separated with mail 544 * separator 545 * @param listRecipients a list of string recipients 546 * @return a String that contains a list of recipients separated with mail 547 * separator 548 */ 549 public static String getStrRecipients( List<String> listRecipients ) 550 { 551 return MailUtil.getStrRecipients( listRecipients ); 552 } 553 554 /** 555 * Get a string that contains an html link to the site back office or front 556 * office. 557 * @param strBaseUrl The base url of the site 558 * @param linkToFrontOffice True if the link should be directed to the front 559 * office, false if it should be directed to the back office. 560 * @return A string containing an html link. 561 */ 562 public static String getSiteLink( String strBaseUrl, boolean linkToFrontOffice ) 563 { 564 StringBuilder sb = new StringBuilder( ); 565 String strSiteName = PortalService.getSiteName( ); 566 567 if ( strSiteName != null ) 568 { 569 sb.append( "<a title=\"" ); 570 sb.append( strSiteName ); 571 sb.append( "\" href=\"" ); 572 sb.append( strBaseUrl ); 573 574 String strUrl; 575 576 if ( linkToFrontOffice ) 577 { 578 strUrl = AppPathService.getPortalUrl( ); 579 } 580 else 581 { 582 strUrl = AppPathService.getAdminMenuUrl( ); 583 } 584 585 if ( strUrl != null ) 586 { 587 sb.append( strUrl ); 588 } 589 590 sb.append( "\" >" ); 591 sb.append( strSiteName ); 592 sb.append( "</a>" ); 593 } 594 595 return sb.toString( ); 596 } 597 }