Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: dashboard updates #843

Merged
merged 63 commits into from
Aug 20, 2020
Merged
Changes from 1 commit
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
945f7d1
Update ci.yaml
salehsquared Jul 24, 2020
d80399b
Check version of google-cloud-shared-config
salehsquared Jul 24, 2020
afc4204
Update pom.xml
salehsquared Jul 24, 2020
98282ff
Update ci.yaml
salehsquared Jul 24, 2020
1861d3b
Update pom.xml
salehsquared Jul 24, 2020
438e5fa
Update ci.yaml
salehsquared Jul 24, 2020
02e35fb
Update ci.yaml
salehsquared Jul 24, 2020
77be68a
Updating permissions on versions script
Jul 24, 2020
ed61410
deps: update dependency com.google.cloud:google-cloud-logging-logback…
salehsquared Jul 24, 2020
9f1fb9a
deps: update dependency com.google.cloud:google-cloud-firestore-bom t…
salehsquared Jul 24, 2020
e224876
Reverting pom.xml after testing changes
Jul 24, 2020
0edb0e5
Merge branch 'master' of https://github.com/salehsquared/java-cloud-bom
Jul 24, 2020
ed33def
Reverting POM version
Jul 24, 2020
b1fe397
Reverting POM version
Jul 24, 2020
14c43ec
Fixing formatting change on ci file
Jul 24, 2020
1150208
Fixing formatting change on ci file
Jul 24, 2020
2616081
Fix for formatting end of file
Jul 24, 2020
b164f1a
Updated dependencies scripts. Separated out, so one script checks for…
Jul 29, 2020
1ad1ae1
Setting ci.yaml file back to original
Jul 29, 2020
807140c
Merge branch 'dependency-versions' of https://github.com/salehsquared…
Jul 30, 2020
9ad1268
Updates to make deps-finder more stable, including using regex. Also …
Jul 30, 2020
8affd08
Updated deps-finder according to comments from Stephanie, Elliotte, a…
Jul 30, 2020
ebbdf93
Updating pom.xml to master branch
Jul 30, 2020
8310661
Merge branch 'master' into dependency-versions
salehsquared Jul 30, 2020
7d745a5
Formatting and curl fixes
Jul 30, 2020
0c7f9b6
Merge branch 'dependency-versions' of https://github.com/salehsquared…
Jul 30, 2020
9d30f20
Merge branch 'master' of https://github.com/googleapis/java-cloud-bom…
Jul 31, 2020
741029e
Separate script for helper functions, conventionalized syntax, verbos…
Jul 31, 2020
39a4c5e
Updated release-versions to match conventions & be more stable readin…
Aug 2, 2020
102c971
Updated search functionality. Cleaned code. Include search by java-cl…
Aug 5, 2020
50635b0
Reformatted comments and added licensing
Aug 5, 2020
65869fc
Major searchbar updates. Updating styling of all-versions page.
Aug 7, 2020
ade2299
Sort functionality added. Added ability to see static version for eac…
Aug 10, 2020
67c73b8
Merge branch 'dashboard-updates' of https://github.com/salehsquared/j…
Aug 10, 2020
376effa
Small sorting fix.
Aug 10, 2020
9378e2f
Smaller changes - styling and code principles
Aug 10, 2020
bfcf0e0
Updated README. Major styling changes for dashboard table
Aug 11, 2020
308ad64
Modified sorting algorithm.
Aug 11, 2020
46559ab
Sorting/arrow algorithm now instant. Minor styling changes.
Aug 11, 2020
b565d67
Fixed searchbar. Added comments. Improved searching.
Aug 11, 2020
0b5b463
Removing dependencies scripts
Aug 11, 2020
d46a286
Removing unnecessary file
Aug 11, 2020
66845f0
Removed bigtable-emulator. Added stylistic changes. Fixed library rem…
Aug 12, 2020
e6b4eaf
Code styling changes
Aug 12, 2020
496ee4e
Style
Aug 12, 2020
fc45f18
Fixed spacing and variable names according to Google standard
Aug 13, 2020
2b75609
Temporarily removing XOM
Aug 14, 2020
0f7201a
Merging with master branch
Aug 14, 2020
60c5fc2
Merge branch 'master' into dashboard-updates
salehsquared Aug 14, 2020
bf9abbf
Added XOM used as an XML parser. Cleaned & reformatted code for grabb…
Aug 14, 2020
70818f5
Merge branch 'dashboard-updates' of https://github.com/salehsquared/j…
Aug 14, 2020
d8bf592
Stylistic changes. Google style sheet
Aug 14, 2020
a81fd58
Fixed VersionData design. Using input stream, and fixed according to …
Aug 14, 2020
bc8271c
Merge branch 'master' into dashboard-updates
salehsquared Aug 14, 2020
00be766
Stylistic and efficiency changes
Aug 15, 2020
dbc8243
Separated out all versions page from regular version data
Aug 15, 2020
39be2a3
Merge branch 'dashboard-updates' of https://github.com/salehsquared/j…
Aug 15, 2020
455a2e6
Removed XML parser, as it's unnecessary.
Aug 15, 2020
a5f2a40
Fixed dashboard design issues
Aug 16, 2020
ea62059
Merge branch 'master' of https://github.com/googleapis/java-cloud-bom…
Aug 17, 2020
07fdaca
Centered table and search bar & change by window size. Additional sea…
Aug 19, 2020
a160e8b
Placed searchbar back outside of table
Aug 19, 2020
2e38251
Update dashboard/src/main/resources/templates/index.ftl
salehsquared Aug 20, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed dashboard design issues
  • Loading branch information
Saleh Mostafa committed Aug 16, 2020
commit a5f2a406c1e3482f18ed841d47f0e09ee002f60e

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
/*
* Copyright 2020 Google LLC.
*
* 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.
*/

package com.google.cloud.tools.opensource.cloudbomdashboard;

import org.apache.maven.artifact.repository.metadata.Metadata;
import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.apache.commons.io.FileUtils;
import org.eclipse.aether.artifact.Artifact;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.BufferedInputStream;
import java.net.URL;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
* Container class for all artifact data pulled from Maven central.
*/
public class ArtifactMavenData {

private static DateFormat dateFormat = new SimpleDateFormat("yyyyMMddhhmmss");
private static DateFormat outputFormat = new SimpleDateFormat("MM-dd-yyyy");

private final Artifact artifact;

private final String latestVersion, lastUpdated,
sharedDependenciesVersion, sharedDependenciesPosition,
pomFileUrl, metadataUrl;

private ArtifactMavenData(Artifact artifact, String latestVersion,
String lastUpdated, String sharedDependenciesVersion,
String sharedDependenciesPosition,
String pomFileUrl, String metadataUrl) {
this.artifact = artifact;
this.latestVersion = latestVersion;
this.lastUpdated = lastUpdated;
this.sharedDependenciesVersion = sharedDependenciesVersion;
this.sharedDependenciesPosition = sharedDependenciesPosition;

this.pomFileUrl = pomFileUrl;
this.metadataUrl = metadataUrl;
}

public Artifact getArtifact() {
return artifact;
}

public String getSharedDependenciesPosition() {
return sharedDependenciesPosition;
}

public String getPomFileUrl() {
return pomFileUrl;
}

public String getMetadataUrl() {
return metadataUrl;
}

public String getLatestVersion() {
return latestVersion;
}

public String getLastUpdated() {
return lastUpdated;
}

public String getSharedDependenciesVersion() {
return sharedDependenciesVersion;
}

public static ArtifactMavenData generateArtifactMavenData(Artifact artifact) {
String metadataUrl = generateMetadataUrl(artifact);
String pomFileUrl = generatePomFileUrl(artifact);

LatestMetadata metadata = getLatestVersionAndLastUpdated(metadataUrl);

String latestVersion = metadata.latestVersion;
String lastUpdated = metadata.lastUpdated;

SharedDependenciesData data = sharedDependencyPositionAndVersion(pomFileUrl, artifact);

String sharedDependenciesPosition = data.sharedDependencyPosition;
String sharedDependenciesVersion = data.sharedDependencyVersion;

return new ArtifactMavenData(artifact, latestVersion, lastUpdated,
sharedDependenciesVersion, sharedDependenciesPosition,
metadataUrl, pomFileUrl);
}

private static LatestMetadata getLatestVersionAndLastUpdated(String metadataUrl) {
try {
File metadataFile = File.createTempFile("metadata", ".xml");
metadataFile.deleteOnExit();

URL url = new URL(metadataUrl);
FileUtils.copyURLToFile(url, metadataFile);

MetadataXpp3Reader reader = new MetadataXpp3Reader();
Metadata metadata = reader.read(new FileInputStream(metadataFile));

if (metadata.getVersioning() == null) {
return new LatestMetadata("", "");
}

String latestVersion;
if (metadata.getVersioning().getLatest() == null) {
latestVersion = "";
} else {
latestVersion = metadata.getVersioning().getLatest();
}

String lastUpdated = metadata.getVersioning().getLastUpdated();
if (lastUpdated != null && !lastUpdated.isEmpty()) {
Date date = dateFormat.parse(lastUpdated);
lastUpdated = outputFormat.format(date);
} else {
lastUpdated = "";
}
return new LatestMetadata(latestVersion, lastUpdated);
} catch (XmlPullParserException | ParseException | IOException ignored) {
return new LatestMetadata("", "");
}
}

private static SharedDependenciesData sharedDependencyPositionAndVersion(String pomUrl,
Artifact artifact) {
String groupPath = artifact.getGroupId().replace('.', '/');
String parentPath = DashboardMain.basePath + "/" + groupPath
+ "/" + artifact.getArtifactId() + "-parent"
+ "/" + artifact.getVersion()
+ "/" + artifact.getArtifactId() + "-parent-" + artifact.getVersion() + ".pom";
String depsBomPath = DashboardMain.basePath + "/" + groupPath
+ "/" + artifact.getArtifactId() + "-deps-bom"
+ "/" + artifact.getVersion()
+ "/" + artifact.getArtifactId() + "-deps-bom-" + artifact.getVersion() + ".pom";
String version = getSharedDependenciesVersionFromUrl(parentPath);
if (version != null) {
return new SharedDependenciesData(parentPath, version);
}
version = getSharedDependenciesVersionFromUrl(pomUrl);
if (version != null) {
return new SharedDependenciesData(pomUrl, version);
}
version = getSharedDependenciesVersionFromUrl(depsBomPath);
if (version != null) {
return new SharedDependenciesData(depsBomPath, version);
}
return new SharedDependenciesData("", "");
}

private static String getSharedDependenciesVersionFromUrl(String pomUrl) {
try {
File pomFile = File.createTempFile("pomFile", ".xml");
pomFile.deleteOnExit();
URL url = new URL(pomUrl);
BufferedInputStream input = new BufferedInputStream(url.openStream());
FileUtils.copyInputStreamToFile(input, pomFile);
MavenXpp3Reader read = new MavenXpp3Reader();
Model model = read.read(new FileInputStream(pomFile));
if (model.getDependencyManagement() == null) {
return null;
}
for (Dependency dep : model.getDependencyManagement()
.getDependencies()) {
if ("com.google.cloud".equals(dep.getGroupId()) && "google-cloud-shared-dependencies"
.equals(dep.getArtifactId())) {
return dep.getVersion();
}
}

} catch (XmlPullParserException | IOException ignored) {
}
return null;
}

private static String generatePomFileUrl(Artifact artifact) {
String groupPath = artifact.getGroupId().replace('.', '/');
return DashboardMain.basePath + "/" + groupPath
+ "/" + artifact.getArtifactId()
+ "/" + artifact.getVersion()
+ "/" + artifact.getArtifactId() + "-" + artifact.getVersion() + ".pom";
}

private static String generateMetadataUrl(Artifact artifact) {
String groupPath = artifact.getGroupId().replace('.', '/');
return DashboardMain.basePath + "/" + groupPath
+ "/" + artifact.getArtifactId()
+ "/maven-metadata.xml";
}

private static class LatestMetadata {

String latestVersion, lastUpdated;

LatestMetadata(String latestVersion, String lastUpdated) {
this.latestVersion = latestVersion;
this.lastUpdated = lastUpdated;
}
}

private static class SharedDependenciesData {

String sharedDependencyPosition, sharedDependencyVersion;

SharedDependenciesData(String sharedDependencyPosition, String sharedDependencyVersion) {
this.sharedDependencyPosition = sharedDependencyPosition;
this.sharedDependencyVersion = sharedDependencyVersion;
}
}
}
Loading