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

Issue 26518 osgi fragment #28981

Merged
merged 7 commits into from
Jun 24, 2024
Merged
Changes from all commits
Commits
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
31 changes: 30 additions & 1 deletion dotCMS/src/main/java/org/apache/felix/framework/OSGIUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import com.liferay.portal.language.LanguageUtil;
import com.liferay.util.FileUtil;
import com.liferay.util.MathUtil;
import io.vavr.Tuple;
import io.vavr.Tuple2;
import io.vavr.control.Try;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
Expand Down Expand Up @@ -613,8 +615,18 @@ private void move(final String[] pathnames,
}
}

private static void sendOSGIBundlesLoadedMessage(final String[] pathnames) {
private static void sendOSGIBundlesLoadedMessage(final String[] pathnamesIn) {

final Tuple2<Boolean, String []> result = containsFragments(pathnamesIn);
if (result._1()) {

final String successMessage = "The packages in the fragment have been added to the exported packages list.";
SystemMessageEventUtil.getInstance().pushMessage("OSGI_BUNDLES_LOADED",new SystemMessageBuilder().setMessage(successMessage)
.setLife(DateUtil.FIVE_SECOND_MILLIS)
.setSeverity(MessageSeverity.SUCCESS).create(), null);
}

final String[] pathnames = result._2();
final String messageKey = pathnames.length > 1? "new-osgi-plugins-installed":"new-osgi-plugin-installed";
final String successMessage = Try.of(()->LanguageUtil.get(APILocator.getCompanyAPI()
.getDefaultCompany().getLocale(), messageKey)).getOrElse(()-> "New OSGi Plugin(s) have been installed");
Expand All @@ -623,6 +635,23 @@ private static void sendOSGIBundlesLoadedMessage(final String[] pathnames) {
.setSeverity(MessageSeverity.SUCCESS).create(), null);
}


private static Tuple2<Boolean, String[]> containsFragments(final String[] pathnamesIn) {

boolean hasFragments = false;
final List<String> pathnames = new ArrayList<>();
for (final String pathname : pathnamesIn) {

if (pathname.contains("fragment")) {
hasFragments = true;
} else {
pathnames.add(pathname);
}
}

return Tuple.of(hasFragments, pathnames.toArray(new String []{}));
}

/**
* Stops the OSGi framework
*/
Expand Down
Loading