Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion application-home/conf/datasources/ds-sites.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
<permission ref="site.reload" mode="set" />
</permissions>
</link>
<link mode="intern" target="/sites&#63;act=reloadTemplate&#38;siteid=${current.id}">
<link mode="intern" target="/sites&#63;act=reloadTemplate&#38;sitename=${current.name}">
<label>reload.template</label>
<icon>reload</icon>
<condition expression="${current.state.name() eq 'STARTED'}" />
Expand Down
4 changes: 2 additions & 2 deletions application-home/conf/events/ev-sites.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@
</permissions>
<params>
<param name="form_action" />
<param name="siteid" />
<param name="sitename" />
</params>
</config>
<condition expression="${form_action eq 'reloadTemplate'}" />
<bean id="sites">
<option name="site" id="${siteid}" />
<option name="site" sitename="${sitename}" />
<option name="action" id="reloadTemplate" />
</bean>
</action>
Expand Down
2 changes: 1 addition & 1 deletion application-home/conf/pages/pg-sites.xml
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@
<action id="reloadTemplate" eventId="siteEvent" onSuccess="/sites" forceForward="true">
<params>
<param name="form_action">${act}</param>
<param name="siteid">${siteid}</param>
<param name="sitename">${sitename}</param>
</params>
</action>
</element>
Expand Down
3 changes: 2 additions & 1 deletion application-home/dictionary/manager-messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ lastLogin=Last login
lastUpdated=Last updated
latestRelease=Latest release
latestSnapshot=Latest snapshot
ldap.disabled=LDAP Authentication is disabled. Set site property ''{0}'' to ''false'' to enable.
ldap.disabled=LDAP Authentication is disabled via site property ''{0}''.
ldap.noAdminPassword=No password for LDAP admin user ''{0}'' is set. Use site property ''{1}'' to set one.
ldap.users=LDAP Users
ldap.settings=LDAP Settings
ldap.not.working=Unable to connect to LDAP server at {0}, please check configuration!
Expand Down
12 changes: 12 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
Release Notes - appNG Manager - Version 1.19.3 (2022-10-07)
-----------------------------------------------------------
* [MGR-143] - Condition for displaying sessions is wrong
* [MGR-144] - Avoid showing an error message when no password is set for LDAP admin

Release Notes - appNG Manager - Version 1.19.2 (2022-07-27)
-----------------------------------------------------------
* [MGR-137] - Avoid possible NPE when showing sessions
* [MGR-139] - Reloading the template does not trigger a ReloadTemplateEvent
* [MGR-140] - Editing an inactive site leads to an ProcessingException
* [MGR-141] - Upgrade version for maven-gpg-plugin

Release Notes - appNG Manager - Version 1.19.1 (2022-02-08)
-----------------------------------------------------------
* [MGR-133] - Include-condition for actions "install" and "reload" is wrong
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<artifactId>appng-manager</artifactId>
<packaging>jar</packaging>
<name>appNG Manager</name>
<version>1.19.2-SNAPSHOT</version>
<version>1.19.4-SNAPSHOT</version>
<description><![CDATA[Global appNG administration]]></description>
<url>https://appng.org</url>

Expand Down Expand Up @@ -116,7 +116,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<version>3.0.1</version>
<executions>
<execution>
<id>sign-artifacts</id>
Expand Down
174 changes: 94 additions & 80 deletions src/main/java/org/appng/application/manager/business/Cache.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import org.appng.xml.platform.SortOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Component;
Expand Down Expand Up @@ -87,98 +88,111 @@ public DataContainer getData(Site site, Application application, Environment env
Map<String, Site> siteMap = env.getAttribute(Scope.PLATFORM, Platform.Environment.SITES);
Optional<Site> cacheSite = siteMap.values().stream().filter(s -> s.getId().equals(siteId)).findFirst();

if (STATISTICS.equals(mode)) {
List<Entry<String, String>> cacheStats = getCacheStats(request, cacheSite);
dataContainer.setItems(cacheStats);
} else if (ENTRIES.equals(mode)) {
Page<CacheEntry> cacheEntries = getCacheEntries(request, fp, cacheSite, dataContainer);
dataContainer.setPage(cacheEntries);
}

return dataContainer;
}

public List<Entry<String, String>> getCacheStats(Request request, Optional<Site> cacheSite) {
List<Entry<String, String>> result = new ArrayList<>();
if (cacheSite.isPresent()) {
if (STATISTICS.equals(mode)) {
List<Entry<String, String>> result = new ArrayList<>();
Map<String, String> stats = CacheService.getCacheStatistics(cacheSite.get());
if (!stats.isEmpty()) {
result.add(getStatEntry(request, stats, CacheService.STATS_NAME));
result.add(getStatEntry(request, stats, CacheService.STATS_SIZE));
result.add(getStatEntry(request, stats, CacheService.STATS_HITS));
result.add(getStatEntry(request, stats, CacheService.STATS_HITS_PERCENT));
result.add(getStatEntry(request, stats, CacheService.STATS_MISSES));
result.add(getStatEntry(request, stats, CacheService.STATS_MISSES_PERCENT));
result.add(getStatEntry(request, stats, CacheService.STATS_PUTS));
result.add(getStatEntry(request, stats, CacheService.STATS_AVG_PUT_TIME));
result.add(getStatEntry(request, stats, CacheService.STATS_GETS));
result.add(getStatEntry(request, stats, CacheService.STATS_AVG_GET_TIME));
result.add(getStatEntry(request, stats, CacheService.STATS_REMOVALS));
result.add(getStatEntry(request, stats, CacheService.STATS_AVG_REMOVAL_TIME));
}
dataContainer.setItems(result);
} else if (ENTRIES.equals(mode)) {
Pageable pageable = fp.getPageable();
List<CacheEntry> cacheEntries = new ArrayList<>();

javax.cache.Cache<String, CachedResponse> cache = CacheService.getCache(cacheSite.get());
int cacheSize = 0;
if (null != cache) {
cacheSize = cache.unwrap(ICache.class).size();

if (cacheSize > maxCacheEntries) {
Iterator<javax.cache.Cache.Entry<String, CachedResponse>> elements = cache.iterator();
int idx = 0;
int startIdx = pageable.getOffset();
int endIdx = pageable.getOffset() + pageable.getPageSize();
while (elements.hasNext()) {
javax.cache.Cache.Entry<java.lang.String, CachedResponse> entry = elements.next();
CachedResponse cachedResponse = entry.getValue();
// entry may have been removed meanwhile
if (null != cachedResponse) {
if (idx >= startIdx && idx < endIdx) {
cacheEntries.add(new CacheEntry(cachedResponse));
}
if (idx++ >= endIdx) {
break;
}
} else {
endIdx++;
Map<String, String> stats = CacheService.getCacheStatistics(cacheSite.get());
if (!stats.isEmpty()) {
result.add(getStatEntry(request, stats, CacheService.STATS_NAME));
result.add(getStatEntry(request, stats, CacheService.STATS_SIZE));
result.add(getStatEntry(request, stats, CacheService.STATS_HITS));
result.add(getStatEntry(request, stats, CacheService.STATS_HITS_PERCENT));
result.add(getStatEntry(request, stats, CacheService.STATS_MISSES));
result.add(getStatEntry(request, stats, CacheService.STATS_MISSES_PERCENT));
result.add(getStatEntry(request, stats, CacheService.STATS_PUTS));
result.add(getStatEntry(request, stats, CacheService.STATS_AVG_PUT_TIME));
result.add(getStatEntry(request, stats, CacheService.STATS_GETS));
result.add(getStatEntry(request, stats, CacheService.STATS_AVG_GET_TIME));
result.add(getStatEntry(request, stats, CacheService.STATS_REMOVALS));
result.add(getStatEntry(request, stats, CacheService.STATS_AVG_REMOVAL_TIME));
}
}
return result;
}

public Page<CacheEntry> getCacheEntries(Request request, FieldProcessor fp, Optional<Site> cacheSite,
DataContainer dataContainer) {
Pageable pageable = fp.getPageable();
List<CacheEntry> cacheEntries = new ArrayList<>();
int cacheSize = 0;
if (cacheSite.isPresent()) {
javax.cache.Cache<String, CachedResponse> cache = CacheService.getCache(cacheSite.get());
if (null != cache) {
cacheSize = cache.unwrap(ICache.class).size();

if (cacheSize > maxCacheEntries) {
Iterator<javax.cache.Cache.Entry<String, CachedResponse>> elements = cache.iterator();
int idx = 0;
int startIdx = pageable.getOffset();
int endIdx = pageable.getOffset() + pageable.getPageSize();
while (elements.hasNext()) {
javax.cache.Cache.Entry<java.lang.String, CachedResponse> entry = elements.next();
CachedResponse cachedResponse = entry.getValue();
// entry may have been removed meanwhile
if (null != cachedResponse) {
if (idx >= startIdx && idx < endIdx) {
cacheEntries.add(new CacheEntry(cachedResponse));
}
if (idx++ >= endIdx) {
break;
}
} else {
endIdx++;
}
}

fp.getFields().stream().filter(f -> !"id".equals(f.getBinding())).forEach(f -> f.setSort(null));
SortOrder idOrder = fp.getField("id").getSort().getOrder();
if (null != idOrder) {
Collections.sort(cacheEntries, (e1, e2) -> StringUtils.compare(e1.getId(), e2.getId()));
if (SortOrder.DESC.equals(idOrder)) {
Collections.reverse(cacheEntries);
}
fp.getFields().stream().filter(f -> !"id".equals(f.getBinding())).forEach(f -> f.setSort(null));
SortOrder idOrder = fp.getField("id").getSort().getOrder();
if (null != idOrder) {
Collections.sort(cacheEntries, (e1, e2) -> StringUtils.compare(e1.getId(), e2.getId()));
if (SortOrder.DESC.equals(idOrder)) {
Collections.reverse(cacheEntries);
}
}

} else {
String entryName = request.getParameter(F_ETR);
String entryType = request.getParameter(F_CTYPE);
boolean filterName = StringUtils.isNotBlank(entryName);
boolean filterType = StringUtils.isNotBlank(entryType);
for (javax.cache.Cache.Entry<String, CachedResponse> entry : cache) {
String entryId = entry.getKey();
CachedResponse cachedResponse = entry.getValue();
// entry may have been removed meanwhile
if (null != cachedResponse) {
boolean nameMatches = !filterName || FilenameUtils.wildcardMatch(
entryId.substring(entryId.indexOf('/')), entryName, IOCase.INSENSITIVE);
boolean typeMatches = !filterType || FilenameUtils
.wildcardMatch(cachedResponse.getContentType(), entryType, IOCase.INSENSITIVE);
if (nameMatches && typeMatches) {
cacheEntries.add(new CacheEntry(cachedResponse));
}
} else {
String entryName = request.getParameter(F_ETR);
String entryType = request.getParameter(F_CTYPE);
boolean filterName = StringUtils.isNotBlank(entryName);
boolean filterType = StringUtils.isNotBlank(entryType);
for (javax.cache.Cache.Entry<String, CachedResponse> entry : cache) {
String entryId = entry.getKey();
CachedResponse cachedResponse = entry.getValue();
// entry may have been removed meanwhile
if (null != cachedResponse) {
boolean nameMatches = !filterName || FilenameUtils.wildcardMatch(
entryId.substring(entryId.indexOf('/')), entryName, IOCase.INSENSITIVE);
boolean typeMatches = !filterType || FilenameUtils
.wildcardMatch(cachedResponse.getContentType(), entryType, IOCase.INSENSITIVE);
if (nameMatches && typeMatches) {
cacheEntries.add(new CacheEntry(cachedResponse));
}
}

Selection nameSelection = selectionFactory.getTextSelection(F_ETR, MessageConstants.NAME,
entryName);
Selection typeSelection = selectionFactory.getTextSelection(F_CTYPE, MessageConstants.TYPE,
entryType);
SelectionGroup selectionGroup = new SelectionGroup();
selectionGroup.getSelections().add(nameSelection);
selectionGroup.getSelections().add(typeSelection);
dataContainer.getSelectionGroups().add(selectionGroup);
}

Selection nameSelection = selectionFactory.getTextSelection(F_ETR, MessageConstants.NAME,
entryName);
Selection typeSelection = selectionFactory.getTextSelection(F_CTYPE, MessageConstants.TYPE,
entryType);
SelectionGroup selectionGroup = new SelectionGroup();
selectionGroup.getSelections().add(nameSelection);
selectionGroup.getSelections().add(typeSelection);
dataContainer.getSelectionGroups().add(selectionGroup);
}
dataContainer.setPage(new PageImpl<>(cacheEntries, pageable, cacheSize));
}
}
return dataContainer;
return new PageImpl<>(cacheEntries, pageable, cacheSize);
}

private Entry<String, String> getStatEntry(Request request, Map<String, String> statistics, String statKey) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,16 @@ public DataContainer getData(Site site, Application application, Environment env
dataContainer.setItems(ldapProps);

if (!ldapDisabled) {
char[] ldapPw = siteProps.getString(LdapService.LDAP_PASSWORD, StringUtils.EMPTY).toCharArray();
boolean adminLoginOk = ldapService.loginUser(site, ldapUser.getString(), ldapPw);
if (!adminLoginOk) {
fp.addErrorMessage(request.getMessage(MessageConstants.LDAP_NOT_WORKING, ldapHost.getString()));
String ldapPassword = siteProps.getString(LdapService.LDAP_PASSWORD, StringUtils.EMPTY);
if (StringUtils.isNotBlank(ldapPassword)) {
char[] ldapPw = ldapPassword.toCharArray();
boolean adminLoginOk = ldapService.loginUser(site, ldapUser.getString(), ldapPw);
if (!adminLoginOk) {
fp.addErrorMessage(request.getMessage(MessageConstants.LDAP_NOT_WORKING, ldapHost.getString()));
}
} else {
fp.addNoticeMessage(request.getMessage(MessageConstants.LDAP_NO_ADMIN_PASSWORD,
ldapUser.getString(), LdapService.LDAP_PASSWORD));
}
}
} else {
Expand Down
Loading