mirror of https://github.com/apache/nifi.git
NIFI-2458: - Fixing issue with timezone when the initial provenance result was cancelled.
This closes #773. Signed-off-by: Bryan Bende <bbende@apache.org>
This commit is contained in:
parent
d223423de9
commit
04147ac22a
|
@ -17,8 +17,11 @@
|
||||||
package org.apache.nifi.web.api.dto;
|
package org.apache.nifi.web.api.dto;
|
||||||
|
|
||||||
import com.wordnik.swagger.annotations.ApiModelProperty;
|
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.XmlType;
|
||||||
|
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains details about this NiFi including the title and version.
|
* Contains details about this NiFi including the title and version.
|
||||||
|
@ -31,6 +34,7 @@ public class AboutDTO {
|
||||||
|
|
||||||
private String uri;
|
private String uri;
|
||||||
private String contentViewerUrl;
|
private String contentViewerUrl;
|
||||||
|
private Date timezone;
|
||||||
|
|
||||||
/* getters / setters */
|
/* getters / setters */
|
||||||
/**
|
/**
|
||||||
|
@ -92,4 +96,20 @@ public class AboutDTO {
|
||||||
public void setContentViewerUrl(String contentViewerUrl) {
|
public void setContentViewerUrl(String contentViewerUrl) {
|
||||||
this.contentViewerUrl = 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1075,6 +1075,7 @@ public class FlowResource extends ApplicationResource {
|
||||||
aboutDTO.setTitle("NiFi");
|
aboutDTO.setTitle("NiFi");
|
||||||
aboutDTO.setVersion(getProperties().getUiTitle());
|
aboutDTO.setVersion(getProperties().getUiTitle());
|
||||||
aboutDTO.setUri(generateResourceUri());
|
aboutDTO.setUri(generateResourceUri());
|
||||||
|
aboutDTO.setTimezone(new Date());
|
||||||
|
|
||||||
// get the content viewer url
|
// get the content viewer url
|
||||||
aboutDTO.setContentViewerUrl(getProperties().getProperty(NiFiProperties.CONTENT_VIEWER_URL));
|
aboutDTO.setContentViewerUrl(getProperties().getProperty(NiFiProperties.CONTENT_VIEWER_URL));
|
||||||
|
|
|
@ -960,9 +960,6 @@ nf.ng.ProvenanceTable = function (provenanceLineageCtrl) {
|
||||||
// update the oldest event available
|
// update the oldest event available
|
||||||
$('#oldest-event').html(nf.Common.formatValue(provenanceResults.oldestEvent));
|
$('#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
|
// record the server offset
|
||||||
provenanceTableCtrl.serverTimeOffset = provenanceResults.timeOffset;
|
provenanceTableCtrl.serverTimeOffset = provenanceResults.timeOffset;
|
||||||
|
|
||||||
|
|
|
@ -94,6 +94,9 @@ nf.ng.Provenance = function (provenanceTableCtrl) {
|
||||||
// store the controller name
|
// store the controller name
|
||||||
$('#nifi-controller-uri').text(aboutDetails.uri);
|
$('#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
|
// store the content viewer url if available
|
||||||
if (!nf.Common.isBlank(aboutDetails.contentViewerUrl)) {
|
if (!nf.Common.isBlank(aboutDetails.contentViewerUrl)) {
|
||||||
$('#nifi-content-viewer-url').text(aboutDetails.contentViewerUrl);
|
$('#nifi-content-viewer-url').text(aboutDetails.contentViewerUrl);
|
||||||
|
|
Loading…
Reference in New Issue