Remove all references to org.json in gdata extension
This commit is contained in:
parent
916ede440b
commit
1df2d15e6d
@ -11,13 +11,11 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||||
import org.json.JSONArray;
|
|
||||||
import org.json.JSONException;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonGenerator;
|
import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
|
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||||
import com.google.api.services.drive.Drive;
|
import com.google.api.services.drive.Drive;
|
||||||
import com.google.api.services.drive.model.File;
|
import com.google.api.services.drive.model.File;
|
||||||
@ -100,7 +98,7 @@ public class GDataImportingController implements ImportingController {
|
|||||||
writer.writeEndArray();
|
writer.writeEndArray();
|
||||||
writer.writeEndObject();
|
writer.writeEndObject();
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (IOException e) {
|
||||||
throw new ServletException(e);
|
throw new ServletException(e);
|
||||||
} finally {
|
} finally {
|
||||||
writer.flush();
|
writer.flush();
|
||||||
@ -111,7 +109,7 @@ public class GDataImportingController implements ImportingController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void listSpreadsheets(Drive drive, JsonGenerator writer)
|
private void listSpreadsheets(Drive drive, JsonGenerator writer)
|
||||||
throws IOException, JSONException {
|
throws IOException {
|
||||||
com.google.api.services.drive.Drive.Files.List files = drive.files().list();
|
com.google.api.services.drive.Drive.Files.List files = drive.files().list();
|
||||||
files.setQ("mimeType = 'application/vnd.google-apps.spreadsheet'");
|
files.setQ("mimeType = 'application/vnd.google-apps.spreadsheet'");
|
||||||
files.setFields("nextPageToken, files(id, name, webViewLink, owners, modifiedTime)");
|
files.setFields("nextPageToken, files(id, name, webViewLink, owners, modifiedTime)");
|
||||||
@ -142,7 +140,7 @@ public class GDataImportingController implements ImportingController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void listFusionTables(Fusiontables service, JsonGenerator writer)
|
private void listFusionTables(Fusiontables service, JsonGenerator writer)
|
||||||
throws IOException, JSONException {
|
throws IOException {
|
||||||
|
|
||||||
Fusiontables.Table.List listTables = service.table().list();
|
Fusiontables.Table.List listTables = service.table().list();
|
||||||
TableList tablelist = listTables.execute();
|
TableList tablelist = listTables.execute();
|
||||||
@ -172,8 +170,8 @@ public class GDataImportingController implements ImportingController {
|
|||||||
String token = TokenCookie.getToken(request);
|
String token = TokenCookie.getToken(request);
|
||||||
String type = parameters.getProperty("docType");
|
String type = parameters.getProperty("docType");
|
||||||
String urlString = parameters.getProperty("docUrl");
|
String urlString = parameters.getProperty("docUrl");
|
||||||
JSONObject result = new JSONObject();
|
ObjectNode result = ParsingUtilities.mapper.createObjectNode();
|
||||||
JSONObject options = new JSONObject();
|
ObjectNode options = ParsingUtilities.mapper.createObjectNode();
|
||||||
|
|
||||||
JSONUtilities.safePut(result, "status", "ok");
|
JSONUtilities.safePut(result, "status", "ok");
|
||||||
JSONUtilities.safePut(result, "options", options);
|
JSONUtilities.safePut(result, "options", options);
|
||||||
@ -182,7 +180,7 @@ public class GDataImportingController implements ImportingController {
|
|||||||
JSONUtilities.safePut(options, "storeBlankCellsAsNulls", true);
|
JSONUtilities.safePut(options, "storeBlankCellsAsNulls", true);
|
||||||
|
|
||||||
if ("spreadsheet".equals(type)) {
|
if ("spreadsheet".equals(type)) {
|
||||||
JSONArray worksheets = new JSONArray();
|
ArrayNode worksheets = ParsingUtilities.mapper.createArrayNode();
|
||||||
// extract spreadSheetId from URL
|
// extract spreadSheetId from URL
|
||||||
String spreadSheetId = GoogleAPIExtension.extractSpreadSheetId(urlString);
|
String spreadSheetId = GoogleAPIExtension.extractSpreadSheetId(urlString);
|
||||||
|
|
||||||
@ -193,7 +191,7 @@ public class GDataImportingController implements ImportingController {
|
|||||||
List<Sheet> worksheetEntries =
|
List<Sheet> worksheetEntries =
|
||||||
getWorksheetEntriesForDoc(token, spreadSheetId);
|
getWorksheetEntriesForDoc(token, spreadSheetId);
|
||||||
for (Sheet sheet : worksheetEntries) {
|
for (Sheet sheet : worksheetEntries) {
|
||||||
JSONObject worksheetO = new JSONObject();
|
ObjectNode worksheetO = ParsingUtilities.mapper.createObjectNode();
|
||||||
JSONUtilities.safePut(worksheetO, "name", sheet.getProperties().getTitle());
|
JSONUtilities.safePut(worksheetO, "name", sheet.getProperties().getTitle());
|
||||||
JSONUtilities.safePut(worksheetO, "rows", sheet.getProperties().getGridProperties().getRowCount());
|
JSONUtilities.safePut(worksheetO, "rows", sheet.getProperties().getGridProperties().getRowCount());
|
||||||
JSONUtilities.safePut(worksheetO, "link",
|
JSONUtilities.safePut(worksheetO, "link",
|
||||||
@ -235,7 +233,6 @@ public class GDataImportingController implements ImportingController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
job.updating = true;
|
job.updating = true;
|
||||||
try {
|
|
||||||
ObjectNode optionObj = ParsingUtilities.evaluateJsonStringToObjectNode(
|
ObjectNode optionObj = ParsingUtilities.evaluateJsonStringToObjectNode(
|
||||||
request.getParameter("options"));
|
request.getParameter("options"));
|
||||||
|
|
||||||
@ -278,13 +275,9 @@ public class GDataImportingController implements ImportingController {
|
|||||||
w.close();
|
w.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (JSONException e) {
|
|
||||||
throw new ServletException(e);
|
|
||||||
} finally {
|
|
||||||
job.touch();
|
job.touch();
|
||||||
job.updating = false;
|
job.updating = false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void doCreateProject(HttpServletRequest request, HttpServletResponse response, Properties parameters)
|
private void doCreateProject(HttpServletRequest request, HttpServletResponse response, Properties parameters)
|
||||||
throws ServletException, IOException {
|
throws ServletException, IOException {
|
||||||
@ -299,7 +292,6 @@ public class GDataImportingController implements ImportingController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
job.updating = true;
|
job.updating = true;
|
||||||
try {
|
|
||||||
final ObjectNode optionObj = ParsingUtilities.evaluateJsonStringToObjectNode(
|
final ObjectNode optionObj = ParsingUtilities.evaluateJsonStringToObjectNode(
|
||||||
request.getParameter("options"));
|
request.getParameter("options"));
|
||||||
|
|
||||||
@ -348,8 +340,5 @@ public class GDataImportingController implements ImportingController {
|
|||||||
}.start();
|
}.start();
|
||||||
|
|
||||||
HttpUtilities.respond(response, "ok", "done");
|
HttpUtilities.respond(response, "ok", "done");
|
||||||
} catch (JSONException e) {
|
|
||||||
throw new ServletException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user