1 18 19 package sync4j.exchange.items.note.manager; 20 21 import sync4j.exchange.items.note.dao.NoteDAO; 22 import sync4j.exchange.items.note.model.Note; 23 import sync4j.exchange.DataAccessException; 24 25 33 public class NoteManager { 34 35 37 39 NoteDAO nd = null ; 40 41 43 public NoteManager(String exchangeServerHost , 44 int exchangeServerPort ) 45 throws DataAccessException { 46 47 this.nd = new NoteDAO (exchangeServerHost , 48 exchangeServerPort ); 49 50 } 51 52 54 65 public Note[] getAllNotes(String username , 66 String credentials , 67 String exchangeFolder ) 68 throws DataAccessException { 69 70 return this.nd.getNotes(username , 71 credentials , 72 new String [0] , 73 exchangeFolder ); 74 } 75 76 88 public Note[] getNotes(String username , 89 String credentials , 90 String [] ids , 91 String exchangeFolder ) 92 throws DataAccessException { 93 94 return this.nd.getNotes(username , 95 credentials , 96 ids , 97 exchangeFolder ); 98 99 } 100 101 112 public Note getNoteById(String username , 113 String credentials , 114 String id , 115 String exchangeFolder) 116 throws DataAccessException { 117 118 Note[] notes = null; 119 120 notes = this.nd.getNotes(username , 121 credentials , 122 new String [] {id} , 123 exchangeFolder ); 124 125 if (notes == null || !(notes.length > 0)) { 126 return null; 127 } 128 129 return notes[0]; 130 131 } 132 133 145 public Note setNote(Note note , 146 String username , 147 String credentials , 148 String exchangeFolder ) 149 throws DataAccessException { 150 151 return this.nd.setNote(note , 152 username , 153 credentials , 154 exchangeFolder ); 155 156 } 157 158 168 public void removeNote(Note note , 169 String username , 170 String principal , 171 String exchangeFolder ) 172 throws DataAccessException { 173 174 this.nd.removeNote(note, username, principal, exchangeFolder); 175 176 } 177 178 190 public Note getNoteTwin(Note note, 191 String username, 192 String credentials, 193 String exchangeFolder) 194 throws DataAccessException { 195 196 Note[] notes = null; 197 198 String subject = null; 199 200 try { 201 202 subject = note.getSubject(); 203 204 } catch (Exception e) { 205 throw new DataAccessException(e.getMessage()); 206 } 207 208 String [] fields = { 209 NoteDAO.TAG_SUBJECT 210 }; 211 212 Object [] values = { 213 subject 214 }; 215 216 notes = this.nd.getNotes(username, 217 credentials, 218 fields, 219 values, 220 exchangeFolder); 221 222 if (notes == null || !(notes.length > 0)) { 223 return null; 224 } 225 226 return notes[0]; 227 } 228 229 } 230 | Popular Tags |