1 /*******************************************************************************
2 * ============LICENSE_START========================================================================
3 * ONAP : ccsdk feature sdnr wt
4 * =================================================================================================
5 * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6 * =================================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software distributed under the License
13 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14 * or implied. See the License for the specific language governing permissions and limitations under
16 * ============LICENSE_END==========================================================================
17 ******************************************************************************/
18 package org.onap.ccsdk.features.sdnr.wt.common.file;
20 import java.io.ByteArrayOutputStream;
21 import java.io.IOException;
22 import java.io.InputStream;
23 import java.text.DateFormat;
24 import java.text.ParseException;
25 import java.text.SimpleDateFormat;
26 import java.util.Date;
27 import java.util.Locale;
31 * #Generated by org.apache.felix.bundleplugin
32 * #Tue Nov 19 10:17:57 CET 2019
33 * version=0.7.0-SNAPSHOT
34 * groupId=org.onap.ccsdk.features.sdnr.wt
35 * artifactId=sdnr-wt-data-provider-provider
39 public class PomPropertiesFile {
41 private Date buildDate;
42 private String version;
43 private String groupId;
44 private String artifactId;
46 public Date getBuildDate() {
47 return this.buildDate;
49 public String getVersion() {
52 public String getGroupId() {
55 public String getArtifactId() {
56 return this.artifactId;
58 private final DateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);
59 public PomPropertiesFile(InputStream is) throws IOException {
60 ByteArrayOutputStream bos = new ByteArrayOutputStream();
62 while ((intRead = is.read()) != -1) {
65 this.parse(new String(bos.toByteArray()));
68 private void parse(String s) {
69 String[] lines = s.split("\n");
70 for(String line:lines) {
72 if(line.startsWith("#Generated")) {
74 } else if( line.startsWith("groupId")) {
75 this.groupId = line.substring("groupId=".length());
77 else if(line.startsWith("artifactId")) {
78 this.artifactId = line.substring("artifactId=".length());
80 else if(line.startsWith("#")){
82 this.buildDate = sdf.parse(line.substring(1));
83 } catch (ParseException e) {
87 if(version!=null && this.buildDate!=null && this.groupId!=null && this.artifactId!=null) {