/*
*
* author:  gvenzl
* created: 27 Mar 2016
*
* name: FileRepository.java
*
*/

package com.dbpm.repository;

import java.io.File;

import com.dbpm.logger.Logger;

public class FileRepository implements Repository {
	
	private File repo;
	private File store;
	
	public FileRepository(String repo, String store) {
		this.repo = new File(repo);
		this.store = new File(store);
	}
	
	@Override
	public boolean checkRepo() {
		return false;
	}

	@Override
	public boolean createRepo() {
		if (repo.exists()) {
			if (!repo.delete()) {
				return false;
			}
		}
		try {
			repo.createNewFile();
		} catch (Exception e) {
			Logger.error(e.getMessage());
			return false;
		}
		
		if (store.exists()) {
			if (!store.delete()) {
				return false;
			}
		}
		if (!store.mkdir()) {
			return false;
		}
		
		return true;
	}

	@Override
	public boolean writeEntry(Package pgk) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean savePackage(Package pgk, byte[] content) {
		// TODO Auto-generated method stub
		return false;
	}

}

@@ -127,16 +127,301 @@
 .File;%0A%0A
+import javax.xml.parsers.DocumentBuilderFactory;%0Aimport javax.xml.transform.Transformer;%0Aimport javax.xml.transform.TransformerFactory;%0Aimport javax.xml.transform.dom.DOMSource;%0Aimport javax.xml.transform.stream.StreamResult;%0A%0Aimport org.w3c.dom.Document;%0Aimport org.w3c.dom.Element;%0A%0A
 import c
@@ -443,16 +443,16 @@
 Logger;%0A
-
 %0Apublic 
@@ -853,29 +853,391 @@
 %0A%09%09%09
-repo.createNewFile();
+// Initialize XML file%0A%09%09%09Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();%0A%09%09%09Element rootElement = doc.createElement(%22repository%22);%0A%09%09%09doc.appendChild(rootElement);%0A%09%09%09%0A%09%09%09// Write XML to disk%0A%09%09%09Transformer transformer = TransformerFactory.newInstance().newTransformer();%0A%09%09%09transformer.transform(new DOMSource(doc), new StreamResult(repo));%0A
 %0A%09%09%7D

Initialize repo.xml