Skip to content

Commit

Permalink
Modified error text, added comments for regex (#4103)
Browse files Browse the repository at this point in the history
  • Loading branch information
nidhi-nair authored Apr 22, 2021
1 parent 9dff696 commit 2eec2fb
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public AppendMethod(ObjectMapper objectMapper) {
@Override
public boolean validateMethodRequest(MethodConfig methodConfig) {
if (methodConfig.getSpreadsheetId() == null || methodConfig.getSpreadsheetId().isBlank()) {
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Spreadsheet Id");
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Spreadsheet Url");
}
if (methodConfig.getSheetName() == null || methodConfig.getSheetName().isBlank()) {
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Sheet name");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public BulkAppendMethod(ObjectMapper objectMapper) {
@Override
public boolean validateMethodRequest(MethodConfig methodConfig) {
if (methodConfig.getSpreadsheetId() == null || methodConfig.getSpreadsheetId().isBlank()) {
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Spreadsheet Id");
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Spreadsheet Url");
}
if (methodConfig.getSheetName() == null || methodConfig.getSheetName().isBlank()) {
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Sheet name");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public BulkUpdateMethod(ObjectMapper objectMapper) {
@Override
public boolean validateMethodRequest(MethodConfig methodConfig) {
if (methodConfig.getSpreadsheetId() == null || methodConfig.getSpreadsheetId().isBlank()) {
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Spreadsheet Id");
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Spreadsheet Url");
}
if (methodConfig.getSheetName() == null || methodConfig.getSheetName().isBlank()) {
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Sheet name");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public ClearMethod(ObjectMapper objectMapper) {
@Override
public boolean validateMethodRequest(MethodConfig methodConfig) {
if (methodConfig.getSpreadsheetId() == null || methodConfig.getSpreadsheetId().isBlank()) {
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Spreadsheet Id");
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Spreadsheet Url");
}
if (methodConfig.getSpreadsheetRange() == null || methodConfig.getSpreadsheetRange().isBlank()) {
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Data Range");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public CopyMethod(ObjectMapper objectMapper) {
@Override
public boolean validateMethodRequest(MethodConfig methodConfig) {
if (methodConfig.getSpreadsheetId() == null || methodConfig.getSpreadsheetId().isBlank()) {
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Spreadsheet Id");
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Spreadsheet Url");
}
if (methodConfig.getSheetId() == null || methodConfig.getSheetId().isBlank()) {
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Sheet Id");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public DeleteRowMethod(ObjectMapper objectMapper) {
@Override
public boolean validateMethodRequest(MethodConfig methodConfig) {
if (methodConfig.getSpreadsheetId() == null || methodConfig.getSpreadsheetId().isBlank()) {
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Spreadsheet Id");
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Spreadsheet Url");
}
if (methodConfig.getSheetName() == null || methodConfig.getSheetName().isBlank()) {
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Sheet name");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public DeleteSheetMethod(ObjectMapper objectMapper) {
@Override
public boolean validateMethodRequest(MethodConfig methodConfig) {
if (methodConfig.getSpreadsheetId() == null || methodConfig.getSpreadsheetId().isBlank()) {
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Spreadsheet Id");
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Spreadsheet Url");
}
if (GoogleSheets.SHEET.equalsIgnoreCase(methodConfig.getDeleteFormat())) {
if (methodConfig.getSheetName() == null || methodConfig.getSheetName().isBlank()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,21 @@ public GetValuesMethod(ObjectMapper objectMapper) {
this.objectMapper = objectMapper;
}

// Used to capture the range of columns in this request. The handling for this regex makes sure that
// all possible combinations of A1 notation for a range map to a common format
Pattern findAllRowsPattern = Pattern.compile("([a-zA-Z]*)\\d*:([a-zA-Z]*)\\d*");

// The starting row for a range is captured using this pattern to find its relative index from table heading
Pattern findOffsetRowPattern = Pattern.compile("(\\d+):");

// Since the value for this pattern is coming from an API response, it also contains the sheet name
// We use this pattern to retrieve only range information
Pattern sheetRangePattern = Pattern.compile(".*!([a-zA-Z]*)\\d*:([a-zA-Z]*)\\d*");

@Override
public boolean validateMethodRequest(MethodConfig methodConfig) {
if (methodConfig.getSpreadsheetId() == null || methodConfig.getSpreadsheetId().isBlank()) {
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Spreadsheet Id");
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Spreadsheet Url");
}
if (methodConfig.getSheetName() == null || methodConfig.getSheetName().isBlank()) {
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Sheet name");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public InfoMethod(ObjectMapper objectMapper) {
@Override
public boolean validateMethodRequest(MethodConfig methodConfig) {
if (methodConfig.getSpreadsheetId() == null || methodConfig.getSpreadsheetId().isBlank()) {
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Spreadsheet Id");
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Spreadsheet Url");
}

return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public UpdateMethod(ObjectMapper objectMapper) {
@Override
public boolean validateMethodRequest(MethodConfig methodConfig) {
if (methodConfig.getSpreadsheetId() == null || methodConfig.getSpreadsheetId().isBlank()) {
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Spreadsheet Id");
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Spreadsheet Url");
}
if (methodConfig.getSheetName() == null || methodConfig.getSheetName().isBlank()) {
throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required field Sheet name");
Expand Down

0 comments on commit 2eec2fb

Please sign in to comment.