mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
manage cloud uploads
This commit is contained in:
@@ -5,7 +5,6 @@ import javax.swing.Icon;
|
||||
import org.diylc.core.CreationMethod;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.annotations.BomPolicy;
|
||||
import org.diylc.core.annotations.IAutoCreator;
|
||||
import org.diylc.core.annotations.KeywordPolicy;
|
||||
|
||||
/**
|
||||
|
||||
@@ -50,6 +50,8 @@ public class Resistance extends AbstractMeasure<ResistanceUnit> {
|
||||
bands = new Color[] {};
|
||||
}
|
||||
} else {
|
||||
if (getValue() == null || getUnit() == null)
|
||||
return new Color[] {};
|
||||
double base = getValue() * getUnit().getFactor();
|
||||
int multiplier = 0;
|
||||
while (base > (resistorColorCode == ResistorColorCode._4_BAND ? 99 : 999)) {
|
||||
|
||||
@@ -98,12 +98,13 @@ public interface IServiceAPI {
|
||||
* @param itemsPerPage
|
||||
* @param sort
|
||||
* @param username
|
||||
* @param projectId optional parameter used when we want to fetch a particular project
|
||||
* @return string with error message if the error occurred or a list of {@link ProjectEntity}
|
||||
* objects.
|
||||
*/
|
||||
Object search(@ParamName("criteria") String criteria, @ParamName("category") String category,
|
||||
@ParamName("page") Integer page, @ParamName("itemsPerPage") Integer itemsPerPage, @ParamName("sort") String sort,
|
||||
@ParamName("username") String username);
|
||||
@ParamName("username") String username, @ParamName("projectId") Integer projectId);
|
||||
|
||||
/**
|
||||
* Uploads a project using token to authenticate. When projectI is specified, it updates the
|
||||
|
||||
@@ -135,7 +135,7 @@ public class CloudPresenter {
|
||||
}
|
||||
|
||||
public void uploadProject(String projectName, String category, String description, String keywords,
|
||||
String diylcVersion, File thumbnail, File project) throws IOException, CloudException {
|
||||
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);
|
||||
|
||||
@@ -145,7 +145,23 @@ public class CloudPresenter {
|
||||
try {
|
||||
String res =
|
||||
getService().uploadProject(username, token, getMachineId(), projectName, category, description, diylcVersion,
|
||||
keywords, thumbnail, project, null);
|
||||
keywords, thumbnail, project, projectId);
|
||||
if (!res.equals(SUCCESS))
|
||||
throw new CloudException(res);
|
||||
} catch (Exception e) {
|
||||
throw new CloudException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteProject(int projectId) throws 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.");
|
||||
|
||||
try {
|
||||
String res = getService().deleteProject(username, token, getMachineId(), projectId);
|
||||
if (!res.equals(SUCCESS))
|
||||
throw new CloudException(res);
|
||||
} catch (Exception e) {
|
||||
@@ -234,7 +250,7 @@ public class CloudPresenter {
|
||||
throws CloudException {
|
||||
LOG.info(String.format("search(%1$s,%2$s,%3$s,%4$d,%5$d)", criteria, category, sortOrder, pageNumber, itemsPerPage));
|
||||
try {
|
||||
Object res = getService().search(criteria, category, pageNumber, itemsPerPage, sortOrder, null);
|
||||
Object res = getService().search(criteria, category, pageNumber, itemsPerPage, sortOrder, null, null);
|
||||
return processResults(res);
|
||||
} catch (CloudException ce) {
|
||||
throw ce;
|
||||
@@ -243,10 +259,10 @@ public class CloudPresenter {
|
||||
}
|
||||
}
|
||||
|
||||
public List<ProjectEntity> fetchUserUploads() throws CloudException {
|
||||
public List<ProjectEntity> fetchUserUploads(Integer projectId) throws CloudException {
|
||||
UserEntity user = getUserDetails();
|
||||
try {
|
||||
Object res = getService().search("", "", 1, Integer.MAX_VALUE, getSortings()[0], user.getUsername());
|
||||
Object res = getService().search("", "", 1, Integer.MAX_VALUE, getSortings()[0], user.getUsername(), projectId);
|
||||
return processResults(res);
|
||||
} catch (CloudException ce) {
|
||||
throw ce;
|
||||
|
||||
Reference in New Issue
Block a user