Repository: nifi
Updated Branches:
  refs/heads/master d223423de -> 04147ac22


NIFI-2458: - Fixing issue with timezone when the initial provenance result was 
cancelled.

This closes #773.

Signed-off-by: Bryan Bende <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/04147ac2
Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/04147ac2
Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/04147ac2

Branch: refs/heads/master
Commit: 04147ac22a8384ec8989100ec4954af4374ceaa9
Parents: d223423
Author: Matt Gilman <[email protected]>
Authored: Tue Aug 2 11:26:05 2016 -0400
Committer: Bryan Bende <[email protected]>
Committed: Thu Aug 4 17:09:21 2016 -0400

----------------------------------------------------------------------
 .../org/apache/nifi/web/api/dto/AboutDTO.java   | 20 +++++++++
 .../nifi/web/api/dto/util/TimezoneAdapter.java  | 46 ++++++++++++++++++++
 .../org/apache/nifi/web/api/FlowResource.java   |  1 +
 .../js/nf/provenance/nf-provenance-table.js     |  3 --
 .../webapp/js/nf/provenance/nf-provenance.js    |  3 ++
 5 files changed, 70 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi/blob/04147ac2/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/AboutDTO.java
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/AboutDTO.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/AboutDTO.java
index fca8d96..72840d0 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/AboutDTO.java
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/AboutDTO.java
@@ -17,8 +17,11 @@
 package org.apache.nifi.web.api.dto;
 
 import com.wordnik.swagger.annotations.ApiModelProperty;
+import org.apache.nifi.web.api.dto.util.TimezoneAdapter;
 
 import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import java.util.Date;
 
 /**
  * Contains details about this NiFi including the title and version.
@@ -31,6 +34,7 @@ public class AboutDTO {
 
     private String uri;
     private String contentViewerUrl;
+    private Date timezone;
 
     /* getters / setters */
     /**
@@ -92,4 +96,20 @@ public class AboutDTO {
     public void setContentViewerUrl(String contentViewerUrl) {
         this.contentViewerUrl = contentViewerUrl;
     }
+
+    /**
+     * @return the timezone of the NiFi instance
+     */
+    @XmlJavaTypeAdapter(TimezoneAdapter.class)
+    @ApiModelProperty(
+            value = "The timezone of the NiFi instance.",
+            readOnly = true
+    )
+    public Date getTimezone() {
+        return timezone;
+    }
+
+    public void setTimezone(Date timezone) {
+        this.timezone = timezone;
+    }
 }

http://git-wip-us.apache.org/repos/asf/nifi/blob/04147ac2/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/util/TimezoneAdapter.java
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/util/TimezoneAdapter.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/util/TimezoneAdapter.java
new file mode 100644
index 0000000..391da89
--- /dev/null
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/util/TimezoneAdapter.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.nifi.web.api.dto.util;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+import java.util.TimeZone;
+
+/**
+ * XmlAdapter for (un)marshalling a date/time.
+ */
+public class TimezoneAdapter extends XmlAdapter<String, Date> {
+
+    public static final String DEFAULT_DATE_TIME_FORMAT = "z";
+
+    @Override
+    public String marshal(Date date) throws Exception {
+        final SimpleDateFormat formatter = new 
SimpleDateFormat(DEFAULT_DATE_TIME_FORMAT, Locale.US);
+        formatter.setTimeZone(TimeZone.getDefault());
+        return formatter.format(date);
+    }
+
+    @Override
+    public Date unmarshal(String date) throws Exception {
+        final SimpleDateFormat parser = new 
SimpleDateFormat(DEFAULT_DATE_TIME_FORMAT, Locale.US);
+        parser.setTimeZone(TimeZone.getDefault());
+        return parser.parse(date);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/nifi/blob/04147ac2/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FlowResource.java
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FlowResource.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FlowResource.java
index 6cb29d0..e48bdc3 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FlowResource.java
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FlowResource.java
@@ -1075,6 +1075,7 @@ public class FlowResource extends ApplicationResource {
         aboutDTO.setTitle("NiFi");
         aboutDTO.setVersion(getProperties().getUiTitle());
         aboutDTO.setUri(generateResourceUri());
+        aboutDTO.setTimezone(new Date());
 
         // get the content viewer url
         
aboutDTO.setContentViewerUrl(getProperties().getProperty(NiFiProperties.CONTENT_VIEWER_URL));

http://git-wip-us.apache.org/repos/asf/nifi/blob/04147ac2/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/provenance/nf-provenance-table.js
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/provenance/nf-provenance-table.js
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/provenance/nf-provenance-table.js
index c0bdb96..2eb6e02 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/provenance/nf-provenance-table.js
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/provenance/nf-provenance-table.js
@@ -960,9 +960,6 @@ nf.ng.ProvenanceTable = function (provenanceLineageCtrl) {
             // update the oldest event available
             
$('#oldest-event').html(nf.Common.formatValue(provenanceResults.oldestEvent));
 
-            // set the timezone for the start and end time
-            
$('.timezone').text(nf.Common.substringAfterLast(provenanceResults.generated, ' 
'));
-
             // record the server offset
             provenanceTableCtrl.serverTimeOffset = 
provenanceResults.timeOffset;
 

http://git-wip-us.apache.org/repos/asf/nifi/blob/04147ac2/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/provenance/nf-provenance.js
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/provenance/nf-provenance.js
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/provenance/nf-provenance.js
index 0c69173..9a7d383 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/provenance/nf-provenance.js
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/provenance/nf-provenance.js
@@ -94,6 +94,9 @@ nf.ng.Provenance = function (provenanceTableCtrl) {
             // store the controller name
             $('#nifi-controller-uri').text(aboutDetails.uri);
 
+            // set the timezone for the start and end time
+            $('.timezone').text(aboutDetails.timezone);
+
             // store the content viewer url if available
             if (!nf.Common.isBlank(aboutDetails.contentViewerUrl)) {
                 
$('#nifi-content-viewer-url').text(aboutDetails.contentViewerUrl);

Reply via email to