this.files = files;
this.configuration = configuration;
this.actionURL = actionURL;
- }
+ }
public IStatus runInWorkspace(IProgressMonitor monitor) {
ProblemConsole console = new ProblemConsole();
HashMap map = new HashMap();
String wikiTitle;
for (int i = 0; i < files.length; i++) {
- wikiTitle = Util.getReadableWikiName(files[i]);
+ file = files[i];
+ wikiTitle = createWikiTitle(file, i);
buffer.append(wikiTitle);
- map.put(wikiTitle, files[i]);
+ map.put(wikiTitle, file);
if (i != files.length - 1) {
buffer.append("\n");
}
ArrayList list = mwConnector.loadXML(configuration, url, buffer.toString());
String body;
- for (int i = 0; i < list.size(); i++) {
- Parsed parsed = (Parsed) list.get(i);
- wikiTitle = parsed.getTitle();
- if (wikiTitle != null) {
- body = parsed.getBody();
- if (body != null) {
- file = (IFile) map.get(wikiTitle);
- if (file != null) {
- // rearrange parsed data into a page for XStream hamdling:
- Page page = new Page(parsed.getDateTimestamp(), wikiTitle, body);
- monitor.subTask("Modify file: " + file.getLocation().toString());
- updateFileContent(console, file, page, body, configuration, monitor);
+ if (list.size() == 0&&files.length>0) {
+ console.println("File: " + file.getLocation().toString() + " not available on the server.");
+ } else {
+ if (list.size() < files.length) {
+ console.println("Not all requested files are available on the server.");
+ }
+ for (int i = 0; i < list.size(); i++) {
+ Parsed parsed = (Parsed) list.get(i);
+ wikiTitle = parsed.getTitle();
+ if (wikiTitle != null) {
+ body = parsed.getBody();
+ if (body != null) {
+ file = (IFile) map.get(wikiTitle);
+ if (file != null) {
+ // rearrange parsed data into a page for XStream hamdling:
+ Page page = new Page(parsed.getDateTimestamp(), wikiTitle, body);
+ monitor.subTask("Modify file: " + file.getLocation().toString());
+ updateFileContent(console, file, page, body, configuration, monitor);
+ }
}
}
- }
- if (monitor.isCanceled()) {
- return Status.CANCEL_STATUS;
+ if (monitor.isCanceled()) {
+ return Status.CANCEL_STATUS;
+ }
}
}
if (isModal(this)) {
return Status.OK_STATUS;
}
+ /**
+ * @param file
+ * @param wikiTitle
+ * @param i
+ * @return
+ */
+ private String createWikiTitle(IFile file, int i) {
+ String wikiTitle = null;
+ String srcBasePath = Util.getWikiTextsPath(file);
+ String binBasePath = Util.getProjectsWikiOutputPath(file.getProject(), WikiEditorPlugin.HTML_OUTPUT_PATH);
+
+ String fileXMLName = Util.getXMLFileName(file, binBasePath, srcBasePath);
+ IPath path = new Path(fileXMLName);
+ IFile xmlFile = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path);
+ if (xmlFile.exists()) {
+ try {
+ Page page = XStreamManager.fromXML(xmlFile.getContents());
+ if (page != null) {
+ wikiTitle = page.getTitle();
+ }
+ // timestamp = XMLReader.getDateTimestamp(xmlFile.getContents());
+ } catch (Exception e2) {
+ }
+ }
+ if (wikiTitle == null) {
+ // if no XML file exists we create the name from the filename
+ wikiTitle = Util.getReadableWikiName(files[i]);
+ }
+ return wikiTitle;
+ }
+
public boolean isModal(Job job) {
Boolean isModal = (Boolean) job.getProperty(IProgressConstants.PROPERTY_IN_DIALOG);
if (isModal == null) {