Project Cloud: replace project file doesn't do what it's supposed to

This commit is contained in:
bancika
2020-12-05 21:43:29 +01:00
parent ff02e779e1
commit 68dd3e08b4
7 changed files with 507 additions and 364 deletions
@@ -149,6 +149,23 @@ public interface IServiceAPI {
@ParamName("category") String category, @ParamName("description") String description,
@ParamName("diylcVersion") String diylcVersion, @ParamName("keywords") String keywords,
@ParamName("thumbnail") File thumbnail, @ParamName("project") File project,
@ParamName("projectId") Integer projectId);
/**
* Replaces project files using token to authenticate. The project must belong to the user.
*
* @param username
* @param token
* @param machineId
* @param diylcVersion
* @param thumbnail
* @param project
* @param projectId
* @return "Success" if the upload was successful or error message if it failed.
*/
String replaceProjectFiles(@ParamName("username") String username, @ParamName("token") String token,
@ParamName("machineId") String machineId, @ParamName("diylcVersion") String diylcVersion,
@ParamName("thumbnail") File thumbnail, @ParamName("project") File project,
@ParamName("projectId") Integer projectId);
/**
@@ -167,8 +167,12 @@ public class CloudPresenter {
if (username == null || token == null)
throw new CloudException("Login failed. Please try to login again.");
LOG.info("Uploading a new project: " + projectName);
if (projectId == null)
LOG.info("Uploading a new project: " + projectName);
else
LOG.info("Updating project: " + projectId);
try {
String res =
getService().uploadProject(username, token, getMachineId(), projectName, category, description, diylcVersion,
@@ -178,6 +182,24 @@ public class CloudPresenter {
} catch (Exception e) {
throw new CloudException(e);
}
}
public void replaceProjectFile(String diylcVersion, File thumbnail, File project, Integer projectId) throws IOException, CloudException {
String username = ConfigurationManager.getInstance().readString(USERNAME_KEY, null);
String token = ConfigurationManager.getInstance().readString(TOKEN_KEY, null);
if (username == null || token == null)
throw new CloudException("Login failed. Please try to login again.");
LOG.info("Replacing project files for: " + projectId);
try {
String res =
getService().replaceProjectFiles(username, token, getMachineId(), diylcVersion, thumbnail, project, projectId);
if (!res.equals(SUCCESS))
throw new CloudException(res);
} catch (Exception e) {
throw new CloudException(e);
}
}
public void updateProjectDetails(ProjectEntity project, String diylcVersion) throws IOException, CloudException {