Ignore:
Timestamp:
10/28/09 20:58:21 (14 years ago)
Author:
wmerlotto
Message:

Ticket #693 - Incrementado a sincronizacao de contatos, integracao com maven e codigo de autenticacao no LDAP.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • contrib/psync/src/main/java/br/com/prognus/psync/engine/source/PIMCalendarSyncSource.java

    r1103 r1545  
    7777                        this.manager = new PIMCalendarManager(JNDI_DATA_SOURCE_NAME, context.getPrincipal(), context.getSourceQuery()); 
    7878                } catch (Exception e) { 
    79                         // TODO Auto-generated catch block 
    8079                        e.printStackTrace(); 
    8180                } 
     
    453452        private String hackFix(String text) { 
    454453 
    455                 String result, head, title, clas, description, tail, new_title; 
    456                 int p_categories, p_classes, p_location, p_dstart, values1, values2, op1, op2, op3, op4, op5, op6, op7, op8, qt1, qt2; 
    457  
    458                 qt1 = 0; 
    459                 qt2 = 0; 
    460  
    461                 // Pega as posicoes das tags 
    462                 p_categories = text.indexOf("CATEGORIES"); 
    463                 p_classes = text.indexOf("CLASS"); 
    464  
    465                 p_location = text.indexOf("LOCATION"); 
    466                 p_dstart = text.indexOf("DTSTART"); 
    467  
    468                 // Pega as posicoes das varias formas da tag SUMMARY 
    469                 op1 = text.indexOf("SUMMARY:"); 
    470                 op2 = text.indexOf("SUMMARY;CHARSET=UTF-8:"); 
    471                 op3 = text.indexOf("SUMMARY;ENCODING=QUOTED-PRINTABLE:"); 
    472                 op4 = text.indexOf("SUMMARY;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8:"); 
    473  
    474                 // Pega as posicoes das varias formas da tag DESCRIPTION 
    475                 op5 = text.indexOf("DESCRIPTION:"); 
    476                 op6 = text.indexOf("DESCRIPTION;CHARSET=UTF-8:"); 
    477                 op7 = text.indexOf("DESCRIPTION;ENCODING=QUOTED-PRINTABLE:"); 
    478                 op8 = text.indexOf("DESCRIPTION;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8:"); 
    479  
    480                 qt1 += (op1 == -1) ? 0 : op1 + 8; 
    481                 qt1 += (op2 == -1) ? 0 : op2 + 22; 
    482                 qt1 += (op3 == -1) ? 0 : op3 + 34; 
    483                 qt1 += (op4 == -1) ? 0 : op4 + 48; 
    484  
    485                 qt2 += (op5 == -1) ? 0 : op5 + 12; 
    486                 qt2 += (op6 == -1) ? 0 : op6 + 26; 
    487                 qt2 += (op7 == -1) ? 0 : op7 + 38; 
    488                 qt2 += (op8 == -1) ? 0 : op8 + 52; 
    489  
    490                 values1 = (p_categories == -1) ? p_classes : p_categories; 
    491                 values2 = (p_location == -1) ? p_dstart : p_location; 
    492  
    493                 head = text.substring(0, qt1); 
    494                 title = text.substring(qt1, values1); 
    495                 clas = text.substring(values1, qt2); 
    496                 description = text.substring(qt2, values2); 
    497                 tail = text.substring(values2); 
    498  
    499                 new_title = title.replaceAll("\r\n ", " "); 
    500  
    501                 // Retira os enters no final do titulo 
    502                 int title_t, title_bl; 
    503  
    504                 while(true){ 
    505                         title_t = new_title.length(); 
    506                         title_bl = new_title.lastIndexOf("=0D=0A=\r\n"); 
    507  
    508                         if(title_bl != -1 && title_t == title_bl + 11){ 
    509                                 new_title = new_title.substring(0, title_bl) + "\r\n"; 
    510                         } else { 
    511                                 break; 
    512                         } 
    513                 } 
    514  
    515                 // Retira os enters no final da descricao 
    516                 int description_t, description_bl; 
    517  
    518                 while(true){ 
    519                         description_t = description.length(); 
    520                         description_bl = description.lastIndexOf("=0D=0A=\r\n"); 
    521  
    522                         if(description_bl != -1 && description_t == description_bl + 11){ 
    523                                 description = description.substring(0, description_bl) + "\r\n"; 
    524                         } else { 
    525                                 break; 
    526                         } 
    527                 } 
    528  
    529                 result = head + new_title + clas + description + tail; 
    530  
    531                 return result; 
     454                try { 
     455                 
     456                        String result, head, title, clas, description, tail, new_title; 
     457                        int p_categories, p_classes, p_location, p_dstart, values1, values2, op1, op2, op3, op4, op5, op6, op7, op8, qt1, qt2; 
     458         
     459                        qt1 = 0; 
     460                        qt2 = 0; 
     461         
     462                        // Pega as posicoes das tags 
     463                        p_categories = text.indexOf("CATEGORIES"); 
     464                        p_classes = text.indexOf("CLASS"); 
     465         
     466                        p_location = text.indexOf("LOCATION"); 
     467                        p_dstart = text.indexOf("DTSTART"); 
     468         
     469                        // Pega as posicoes das varias formas da tag SUMMARY 
     470                        op1 = text.indexOf("SUMMARY:"); 
     471                        op2 = text.indexOf("SUMMARY;CHARSET=UTF-8:"); 
     472                        op3 = text.indexOf("SUMMARY;ENCODING=QUOTED-PRINTABLE:"); 
     473                        op4 = text.indexOf("SUMMARY;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8:"); 
     474         
     475                        // Pega as posicoes das varias formas da tag DESCRIPTION 
     476                        op5 = text.indexOf("DESCRIPTION:"); 
     477                        op6 = text.indexOf("DESCRIPTION;CHARSET=UTF-8:"); 
     478                        op7 = text.indexOf("DESCRIPTION;ENCODING=QUOTED-PRINTABLE:"); 
     479                        op8 = text.indexOf("DESCRIPTION;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8:"); 
     480         
     481                        qt1 += (op1 == -1) ? 0 : op1 + 8; 
     482                        qt1 += (op2 == -1) ? 0 : op2 + 22; 
     483                        qt1 += (op3 == -1) ? 0 : op3 + 34; 
     484                        qt1 += (op4 == -1) ? 0 : op4 + 48; 
     485         
     486                        qt2 += (op5 == -1) ? 0 : op5 + 12; 
     487                        qt2 += (op6 == -1) ? 0 : op6 + 26; 
     488                        qt2 += (op7 == -1) ? 0 : op7 + 38; 
     489                        qt2 += (op8 == -1) ? 0 : op8 + 52; 
     490         
     491                        values1 = (p_categories == -1) ? p_classes : p_categories; 
     492                        values2 = (p_location == -1) ? p_dstart : p_location; 
     493         
     494                        head = text.substring(0, qt1); 
     495                        title = text.substring(qt1, values1); 
     496                        clas = text.substring(values1, qt2); 
     497                        description = text.substring(qt2, values2); 
     498                        tail = text.substring(values2); 
     499         
     500                        new_title = title.replaceAll("\r\n ", " "); 
     501         
     502                        // Retira os enters no final do titulo 
     503                        int title_t, title_bl; 
     504         
     505                        while(true){ 
     506                                title_t = new_title.length(); 
     507                                title_bl = new_title.lastIndexOf("=0D=0A=\r\n"); 
     508         
     509                                if(title_bl != -1 && title_t == title_bl + 11){ 
     510                                        new_title = new_title.substring(0, title_bl) + "\r\n"; 
     511                                } else { 
     512                                        break; 
     513                                } 
     514                        } 
     515         
     516                        // Retira os enters no final da descricao 
     517                        int description_t, description_bl; 
     518         
     519                        while(true){ 
     520                                description_t = description.length(); 
     521                                description_bl = description.lastIndexOf("=0D=0A=\r\n"); 
     522         
     523                                if(description_bl != -1 && description_t == description_bl + 11){ 
     524                                        description = description.substring(0, description_bl) + "\r\n"; 
     525                                } else { 
     526                                        break; 
     527                                } 
     528                        } 
     529         
     530                        result = head + new_title + clas + description + tail; 
     531 
     532                        return result; 
     533                }catch (Exception e) { 
     534                        if (log.isTraceEnabled()) { 
     535                                log.trace(e); 
     536                        } 
     537                        return text; 
     538                } 
    532539        } 
    533540 
Note: See TracChangeset for help on using the changeset viewer.