Skip to content

Commit

Permalink
BLADE-743 cli: ReleaseUtil: removes unused methods and classes
Browse files Browse the repository at this point in the history
  • Loading branch information
drewbrokke committed Apr 3, 2024
1 parent d7c2783 commit de3d81a
Showing 1 changed file with 0 additions and 130 deletions.
130 changes: 0 additions & 130 deletions cli/src/main/java/com/liferay/blade/cli/util/ReleaseUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.function.Function;
import java.util.stream.Stream;

Expand All @@ -27,14 +26,6 @@ public static ReleaseEntry getReleaseEntry(String releaseKey) {
return _releaseUtil._releaseEntryMap.getOrDefault(releaseKey, _EMPTY_RELEASE_ENTRY);
}

public static ReleaseProperties getReleaseProperties(String releaseKey) {
if (releaseKey == null) {
return _EMPTY_RELEASE_PROPERTIES;
}

return _releaseUtil._releasePropertiesMap.computeIfAbsent(releaseKey, _releaseUtil::_createReleaseProperties);
}

public static void refreshReleases() {
System.out.println("Checking for new releases...");

Expand Down Expand Up @@ -106,98 +97,6 @@ public boolean isPromoted() {

}

public static class ReleaseProperties {

public String getAppServerTomcatVersion() {
return _appServerTomcatVersion;
}

public String getBuildTimestamp() {
return _buildTimestamp;
}

public String getBundleChecksumSHA512() {
return _bundleChecksumSHA512;
}

public String getBundleUrl() {
return _bundleUrl;
}

public String getGitHashLiferayDocker() {
return _gitHashLiferayDocker;
}

public String getGitHashLiferayPortalEE() {
return _gitHashLiferayPortalEE;
}

public String getLiferayDockerImage() {
return _liferayDockerImage;
}

public String getLiferayDockerTags() {
return _liferayDockerTags;
}

public String getLiferayProductVersion() {
return _liferayProductVersion;
}

public String getReleaseDate() {
return _releaseDate;
}

public String getTargetPlatformVersion() {
return _targetPlatformVersion;
}

private ReleaseProperties() {
this(new Properties());
}

private ReleaseProperties(Properties properties) {
this(
properties.getProperty("app.server.tomcat.version"), properties.getProperty("build.timestamp"),
properties.getProperty("bundle.checksum.sha512"), properties.getProperty("bundle.url"),
properties.getProperty("git.hash.liferay-docker"), properties.getProperty("git.hash.liferay-portal-ee"),
properties.getProperty("liferay.docker.image"), properties.getProperty("liferay.docker.tags"),
properties.getProperty("liferay.product.version"), properties.getProperty("release.date"),
properties.getProperty("target.platform.version"));
}

private ReleaseProperties(
String appServerTomcatVersion, String buildTimestamp, String bundleChecksumSHA512, String bundleUrl,
String gitHashLiferayDocker, String gitHashLiferayPortalEE, String liferayDockerImage,
String liferayDockerTags, String liferayProductVersion, String releaseDate, String targetPlatformVersion) {

_appServerTomcatVersion = appServerTomcatVersion;
_buildTimestamp = buildTimestamp;
_bundleChecksumSHA512 = bundleChecksumSHA512;
_bundleUrl = bundleUrl;
_gitHashLiferayDocker = gitHashLiferayDocker;
_gitHashLiferayPortalEE = gitHashLiferayPortalEE;
_liferayDockerImage = liferayDockerImage;
_liferayDockerTags = liferayDockerTags;
_liferayProductVersion = liferayProductVersion;
_releaseDate = releaseDate;
_targetPlatformVersion = targetPlatformVersion;
}

private final String _appServerTomcatVersion;
private final String _buildTimestamp;
private final String _bundleChecksumSHA512;
private final String _bundleUrl;
private final String _gitHashLiferayDocker;
private final String _gitHashLiferayPortalEE;
private final String _liferayDockerImage;
private final String _liferayDockerTags;
private final String _liferayProductVersion;
private final String _releaseDate;
private final String _targetPlatformVersion;

}

private ReleaseUtil(int maxAge) {
File releasesJsonFile = new File(_workspaceCacheDir, "releases.json");

Expand All @@ -220,41 +119,12 @@ private ReleaseUtil(int maxAge) {
}
}

private ReleaseProperties _createReleaseProperties(String releaseKey) {
ReleaseEntry releaseEntry = _releaseEntryMap.get(releaseKey);

if (releaseEntry == null) {
throw new RuntimeException(
String.format(
"%s is not a valid product key. Must be one of %s", releaseKey, _releaseEntryMap.keySet()));
}

String product = releaseEntry.getProduct();

File productReleasePropertiesCacheDir = new File(
new File(_workspaceCacheDir, "releaseProperties"), String.format("%s/%s", product, releaseKey));

String releasesCDNUrl = releaseEntry.getUrl() + "/release.properties";

String releasesUrl = releasesCDNUrl.replaceFirst("releases-cdn", "releases");

Properties properties = ResourceUtil.readProperties(
ResourceUtil.getLocalFileResolver(new File(productReleasePropertiesCacheDir, "release.properties")),
ResourceUtil.getURLResolver(productReleasePropertiesCacheDir, releasesCDNUrl, "release.properties"),
ResourceUtil.getURLResolver(productReleasePropertiesCacheDir, releasesUrl, "release.properties"));

return new ReleaseProperties(properties);
}

private static final ReleaseEntry _EMPTY_RELEASE_ENTRY = new ReleaseEntry();

private static final ReleaseProperties _EMPTY_RELEASE_PROPERTIES = new ReleaseProperties();

private static ReleaseUtil _releaseUtil = new ReleaseUtil(7);

private final ReleaseEntries _releaseEntries;
private final Map<String, ReleaseEntry> _releaseEntryMap = new HashMap<>();
private final Map<String, ReleaseProperties> _releasePropertiesMap = new HashMap<>();
private final File _workspaceCacheDir = new File(System.getProperty("user.home"), ".liferay/workspace");

private static class ReleaseEntries extends ArrayList<ReleaseEntry> {
Expand Down

0 comments on commit de3d81a

Please sign in to comment.