mdeuser commented on a change in pull request #3256: Refactor some bits of the 
triggers API.
URL: 
https://github.com/apache/incubator-openwhisk/pull/3256#discussion_r167068356
 
 

 ##########
 File path: core/controller/src/main/scala/whisk/core/controller/Triggers.scala
 ##########
 @@ -372,58 +356,36 @@ trait WhiskTriggersApi extends WhiskCollectionAPI {
     // Build the url to invoke an action mapped to the rule
     val actionUrl = baseControllerPath / rule.action.path.root.asString / 
"actions"
 
-    val actionPath = {
-      rule.action.path.relativePath.map { pkg =>
-        (Path.SingleSlash + pkg.namespace) / rule.action.name.asString
-      } getOrElse {
-        Path.SingleSlash + rule.action.name.asString
-      }
-    }.toString
+    val actionPath = rule.action.path.relativePath
+      .map(pkg => Path / pkg.namespace / rule.action.name.asString)
+      .getOrElse(Path / rule.action.name.asString)
 
     val request = HttpRequest(
       method = POST,
-      uri = url.withPath(actionUrl + actionPath),
+      uri = url.withPath(actionUrl ++ actionPath),
       headers = 
List(Authorization(BasicHttpCredentials(user.authkey.uuid.asString, 
user.authkey.key.asString))),
       entity = HttpEntity(MediaTypes.`application/json`, args.compactPrint))
 
     Http().singleRequest(request)
   }
 
-  /**
-   * Create JSON object containing the pertinent rule activation details.
-   * {
-   *   "rule": "my-rule",
-   *   "action": "my-action",
-   *   "statusCode": 0,
-   *   "status": "success",
-   *   "activationId": "...",                              // either this 
field, ...
-   *   "error": "The requested resource does not exist."   // ... or this 
field will be present
-   * }
-   *
-   * @param statusCode one of ActivationResponse values
-   * @param ruleName the name of the rule that was activated
-   * @param actionName the name of the action activated by the rule
-   * @param actionActivationId the activation id, if there is one
-   * @param errorMsg the rror messages otherwise
-   * @return JsObject as formatted above
-   */
-  private def ruleResult(statusCode: Int,
-                         ruleName: FullyQualifiedEntityName,
-                         actionName: FullyQualifiedEntityName,
-                         actionActivationId: Option[JsValue] = None,
-                         errorMsg: Option[String] = None): JsObject = {
-    JsObject(
-      Map(
-        "rule" -> JsString(ruleName.asString),
-        "action" -> JsString(actionName.asString),
-        "statusCode" -> JsNumber(statusCode),
-        "success" -> JsBoolean(statusCode == ActivationResponse.Success)) ++
-        actionActivationId.map("activationId" -> _.toJson) ++
-        errorMsg.map("error" -> JsString(_)))
+  /** Contains the result of invoking a rule */
+  case class RuleActivationResult(statusCode: Int,
+                                  ruleName: FullyQualifiedEntityName,
+                                  actionName: FullyQualifiedEntityName,
+                                  response: Either[String, ActivationId]) {
 
 Review comment:
   today these values are mutually exclusive, but perhaps it may be possible 
for a trigger response to include the activation id as well as an error 
message..?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to