Skip to content

Commit

Permalink
new version 0.0.7:
Browse files Browse the repository at this point in the history
* add network connection proxy capability
* change user configuration persistence
* change cache management
* minor refactoring
  • Loading branch information
mhelleboid committed Nov 7, 2015
1 parent ea91d8c commit 7dab5e0
Show file tree
Hide file tree
Showing 56 changed files with 1,046 additions and 775 deletions.
45 changes: 22 additions & 23 deletions remotesync-api/.settings/PiwigoRemoteSync API Junit AllTests.launch
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
<stringAttribute key="bad_container_name" value="/remotesync-api/.se"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/remotesync-api/src/test/java/org/piwigo/remotesync/api/test/RemotesyncAPIAllTests.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<mapAttribute key="org.eclipse.debug.core.preferred_launchers">
<mapEntry key="[debug]" value="org.eclipse.jdt.junit.launchconfig"/>
<mapEntry key="[run]" value="org.eclipse.jdt.junit.launchconfig"/>
</mapAttribute>
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/java-1.7.0-openjdk-i386"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.piwigo.remotesync.api.test.RemotesyncAPIAllTests"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="remotesync-api"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
</launchConfiguration>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
<stringAttribute key="bad_container_name" value="/remotesync-api/.se"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/remotesync-api/src/test/java/org/piwigo/remotesync/api/test/RemotesyncAPIAllTests.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<mapAttribute key="org.eclipse.debug.core.preferred_launchers">
<mapEntry key="[debug]" value="org.eclipse.jdt.junit.launchconfig"/>
<mapEntry key="[run]" value="org.eclipse.jdt.junit.launchconfig"/>
</mapAttribute>
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.piwigo.remotesync.api.test.RemotesyncAPIAllTests"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="remotesync-api"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
</launchConfiguration>
29 changes: 14 additions & 15 deletions remotesync-api/.settings/PiwigoRemoteSync API Main.launch
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/remotesync-api/src/main/java/org/piwigo/remotesync/api/Main.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/java-1.7.0-openjdk-i386"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.piwigo.remotesync.api.Main"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-debug -help"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="remotesync-api"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
</launchConfiguration>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/remotesync-api/src/main/java/org/piwigo/remotesync/api/Main.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.piwigo.remotesync.api.Main"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-debug -help"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="remotesync-api"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
</launchConfiguration>
2 changes: 1 addition & 1 deletion remotesync-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
<parent>
<groupId>piwigo</groupId>
<artifactId>remotesync</artifactId>
<version>0.0.6</version>
<version>0.0.7</version>
<relativePath>../remotesync</relativePath>
</parent>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@
******************************************************************************/
package org.piwigo.remotesync.api;

import org.piwigo.remotesync.api.client.Client;
import org.piwigo.remotesync.api.exception.ClientServerException;
import org.piwigo.remotesync.api.request.*;
import org.piwigo.remotesync.api.response.*;

@org.piwigo.remotesync.generator.Generated
public abstract class AbstractAPI {

protected abstract Client getClient();
protected abstract IClient getClient();

public PwgCaddieAddResponse caddieAdd(PwgCaddieAddRequest request) throws ClientServerException {
return getClient().sendRequest(request);
Expand Down
15 changes: 7 additions & 8 deletions remotesync-api/src/main/java/org/piwigo/remotesync/api/API.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import org.piwigo.remotesync.api.AbstractAPI;
import org.piwigo.remotesync.api.client.AuthenticatedWSClient;
import org.piwigo.remotesync.api.client.Client;
import org.piwigo.remotesync.api.exception.ClientServerException;
import org.piwigo.remotesync.api.request.PwgImagesAddAllChunksRequest;
import org.piwigo.remotesync.api.request.PwgImagesAddFileWithChunkRequest;
Expand All @@ -24,26 +23,26 @@

public class API extends AbstractAPI {

protected Client client;
protected IClient client;

public API(Client client) {
public API(IClient client) {
this.client = client;
}

public API(String url) {
this.client = new AuthenticatedWSClient(url);
public API(IClientConfiguration clientConfiguration) {
this.client = new AuthenticatedWSClient(clientConfiguration);
}

public void login(String username, String password) throws ClientServerException {
client.login(username, password);
public void login() throws ClientServerException {
client.login();
}

public void logout() throws ClientServerException {
client.logout();
}

@Override
protected Client getClient() {
protected IClient getClient() {
return client;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;
import org.kohsuke.args4j.OptionHandlerFilter;
import org.piwigo.remotesync.api.conf.Config;
import org.piwigo.remotesync.api.conf.ConfigUtil;
import org.piwigo.remotesync.api.conf.GalleryConfig;
import org.piwigo.remotesync.api.conf.UserConfiguration;
import org.piwigo.remotesync.api.conf.ConfigurationUtil;
import org.piwigo.remotesync.api.conf.SyncConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -27,15 +27,15 @@ public abstract class AbstractMain {
private static final Logger logger = LoggerFactory.getLogger(AbstractMain.class);

protected void run(String[] args) {
GalleryConfig parsedGalleryConfig = new GalleryConfig();
CmdLineParser cmdLineParser = createParser(parsedGalleryConfig);
SyncConfiguration parsedSyncConfiguration = new SyncConfiguration();
CmdLineParser cmdLineParser = createParser(parsedSyncConfiguration);

try {
cmdLineParser.parseArgument(args);

configureLog(debug);

createConfig(parsedGalleryConfig);
createConfiguration(parsedSyncConfiguration);

if (help) {
System.out.println("Piwigo Remote Sync : java -jar remotesync.jar");
Expand All @@ -61,19 +61,19 @@ protected void run(String[] args) {
@Option(name = "-help", usage = "help")
protected boolean help = false;

protected CmdLineParser createParser(GalleryConfig galleryConfig) {
protected CmdLineParser createParser(ISyncConfiguration syncConfiguration) {
CmdLineParser cmdLineParser = new CmdLineParser(null);
new ClassParser().parse(this, cmdLineParser);
new ClassParser().parse(galleryConfig, cmdLineParser);
new ClassParser().parse(syncConfiguration, cmdLineParser);
return cmdLineParser;
}

protected void createConfig(GalleryConfig parsedGalleryConfig) {
Config config = ConfigUtil.INSTANCE.getUserConfig();
protected void createConfiguration(SyncConfiguration parsedSyncConfiguration) {
UserConfiguration userConfiguration = ConfigurationUtil.INSTANCE.getUserConfiguration();

//if some gallery configuration was provided through parameters
if (!parsedGalleryConfig.isEmpty())
config.setCurrentGalleryConfig(parsedGalleryConfig);
if (!parsedSyncConfiguration.isEmpty())
userConfiguration.setCurrentSyncConfiguration(parsedSyncConfiguration);
}

protected void configureLog(boolean debug) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@
* Contributors:
* Matthieu Helleboid - initial API and implementation
******************************************************************************/
package org.piwigo.remotesync.api.client;
package org.piwigo.remotesync.api;

import org.piwigo.remotesync.api.exception.ClientServerException;
import org.piwigo.remotesync.api.request.AbstractRequest;
import org.piwigo.remotesync.api.request.ComposedRequest;
import org.piwigo.remotesync.api.response.BasicResponse;
import org.piwigo.remotesync.api.response.ComposedResponse;

public interface Client {
public interface IClient {
public <T extends BasicResponse> T sendRequest(AbstractRequest<T> request) throws ClientServerException;

public <T extends BasicResponse> ComposedResponse<T> sendRequest(ComposedRequest<T> composedRequest) throws ClientServerException;

public Client login(String username, String password) throws ClientServerException;
public IClient login() throws ClientServerException;

public Client logout() throws ClientServerException;
public IClient logout() throws ClientServerException;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*******************************************************************************
* Copyright (c) 2014 Matthieu Helleboid.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v2.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* Contributors:
* Matthieu Helleboid - initial API and implementation
******************************************************************************/
package org.piwigo.remotesync.api;

public interface IClientConfiguration {
public String getUrl();

public String getUsername();
public String getPassword();

public boolean getUsesProxy();
public String getProxyUrl();
public int getProxyPort();
public String getProxyUsername();
public String getProxyPassword();

public int getChunkSize();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*******************************************************************************
* Copyright (c) 2014 Matthieu Helleboid.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v2.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* Contributors:
* Matthieu Helleboid - initial API and implementation
******************************************************************************/
package org.piwigo.remotesync.api;

public interface ISyncConfiguration extends IClientConfiguration {
public String getDirectory();
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,5 @@ public class Tasks {
//TODO implement request text : connecting to / uploading file
//TODO implement pause/retry/save of composedrequest

//TODO provide API to create client from galleryconfig

//TODO test upload with community plugin
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*******************************************************************************
* Copyright (c) 2014 Matthieu Helleboid.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v2.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* Contributors:
* Matthieu Helleboid - initial API and implementation
******************************************************************************/
package org.piwigo.remotesync.api.cache;

public abstract class AbstractCacheElement implements ILegacyCacheElement {
protected String url;
protected Integer id;

public AbstractCacheElement() {
}

public AbstractCacheElement(String url, Integer id) {
this.url = url;
this.id = id;
}

public Integer getId() {
return id;
}

public String getUrl() {
return url;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*******************************************************************************
* Copyright (c) 2014 Matthieu Helleboid.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v2.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* Contributors:
* Matthieu Helleboid - initial API and implementation
******************************************************************************/
package org.piwigo.remotesync.api.cache;

public class AlbumCacheElement extends AbstractCacheElement {

public AlbumCacheElement() {
super();
}

public AlbumCacheElement(String url, Integer id) {
super(url, id);
}

@Override
public String writeToString() {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(url);
stringBuilder.append(" album_id = ");
stringBuilder.append(id);
return stringBuilder.toString();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*******************************************************************************
* Copyright (c) 2014 Matthieu Helleboid.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v2.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* Contributors:
* Matthieu Helleboid - initial API and implementation
******************************************************************************/
package org.piwigo.remotesync.api.cache;

public interface ILegacyCacheElement {

public String writeToString();

}
Loading

0 comments on commit 7dab5e0

Please sign in to comment.