package com.github.aureliano.achmed.os.pkg;

import com.github.aureliano.achmed.command.CommandResponse;
import com.github.aureliano.achmed.resources.properties.PackageProperties;

public class DpkgPackageManager implements IPackageManager {

	private PackageProperties properties;
	
	public DpkgPackageManager() {
		super();
	}

	public CommandResponse install() {
		throw new UnsupportedOperationException("Method not implemented yet.");
	}

	public CommandResponse uninstall() {
		throw new UnsupportedOperationException("Method not implemented yet.");
	}

	public String latest() {
		throw new UnsupportedOperationException("Method not implemented yet.");
	}

	public void setPackageProperties(PackageProperties properties) {
		this.properties = properties;
	}

	public PackageProperties getPackageProperties() {
		return this.properties;
	}
}
@@ -92,570 +92,1445 @@
 mand
-Response;%0Aimport com.github.aureliano.achmed.resources.properties.PackageProperties;%0A%0Apublic class DpkgPackageManager implements IPackageManager %7B%0A%0A%09private PackageProperties properties;%0A%09%0A%09public DpkgPackageManager() %7B%0A%09%09super();%0A%09%7D%0A%0A%09public CommandResponse install() %7B%0A%09%09throw new UnsupportedOperationException(%22Method not implemented yet.%22);%0A%09%7D%0A%0A%09public CommandResponse uninstall() %7B%0A%09%09throw new UnsupportedOperationException(%22Method not implemented yet.%22);%0A%09%7D%0A%0A%09public String latest() %7B%0A%09%09throw new UnsupportedOperationException(%22Method not implemented yet.%22
+Facade;%0Aimport com.github.aureliano.achmed.command.CommandResponse;%0Aimport com.github.aureliano.achmed.exception.PackageResourceException;%0Aimport com.github.aureliano.achmed.helper.StringHelper;%0Aimport com.github.aureliano.achmed.resources.properties.PackageProperties;%0A%0Apublic class DpkgPackageManager implements IPackageManager %7B%0A%09%0A%09private static final String DPKG_QUERY = %22/usr/bin/dpkg-query%22;%0A%09private static final String QUERY_FORMAT = %22'$%7Bstatus%7D $%7Bversion%7D%5C%5Cn'%22;%0A%0A%09private PackageProperties properties;%0A%09%0A%09public DpkgPackageManager() %7B%0A%09%09super();%0A%09%7D%0A%0A%09public CommandResponse install() %7B%0A%09%09throw new UnsupportedOperationException(%22Method not implemented yet.%22);%0A%09%7D%0A%0A%09public CommandResponse uninstall() %7B%0A%09%09throw new UnsupportedOperationException(%22Method not implemented yet.%22);%0A%09%7D%0A%0A%09public String latest() %7B%0A%09%09throw new UnsupportedOperationException(%22Method not implemented yet.%22);%0A%09%7D%0A%09%0A%09public boolean isInstalled() %7B%0A%09%09final String desiredStatus = %22installed%22;%0A%09%09CommandResponse res = CommandFacade.executeCommand(%0A%09%09%09DPKG_QUERY, %22-W%22, %22-f%22, QUERY_FORMAT, this.properties.getName()%0A%09%09);%0A%09%09%0A%09%09if (!res.isOK()) %7B%0A%09%09%09throw new PackageResourceException(res);%0A%09%09%7D%0A%09%09%0A%09%09String%5B%5D match = StringHelper.match(%22%5E(%5C%5CS+)%5C%5Cs+(%5C%5CS+)%5C%5Cs+(%5C%5CS+)%5C%5Cs+(%5C%5CS*)$%22, res.getOutput());%0A%09%09if (match == null) %7B%0A%09%09%09throw new PackageResourceException(%22Failed to match dpkg-query %22 + res.getCommand());%0A%09%09%7D%0A%09%09%0A%09%09return desiredStatus.equalsIgnoreCase(match%5B3%5D
 );%0A%09

Implement methodo to check wheter package is installed.