forked from hyperledger-archives/composer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue 1639 - query validation (hyperledger-archives#1656)
* Validation for queries * Merged changes and added new exception
- Loading branch information
Showing
34 changed files
with
1,032 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -193,7 +193,6 @@ class ModelUtil { | |
return type; | ||
} | ||
} | ||
|
||
} | ||
|
||
module.exports = ModelUtil; |
67 changes: 67 additions & 0 deletions
67
packages/composer-common/lib/query/invalidqueryexception.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const BaseFileException = require('../basefileexception'); | ||
|
||
/** | ||
* Exception thrown for invalid queries | ||
* @extends BaseFileException | ||
* @see See [BaseFileException]{@link module:composer-common.BaseFileException} | ||
* @class | ||
* @memberof module:composer-common | ||
*/ | ||
class InvalidQueryException extends BaseFileException { | ||
|
||
/** | ||
* Create an InvalidQueryException. | ||
* @param {String} message - the message for the exception | ||
* @param {QueryFile} [queryFile] - the optional queryFile associated with the exception | ||
* @param {Object} [fileLocation] - location details of the error within the model file. | ||
* @param {String} fileLocation.start.line - start line of the error location. | ||
* @param {String} fileLocation.start.column - start column of the error location. | ||
* @param {String} fileLocation.end.line - end line of the error location. | ||
* @param {String} fileLocation.end.column - end column of the error location. | ||
*/ | ||
constructor(message, queryFile, fileLocation) { | ||
|
||
let messageSuffix = ''; | ||
if(queryFile && queryFile.getIdentifier()) { | ||
messageSuffix = 'File \'' + queryFile.getIdentifier() + '\': ' ; | ||
} | ||
|
||
if(fileLocation) { | ||
messageSuffix = messageSuffix + 'line ' + fileLocation.start.line + ' column ' + | ||
fileLocation.start.column + ', to line ' + fileLocation.end.line + ' column ' + | ||
fileLocation.end.column + '. '; | ||
} | ||
|
||
// First character to be uppercase | ||
messageSuffix = messageSuffix.charAt(0).toUpperCase() + messageSuffix.slice(1); | ||
|
||
super(message, fileLocation, message + ' ' + messageSuffix); | ||
this.queryFile = queryFile; | ||
} | ||
|
||
/** | ||
* Returns the query file associated with the exception or null | ||
* @return {QueryFile} the optional query file associated with the exception | ||
*/ | ||
getQueryFile() { | ||
return this.queryFile; | ||
} | ||
} | ||
|
||
module.exports = InvalidQueryException; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.