Skip to content

Commit

Permalink
Product version stuff renamed.
Browse files Browse the repository at this point in the history
Component -> ComponentDefinition
ProductVersion -> ProductVersionDefinition
Product -> ProductDefinition
Suite -> SuiteDefinition
SuiteLoadingException -> SuiteDefinitionLoadingException
ProductVersionStateWrap -> LocalProductVersion
ProductState -> LocalProduct
  • Loading branch information
asheb committed Aug 29, 2008
1 parent 3cc7865 commit a5588cc
Show file tree
Hide file tree
Showing 29 changed files with 782 additions and 793 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;

import com.yoursway.autoupdater.auxiliary.Suite;
import com.yoursway.autoupdater.auxiliary.SuiteDefinition;
import com.yoursway.autoupdater.gui.view.VersionsView;
import com.yoursway.autoupdater.localrepository.LocalRepository;

Expand All @@ -21,10 +21,10 @@ public static void main(String[] args) {
shell.setText("Autoupdater");
shell.setBounds(new Rectangle(480, 320, 320, 240));

Suite suite = null;
SuiteDefinition suite = null;
LocalRepository localRepository = null;
try {
suite = Suite.load(args[0], args[1]);
suite = SuiteDefinition.load(args[0], args[1]);
localRepository = LocalRepository.createForGUI();
} catch (Throwable e) {
fatalError(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableItem;

import com.yoursway.autoupdater.auxiliary.ProductVersion;
import com.yoursway.autoupdater.auxiliary.Suite;
import com.yoursway.autoupdater.auxiliary.ProductVersionDefinition;
import com.yoursway.autoupdater.auxiliary.SuiteDefinition;
import com.yoursway.autoupdater.gui.demo.UpdaterStyleMock;
import com.yoursway.autoupdater.localrepository.LocalRepository;
import com.yoursway.autoupdater.localrepository.UpdatingListener;

public class VersionsView {

public VersionsView(Composite parent, Suite suite, final LocalRepository localRepository,
public VersionsView(Composite parent, SuiteDefinition suite, final LocalRepository localRepository,
UpdaterStyle style) {

parent.setLayout(new GridLayout());

final Table versions = new Table(parent, SWT.SINGLE);
versions.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

for (ProductVersion version : suite.versions()) {
for (ProductVersionDefinition version : suite.versions()) {
TableItem item = new TableItem(versions, SWT.NONE);
item.setData(version);
item.setText(version.toString());
Expand Down Expand Up @@ -75,7 +75,7 @@ public void widgetSelected(SelectionEvent e) {
TableItem[] selection = versions.getSelection();
assertion(selection.length == 1, "Only one item must be selected");
TableItem item = selection[0];
ProductVersion version = (ProductVersion) item.getData();
ProductVersionDefinition version = (ProductVersionDefinition) item.getData();

localRepository.startUpdating(version, new UpdatingListener() {
public void downloadingStarted() {
Expand Down Expand Up @@ -135,7 +135,7 @@ public void run() {

}

public static void show(Suite suite, LocalRepository localRepository) {
public static void show(SuiteDefinition suite, LocalRepository localRepository) {
Shell shell = new Shell();
//! magic
shell.setText("Autoupdater");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
import org.junit.After;
import org.junit.Test;

import com.yoursway.autoupdater.auxiliary.Component;
import com.yoursway.autoupdater.auxiliary.ComponentDefinition;
import com.yoursway.autoupdater.auxiliary.ComponentFile;
import com.yoursway.autoupdater.auxiliary.ComponentStopper;
import com.yoursway.autoupdater.auxiliary.Product;
import com.yoursway.autoupdater.auxiliary.ProductVersion;
import com.yoursway.autoupdater.auxiliary.ProductDefinition;
import com.yoursway.autoupdater.auxiliary.ProductVersionDefinition;
import com.yoursway.autoupdater.filelibrary.Request;
import com.yoursway.autoupdater.installer.Installer;
import com.yoursway.autoupdater.installer.InstallerException;
Expand All @@ -48,7 +48,7 @@ public class InstallerTests {
@Test
public void external() throws IOException, InstallerException, UnexpectedMessageException {
Installer installer = new ExternalInstaller();
Collection<Component> components = newLinkedList(component(12, 25), component(23, 42));
Collection<ComponentDefinition> components = newLinkedList(component(12, 25), component(23, 42));
File target = createTempFolder();

install(installer, components, components, target);
Expand All @@ -64,7 +64,7 @@ public void external() throws IOException, InstallerException, UnexpectedMessage
@Test
public void internal() throws IOException, InstallerException {
Installer installer = new InternalInstaller();
Collection<Component> components = newLinkedList(component(12, 25), component(23, 42));
Collection<ComponentDefinition> components = newLinkedList(component(12, 25), component(23, 42));
File target = createTempFolder();

install(installer, components, components, target);
Expand All @@ -76,8 +76,8 @@ public void internal() throws IOException, InstallerException {
@Test
public void deleting() throws IOException, InstallerException {
Installer installer = new InternalInstaller();
Collection<Component> components1 = newLinkedList(component(8, 15), component(33, 48));
Collection<Component> components2 = newLinkedList(component(12, 25), component(23, 42));
Collection<ComponentDefinition> components1 = newLinkedList(component(8, 15), component(33, 48));
Collection<ComponentDefinition> components2 = newLinkedList(component(12, 25), component(23, 42));
File target = createTempFolder();

createFiles(target, components1);
Expand All @@ -95,7 +95,7 @@ public void deleting() throws IOException, InstallerException {
@Test
public void date() throws IOException, InstallerException {
Installer installer = new InternalInstaller();
Collection<Component> components = newLinkedList(component(12, 25), component(23, 42));
Collection<ComponentDefinition> components = newLinkedList(component(12, 25), component(23, 42));
File target = createTempFolder();

install(installer, components, components, target);
Expand All @@ -112,14 +112,14 @@ public void cleanEach() {
tempFolders.clear();
}

private void install(Installer installer, Collection<Component> oldComponents,
Collection<Component> newComponents, File target) throws IOException, InstallerException {
private void install(Installer installer, Collection<ComponentDefinition> oldComponents,
Collection<ComponentDefinition> newComponents, File target) throws IOException, InstallerException {

Product product = new Product("UNNAMED");
ProductDefinition product = new ProductDefinition("UNNAMED");
Collection<Request> p = newLinkedList();

ProductVersion current = new ProductVersion(product, p, oldComponents, "");
ProductVersion version = new ProductVersion(product, p, newComponents, "");
ProductVersionDefinition current = new ProductVersionDefinition(product, p, oldComponents, "");
ProductVersionDefinition version = new ProductVersionDefinition(product, p, newComponents, "");

Map<String, File> packs = packs();
File extInstallerFolder = createTempFolder();
Expand All @@ -132,8 +132,8 @@ public boolean stop() {
installer.install(current, version, packs, target, extInstallerFolder, stopper);
}

private void createFiles(File target, Collection<Component> components) throws IOException {
for (Component component : components)
private void createFiles(File target, Collection<ComponentDefinition> components) throws IOException {
for (ComponentDefinition component : components)
for (ComponentFile file : component.files())
new File(target, file.path()).createNewFile();
}
Expand All @@ -144,8 +144,8 @@ private File createTempFolder() throws IOException {
return folder;
}

private Component component(int first, int last) throws MalformedURLException {
return new Component(files(first, last), packs(first, last));
private ComponentDefinition component(int first, int last) throws MalformedURLException {
return new ComponentDefinition(files(first, last), packs(first, last));
}

private Collection<ComponentFile> files(int first, int last) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
import org.junit.Before;
import org.junit.Test;

import com.yoursway.autoupdater.auxiliary.Component;
import com.yoursway.autoupdater.auxiliary.ComponentDefinition;
import com.yoursway.autoupdater.auxiliary.ComponentStopper;
import com.yoursway.autoupdater.auxiliary.Product;
import com.yoursway.autoupdater.auxiliary.ProductVersion;
import com.yoursway.autoupdater.auxiliary.ProductDefinition;
import com.yoursway.autoupdater.auxiliary.ProductVersionDefinition;
import com.yoursway.autoupdater.filelibrary.Request;
import com.yoursway.autoupdater.filelibrary.RequestUtils;
import com.yoursway.autoupdater.installer.Installer;
Expand Down Expand Up @@ -49,13 +49,14 @@ public void integration_simple() throws IOException, InterruptedException {
Collection<Request> requests = RequestUtils.requests(first, last, ".zip");
RequestUtils.mount(server, requests);

Product product = new Product("UNNAMED");
Collection<Component> packs = newLinkedList();
ProductVersion version = new ProductVersion(product, requests, packs, "");
ProductDefinition product = new ProductDefinition("UNNAMED");
Collection<ComponentDefinition> components = newLinkedList();
ProductVersionDefinition version = new ProductVersionDefinition(product, requests, components, "");

LocalRepository repo = new LocalRepository(new Installer() {
public void install(ProductVersion current, ProductVersion version, Map<String, File> packs,
File target, File extInstallerFolder, ComponentStopper stopper) throws InstallerException {
public void install(ProductVersionDefinition current, ProductVersionDefinition version,
Map<String, File> packs, File target, File extInstallerFolder, ComponentStopper stopper)
throws InstallerException {

System.out.println("Installation started!");

Expand Down
4 changes: 2 additions & 2 deletions com.yoursway.autoupdater/protos/InstallationProtos.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ message PackMemento {
}

message InstallationMemento {
required ProductVersionMemento current = 1;
required ProductVersionMemento version = 2;
required ProductVersionDefinitionMemento current = 1;
required ProductVersionDefinitionMemento version = 2;
repeated PackMemento pack = 3;
required string target = 4;
}
31 changes: 14 additions & 17 deletions com.yoursway.autoupdater/protos/LocalRepositoryProtos.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,44 +13,41 @@ message ComponentFileMemento {
required string path = 4;
}

message ComponentMemento {
message ComponentDefinitionMemento {
repeated ComponentFileMemento file = 1;
repeated RequestMemento pack = 2;
}

message ProductMemento {
message ProductDefinitionMemento {

}

message ProductVersionMemento {
required ProductMemento product = 1;
message ProductVersionDefinitionMemento {
required ProductDefinitionMemento product = 1;

repeated RequestMemento pack = 2;
repeated ComponentMemento component = 3;
repeated ComponentDefinitionMemento component = 3;

required string executable = 4;
}

message ProductVersionStateMemento {
required ProductVersionMemento version = 1;
message LocalProductVersionMemento {
required ProductVersionDefinitionMemento definition = 1;

enum State {
New = 0;
Downloading = 1;
Installing = 2;
Current = 3;
Old = 4;
Idle = 0;
Installing = 1;
}

required State state = 2;
}

message ProductStateMemento {
required ProductMemento product = 1;
message LocalProductMemento {
required ProductDefinitionMemento definition = 1;

repeated ProductVersionStateMemento version = 2;
repeated LocalProductVersionMemento version = 2;
}

message LocalRepositoryMemento {
repeated ProductStateMemento product = 1;
}
repeated LocalProductMemento product = 1;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,22 @@
import java.util.Map;

import com.yoursway.autoupdater.filelibrary.Request;
import com.yoursway.autoupdater.protos.LocalRepositoryProtos.ComponentDefinitionMemento;
import com.yoursway.autoupdater.protos.LocalRepositoryProtos.ComponentFileMemento;
import com.yoursway.autoupdater.protos.LocalRepositoryProtos.ComponentMemento;
import com.yoursway.autoupdater.protos.LocalRepositoryProtos.RequestMemento;
import com.yoursway.autoupdater.protos.LocalRepositoryProtos.ComponentMemento.Builder;
import com.yoursway.autoupdater.protos.LocalRepositoryProtos.ComponentDefinitionMemento.Builder;

public class Component {
public class ComponentDefinition {

private static final String COMPONENTS_PATH = "components/";
private static final String PACKS_PATH = "packs/";

private final Map<String, ComponentFile> files = newHashMap();
private final Collection<Request> packs;

private String name;

public Component(Collection<ComponentFile> files, Collection<Request> packs) {
public ComponentDefinition(Collection<ComponentFile> files, Collection<Request> packs) {
if (packs == null)
throw new NullPointerException("packs is null");

Expand All @@ -41,7 +42,7 @@ private void addFile(ComponentFile file) {
files.put(file.hash, file);
}

public Component(URL updateSite, String name) throws IOException, InvalidFileFormatException {
public ComponentDefinition(URL updateSite, String name) throws IOException, InvalidFileFormatException {
this.name = name;
packs = newLinkedList();

Expand Down Expand Up @@ -77,18 +78,18 @@ public Collection<ComponentFile> files() {
return files.values();
}

static Component fromMemento(ComponentMemento memento) throws MalformedURLException {
static ComponentDefinition fromMemento(ComponentDefinitionMemento memento) throws MalformedURLException {
Collection<ComponentFile> files = newLinkedList();
Collection<Request> packs = newLinkedList();
for (RequestMemento m : memento.getPackList())
packs.add(Request.fromMemento(m));
for (ComponentFileMemento m : memento.getFileList())
files.add(ComponentFile.fromMemento(m));
return new Component(files, packs);
return new ComponentDefinition(files, packs);
}

ComponentMemento toMemento() {
Builder b = ComponentMemento.newBuilder();
ComponentDefinitionMemento toMemento() {
Builder b = ComponentDefinitionMemento.newBuilder();
for (Request pack : packs)
b.addPack(pack.toMemento());
for (ComponentFile file : files.values())
Expand Down

This file was deleted.

Loading

0 comments on commit a5588cc

Please sign in to comment.