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

Lps 94399 #72206

Closed
wants to merge 36 commits into from
Closed

Lps 94399 #72206

Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
c1e549f
LPS-93659 Rename to what it is.
Preston-Crary Apr 18, 2019
459cf64
LPS-93659 Not thrown.
Preston-Crary Apr 18, 2019
40cfb0a
LPS-93659 At least log it.
Preston-Crary Apr 18, 2019
6155e5d
LPS-93659 Inline method with only one usage.
Preston-Crary Apr 18, 2019
4a31760
LPS-93659 Inline var.
Preston-Crary Apr 18, 2019
52b18ad
LPS-93659 Inline simple method.
Preston-Crary Apr 18, 2019
2b1e053
LPS-93659 As used.
Preston-Crary Apr 18, 2019
bef09af
LPS-93659 Pull up common logic.
Preston-Crary Apr 18, 2019
81feb71
LPS-93659 Pull up the duplicate logic and remove the adaptor to our o…
Preston-Crary Apr 18, 2019
0da3818
LPS-93659 Allow the exception instead of hiding it.
Preston-Crary Apr 18, 2019
7da730c
LPS-93659 Pull up creation logic into factory.
Preston-Crary Apr 18, 2019
7c74640
LPS-93659 This case is impossible.
Preston-Crary Apr 18, 2019
837050d
LPS-94399 Pull up logic. Remove tautology test, after this it was ass…
Preston-Crary Apr 18, 2019
6901022
LPS-94399 Extract method.
Preston-Crary Apr 18, 2019
752c293
LPS-94399 Simplify.
Preston-Crary Apr 18, 2019
f23f318
LPS-94399 Inline method.
Preston-Crary Apr 18, 2019
5446a40
LPS-94399 Remove extra substring() call.
Preston-Crary Apr 18, 2019
ce338bc
LPS-94399 Measure twice, cut once.
Preston-Crary Apr 18, 2019
c4770da
LPS-94399 As used.
Preston-Crary Apr 18, 2019
24df5e9
LPS-94399 It's one-to-one. Remove other tautology tests.
Preston-Crary Apr 18, 2019
b160c36
LPS-94399 Combine calls.
Preston-Crary Apr 19, 2019
5fa4d5c
LPS-94399 No difference between ConfigurationDescriptions but that ge…
Preston-Crary Apr 19, 2019
3044fec
LPS-94399 No need for interface.
Preston-Crary Apr 19, 2019
dcf2f84
LPS-94399 Push down.
Preston-Crary Apr 19, 2019
eea526b
LPS-94399 Pull up getProperties().
Preston-Crary Apr 19, 2019
99e1318
LPS-94399 Reduce duplication with base class.
Preston-Crary Apr 19, 2019
86ef155
LPS-94399 Replace abstract class with concrete class.
Preston-Crary Apr 19, 2019
11c6b63
LPS-94399 One return.
Preston-Crary Apr 19, 2019
a07674e
LPS-94399 Merge ConfigurationDescription with NamedConfigurationContent.
Preston-Crary Apr 19, 2019
4f17be5
LPS-94399 Move the string parsing to a single place.
Preston-Crary Apr 19, 2019
b17b179
LPS-94399 Less substring() calls.
Preston-Crary Apr 19, 2019
c7786e7
LPS-94399 Update test.
Preston-Crary Apr 19, 2019
9b96f80
LPS-94399 Make the inputStreams are closed
shuyangzhou Apr 24, 2019
c729e56
LPS-94399 Be strict, abort Extension creation on any failure.
shuyangzhou Apr 24, 2019
df01d43
LPS-94399 Mute the confusing the System.err print. Change this to log…
shuyangzhou Apr 24, 2019
44f90db
LPS-94399 There is nothing to destroy
shuyangzhou Apr 24, 2019
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

LPS-93659 Pull up the duplicate logic and remove the adaptor to our o…

…wn internal API.
  • Loading branch information...
Preston-Crary authored and shuyangzhou committed Apr 18, 2019
commit 81feb7108039b1cc05c4d010db5abc4a0f4071e6

This file was deleted.

@@ -18,8 +18,6 @@
import com.liferay.petra.string.StringBundler;
import com.liferay.petra.string.StringPool;

import java.io.IOException;

import java.net.URL;

import java.util.ArrayList;
@@ -96,23 +94,32 @@ protected Extension doCreateExtension(Bundle bundle) {
Dictionary<String, String> headers = bundle.getHeaders(
StringPool.BLANK);

if (headers.get("Liferay-Configuration-Path") == null) {
String configurationPath = headers.get("Liferay-Configuration-Path");

if (configurationPath == null) {
return null;
}

Collection<NamedConfigurationContent> namedConfigurationContents =
List<NamedConfigurationContent> namedConfigurationContents =
new ArrayList<>();

for (NamedConfigurationContentFactory namedConfigurationContentFactory :
_namedConfigurationContentFactories) {

try {
List<NamedConfigurationContent> contents =
namedConfigurationContentFactory.create(
new BundleStorageImpl(bundle));
Enumeration<URL> entries = bundle.findEntries(
configurationPath,
namedConfigurationContentFactory.getFilePattern(), true);

if (entries == null) {
continue;
}

if (contents != null) {
namedConfigurationContents.addAll(contents);
while (entries.hasMoreElements()) {
URL url = entries.nextElement();

namedConfigurationContents.add(
namedConfigurationContentFactory.create(url));
}
}
catch (Throwable t) {
@@ -169,61 +176,4 @@ protected void warn(Bundle bundle, String s, Throwable throwable) {
private final Collection<NamedConfigurationContentFactory>
_namedConfigurationContentFactories = new CopyOnWriteArrayList<>();

private static class BundleStorageImpl implements BundleStorage {

public BundleStorageImpl(Bundle bundle) {
_bundle = bundle;
}

@Override
public Enumeration<URL> findEntries(
String root, String pattern, boolean recurse) {

return _bundle.findEntries(root, pattern, recurse);
}

@Override
public long getBundleId() {
return _bundle.getBundleId();
}

@Override
public URL getEntry(String name) {
return _bundle.getEntry(name);
}

@Override
public Enumeration<String> getEntryPaths(String name) {
return _bundle.getEntryPaths(name);
}

@Override
public Dictionary<String, String> getHeaders() {
return _bundle.getHeaders(StringPool.BLANK);
}

@Override
public String getLocation() {
return _bundle.getLocation();
}

@Override
public URL getResource(String name) {
return _bundle.getResource(name);
}

@Override
public Enumeration<URL> getResources(String name) throws IOException {
return _bundle.getResources(name);
}

@Override
public String getSymbolicName() {
return _bundle.getSymbolicName();
}

private final Bundle _bundle;

}

}
@@ -14,13 +14,15 @@

package com.liferay.portal.configuration.extender.internal;

import java.util.List;
import java.net.URL;

/**
* @author Carlos Sierra Andrés
*/
public interface NamedConfigurationContentFactory {

public List<NamedConfigurationContent> create(BundleStorage bundleStorage);
public NamedConfigurationContent create(URL url);

public String getFilePattern();

}
@@ -14,15 +14,8 @@

package com.liferay.portal.configuration.extender.internal;

import com.liferay.portal.kernel.util.ListUtil;
import com.liferay.portal.kernel.util.MappingEnumeration;

import java.net.URL;

import java.util.Dictionary;
import java.util.Enumeration;
import java.util.List;

import org.osgi.service.component.annotations.Component;

/**
@@ -33,26 +26,13 @@
implements NamedConfigurationContentFactory {

@Override
public List<NamedConfigurationContent> create(BundleStorage bundleStorage) {
Dictionary<String, String> headers = bundleStorage.getHeaders();

String configurationPath = headers.get("Liferay-Configuration-Path");

final Enumeration<URL> entries = bundleStorage.findEntries(
configurationPath, "*.properties", true);

return ListUtil.fromEnumeration(
new MappingEnumeration<>(
entries,
new MappingEnumeration.Mapper
<URL, NamedConfigurationContent>() {

@Override
public NamedConfigurationContent map(URL url) {
return new PropertiesFileNamedConfigurationContent(url);
}
public NamedConfigurationContent create(URL url) {
return new PropertiesFileNamedConfigurationContent(url);
}

}));
@Override
public String getFilePattern() {
return "*.properties";
}

}
@@ -14,18 +14,11 @@

package com.liferay.portal.configuration.extender.internal.support.config.file;

import com.liferay.portal.configuration.extender.internal.BundleStorage;
import com.liferay.portal.configuration.extender.internal.NamedConfigurationContent;
import com.liferay.portal.configuration.extender.internal.NamedConfigurationContentFactory;
import com.liferay.portal.kernel.util.ListUtil;
import com.liferay.portal.kernel.util.MappingEnumeration;

import java.net.URL;

import java.util.Dictionary;
import java.util.Enumeration;
import java.util.List;

import org.osgi.service.component.annotations.Component;

/**
@@ -36,26 +29,13 @@
implements NamedConfigurationContentFactory {

@Override
public List<NamedConfigurationContent> create(BundleStorage bundleStorage) {
Dictionary<String, String> headers = bundleStorage.getHeaders();

String configurationPath = headers.get("Liferay-Configuration-Path");

Enumeration<URL> enumeration = bundleStorage.findEntries(
configurationPath, "*.config", true);

return ListUtil.fromEnumeration(
new MappingEnumeration<>(
enumeration,
new MappingEnumeration.Mapper
<URL, NamedConfigurationContent>() {

@Override
public NamedConfigurationContent map(URL url) {
return new ConfigFileNamedConfigurationContent(url);
}
public NamedConfigurationContent create(URL url) {
return new ConfigFileNamedConfigurationContent(url);
}

}));
@Override
public String getFilePattern() {
return "*.config";
}

}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.