|
Lines 17-22
Link Here
|
| 17 |
import java.util.ArrayList; |
17 |
import java.util.ArrayList; |
| 18 |
import java.util.Date; |
18 |
import java.util.Date; |
| 19 |
import java.util.HashMap; |
19 |
import java.util.HashMap; |
|
|
20 |
import java.util.HashSet; |
| 20 |
import java.util.List; |
21 |
import java.util.List; |
| 21 |
import java.util.Map; |
22 |
import java.util.Map; |
| 22 |
import java.util.Set; |
23 |
import java.util.Set; |
|
Lines 40-52
Link Here
|
| 40 |
import org.eclipse.jface.dialogs.MessageDialog; |
41 |
import org.eclipse.jface.dialogs.MessageDialog; |
| 41 |
import org.eclipse.mylyn.internal.tasks.core.TaskDataManager; |
42 |
import org.eclipse.mylyn.internal.tasks.core.TaskDataManager; |
| 42 |
import org.eclipse.mylyn.internal.tasks.core.TaskExternalizationException; |
43 |
import org.eclipse.mylyn.internal.tasks.core.TaskExternalizationException; |
|
|
44 |
import org.eclipse.mylyn.internal.tasks.core.TaskRepositoriesExternalizer; |
| 43 |
import org.eclipse.mylyn.internal.tasks.ui.ITasksUiConstants; |
45 |
import org.eclipse.mylyn.internal.tasks.ui.ITasksUiConstants; |
| 44 |
import org.eclipse.mylyn.monitor.core.StatusHandler; |
46 |
import org.eclipse.mylyn.monitor.core.StatusHandler; |
| 45 |
import org.eclipse.mylyn.tasks.core.AbstractRepositoryQuery; |
47 |
import org.eclipse.mylyn.tasks.core.AbstractRepositoryQuery; |
| 46 |
import org.eclipse.mylyn.tasks.core.AbstractTaskContainer; |
|
|
| 47 |
import org.eclipse.mylyn.tasks.core.AbstractTask; |
48 |
import org.eclipse.mylyn.tasks.core.AbstractTask; |
|
|
49 |
import org.eclipse.mylyn.tasks.core.AbstractTaskContainer; |
| 48 |
import org.eclipse.mylyn.tasks.core.AbstractTaskListFactory; |
50 |
import org.eclipse.mylyn.tasks.core.AbstractTaskListFactory; |
| 49 |
import org.eclipse.mylyn.tasks.core.TaskList; |
51 |
import org.eclipse.mylyn.tasks.core.TaskList; |
|
|
52 |
import org.eclipse.mylyn.tasks.core.TaskRepository; |
| 53 |
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin; |
| 50 |
import org.w3c.dom.Document; |
54 |
import org.w3c.dom.Document; |
| 51 |
import org.w3c.dom.Element; |
55 |
import org.w3c.dom.Element; |
| 52 |
import org.w3c.dom.Node; |
56 |
import org.w3c.dom.Node; |
|
Lines 82-87
Link Here
|
| 82 |
private List<AbstractTaskListFactory> externalizers; |
86 |
private List<AbstractTaskListFactory> externalizers; |
| 83 |
|
87 |
|
| 84 |
private DelegatingTaskExternalizer delagatingExternalizer; |
88 |
private DelegatingTaskExternalizer delagatingExternalizer; |
|
|
89 |
|
| 90 |
private TaskRepositoriesExternalizer repositoriesExternalizer; |
| 85 |
|
91 |
|
| 86 |
private List<Node> orphanedTaskNodes = new ArrayList<Node>(); |
92 |
private List<Node> orphanedTaskNodes = new ArrayList<Node>(); |
| 87 |
|
93 |
|
|
Lines 93-98
Link Here
|
| 93 |
|
99 |
|
| 94 |
public TaskListWriter() { |
100 |
public TaskListWriter() { |
| 95 |
this.delagatingExternalizer = new DelegatingTaskExternalizer(); |
101 |
this.delagatingExternalizer = new DelegatingTaskExternalizer(); |
|
|
102 |
this.repositoriesExternalizer = new TaskRepositoriesExternalizer(); |
| 96 |
} |
103 |
} |
| 97 |
|
104 |
|
| 98 |
public void setDelegateExternalizers(List<AbstractTaskListFactory> externalizers) { |
105 |
public void setDelegateExternalizers(List<AbstractTaskListFactory> externalizers) { |
|
Lines 196-208
Link Here
|
| 196 |
private void writeDOMtoFile(Document doc, File file) { |
203 |
private void writeDOMtoFile(Document doc, File file) { |
| 197 |
try { |
204 |
try { |
| 198 |
ZipOutputStream outputStream = new ZipOutputStream(new FileOutputStream(file)); |
205 |
ZipOutputStream outputStream = new ZipOutputStream(new FileOutputStream(file)); |
| 199 |
ZipEntry zipEntry = new ZipEntry(ITasksUiConstants.OLD_TASK_LIST_FILE); |
206 |
writeTaskListToZipEntry(doc, outputStream); |
| 200 |
outputStream.putNextEntry(zipEntry); |
|
|
| 201 |
outputStream.setMethod(ZipOutputStream.DEFLATED); |
| 202 |
// OutputStream outputStream = new FileOutputStream(file); |
| 203 |
writeDOMtoStream(doc, outputStream); |
| 204 |
outputStream.flush(); |
| 205 |
outputStream.closeEntry(); |
| 206 |
outputStream.close(); |
207 |
outputStream.close(); |
| 207 |
} catch (Exception fnfe) { |
208 |
} catch (Exception fnfe) { |
| 208 |
StatusHandler.log(fnfe, "TaskList could not be found"); |
209 |
StatusHandler.log(fnfe, "TaskList could not be found"); |
|
Lines 210-215
Link Here
|
| 210 |
} |
211 |
} |
| 211 |
|
212 |
|
| 212 |
/** |
213 |
/** |
|
|
214 |
* @param doc |
| 215 |
* @param outputStream |
| 216 |
* @throws IOException |
| 217 |
*/ |
| 218 |
private void writeTaskListToZipEntry(Document doc, ZipOutputStream outputStream) throws IOException { |
| 219 |
ZipEntry zipEntry = new ZipEntry(ITasksUiConstants.OLD_TASK_LIST_FILE); |
| 220 |
outputStream.putNextEntry(zipEntry); |
| 221 |
outputStream.setMethod(ZipOutputStream.DEFLATED); |
| 222 |
// OutputStream outputStream = new FileOutputStream(file); |
| 223 |
writeDOMtoStream(doc, outputStream); |
| 224 |
outputStream.flush(); |
| 225 |
outputStream.closeEntry(); |
| 226 |
} |
| 227 |
|
| 228 |
/** |
| 213 |
* Writes the provided XML document out to the specified output stream. |
229 |
* Writes the provided XML document out to the specified output stream. |
| 214 |
* |
230 |
* |
| 215 |
* doc - the document to be written outputStream - the stream to which the document is to be written |
231 |
* doc - the document to be written outputStream - the stream to which the document is to be written |
|
Lines 427-433
Link Here
|
| 427 |
if (inputFile.getName().endsWith(ITasksUiConstants.FILE_EXTENSION)) { |
443 |
if (inputFile.getName().endsWith(ITasksUiConstants.FILE_EXTENSION)) { |
| 428 |
// is zipped context |
444 |
// is zipped context |
| 429 |
inputStream = new ZipInputStream(new FileInputStream(inputFile)); |
445 |
inputStream = new ZipInputStream(new FileInputStream(inputFile)); |
| 430 |
((ZipInputStream) inputStream).getNextEntry(); |
446 |
// search for TaskList entry |
|
|
447 |
ZipEntry entry = ((ZipInputStream) inputStream).getNextEntry(); |
| 448 |
while (entry != null) { |
| 449 |
if (ITasksUiConstants.OLD_TASK_LIST_FILE.equals(entry.getName())) { |
| 450 |
break; |
| 451 |
} |
| 452 |
entry = ((ZipInputStream) inputStream).getNextEntry(); |
| 453 |
} |
| 454 |
if (entry == null) { |
| 455 |
return null; |
| 456 |
} |
| 431 |
} else { |
457 |
} else { |
| 432 |
inputStream = new FileInputStream(inputFile); |
458 |
inputStream = new FileInputStream(inputFile); |
| 433 |
} |
459 |
} |
|
Lines 494-502
Link Here
|
| 494 |
} |
520 |
} |
| 495 |
|
521 |
|
| 496 |
public void writeQueries(List<AbstractRepositoryQuery> queries, File outFile) { |
522 |
public void writeQueries(List<AbstractRepositoryQuery> queries, File outFile) { |
|
|
523 |
Set<TaskRepository> repositories = new HashSet<TaskRepository>(); |
| 524 |
for (AbstractRepositoryQuery query : queries) { |
| 525 |
TaskRepository repository = TasksUiPlugin.getRepositoryManager().getRepository(query.getRepositoryUrl()); |
| 526 |
if (repository != null) { |
| 527 |
repositories.add(repository); |
| 528 |
} |
| 529 |
} |
| 530 |
|
| 497 |
Document doc = createQueryDocument(queries); |
531 |
Document doc = createQueryDocument(queries); |
| 498 |
if (doc != null) { |
532 |
if (doc != null) { |
| 499 |
writeDOMtoFile(doc, outFile); |
533 |
try { |
|
|
534 |
ZipOutputStream outputStream = new ZipOutputStream(new FileOutputStream(outFile)); |
| 535 |
writeTaskListToZipEntry(doc, outputStream); |
| 536 |
repositoriesExternalizer.writeRepositoriesToZipEntry(repositories, outputStream); |
| 537 |
outputStream.close(); |
| 538 |
} catch (Exception fnfe) { |
| 539 |
StatusHandler.log(fnfe, "TaskList could not be found"); |
| 540 |
} |
| 500 |
} |
541 |
} |
| 501 |
return; |
542 |
return; |
| 502 |
} |
543 |
} |
|
Lines 582-585
Link Here
|
| 582 |
|
623 |
|
| 583 |
return queries; |
624 |
return queries; |
| 584 |
} |
625 |
} |
|
|
626 |
|
| 627 |
public Set<TaskRepository> readRepositories(File file) { |
| 628 |
Set<TaskRepository> repository = repositoriesExternalizer.readRepositoriesFromXML(file); |
| 629 |
if (repository == null) { |
| 630 |
repository = new HashSet<TaskRepository>(); |
| 631 |
} |
| 632 |
return repository; |
| 633 |
} |
| 585 |
} |
634 |
} |