Skip to content

Commit

Permalink
Merge branch 'release/2.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
ghenzler committed Oct 18, 2017
2 parents 30522bb + 19059da commit 1d8b5b4
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 70 deletions.
6 changes: 3 additions & 3 deletions accesscontroltool-bundle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>biz.netcentric.cq.tools.accesscontroltool</groupId>
<artifactId>accesscontroltool</artifactId>
<version>2.0.1</version>
<version>2.0.2</version>
</parent>

<!-- ====================================================================== -->
Expand Down Expand Up @@ -140,12 +140,12 @@
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>el-api</artifactId>
<version>6.0.41</version>
<version>6.0.53</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>jasper-el</artifactId>
<version>6.0.41</version>
<version>6.0.53</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import javax.jcr.PathNotFoundException;
import javax.jcr.Property;
import javax.jcr.PropertyIterator;
import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.Value;
Expand Down Expand Up @@ -80,7 +81,11 @@ public List<Object> getValuesForPath(String pathOfChildrenOfClause, AcInstallati
if (prop.isMultiple()) {
jcrContentSubNode.put(prop.getName(), valuesToStringArr(prop.getValues()));
} else {
String strVal = prop.getValue().getString();
Value value = prop.getValue();
if (isIrrelevantType(value)) {
continue;
}
String strVal = value.getString();
jcrContentSubNode.put(prop.getName(), strVal);

// add the title also to root map to simplify access
Expand Down Expand Up @@ -112,12 +117,22 @@ public List<Object> getValuesForPath(String pathOfChildrenOfClause, AcInstallati
return results;
}

private boolean isIrrelevantType(Value value) {
return value.getType() == PropertyType.BINARY
|| value.getType() == PropertyType.REFERENCE
|| value.getType() == PropertyType.WEAKREFERENCE;
}

private String[] valuesToStringArr(Value[] values) throws ValueFormatException, RepositoryException {
String[] strVals = new String[values.length];
List<String> strVals = new ArrayList<String>();
for (int i = 0; i < values.length; i++) {
strVals[i] = values[i].getString();
Value value = values[i];
if (isIrrelevantType(value)) {
continue;
}
strVals.add(value.getString());
}
return strVals;
return strVals.toArray(new String[strVals.size()]);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Properties;
import org.apache.felix.scr.annotations.PropertyOption;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.PropertyOption;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.commons.osgi.PropertiesUtil;
import org.apache.sling.jcr.api.SlingRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import biz.netcentric.cq.tools.actool.aceservice.AceService;
import biz.netcentric.cq.tools.actool.api.AcInstallationService;
import biz.netcentric.cq.tools.actool.configuploadlistener.UploadListenerService;
import biz.netcentric.cq.tools.actool.helper.Constants;
import biz.netcentric.cq.tools.actool.history.AcHistoryService;
import biz.netcentric.cq.tools.actool.impl.AcInstallationServiceImpl;

@Component(metatype = true, label = "AC Configuration Upload Listener Service", immediate = true, description = "Listens for ACL configuration uploads and triggers ACL Service.")
@Properties({
Expand All @@ -43,27 +43,21 @@
@PropertyOption(name = "disabled", value = "disabled"),
@PropertyOption(name = "enabled", value = "enabled") }) })
@Service(value = UploadListenerService.class)
public class UploadListenerServiceImpl implements UploadListenerService,
EventListener {
public class UploadListenerServiceImpl implements UploadListenerService, EventListener {
private static final Logger LOG = LoggerFactory.getLogger(UploadListenerServiceImpl.class);

static final String ACE_UPLOAD_LISTENER_SET_STATUS_SERVICE = "AceUploadListener.setStatusService";

private String configurationPath;
private boolean enabled;

private static final Logger LOG = LoggerFactory
.getLogger(UploadListenerServiceImpl.class);

private Session adminSession;

@Reference
SlingRepository repository;

@Reference
AceService aceService;

@Reference
AcHistoryService acHistoryService;
AcInstallationService acInstallationService;

@Override
public void onEvent(EventIterator events) {
Expand All @@ -87,8 +81,8 @@ public void onEvent(EventIterator events) {
LOG.warn("Unexpected event: {}", event);
}
if (node != null && node.hasProperty("jcr:content/jcr:data")) {
LOG.info("Detected new or changed node at {}.", node.getPath());
++changes;
LOG.info("Detected new or changed node at {}", node.getPath());
changes++;
} else {
LOG.debug("Node {} associated with event does not have configuration data.", event.getPath());
}
Expand All @@ -98,77 +92,74 @@ public void onEvent(EventIterator events) {
}
if (changes > 0) {
LOG.info("There are {} new or changed files. Triggering reload of configuration.", changes);
aceService.execute();
acInstallationService.apply();
}
}
}

@Activate
public void activate(@SuppressWarnings("rawtypes") final Map properties)
throws Exception {
this.configurationPath = aceService.getConfiguredAcConfigurationRootPath();
String statusService = PropertiesUtil
.toString(
properties
.get(UploadListenerServiceImpl.ACE_UPLOAD_LISTENER_SET_STATUS_SERVICE),
"");
this.configurationPath = ((AcInstallationServiceImpl) acInstallationService).getConfiguredAcConfigurationRootPath();
String statusService = PropertiesUtil.toString(properties.get(UploadListenerServiceImpl.ACE_UPLOAD_LISTENER_SET_STATUS_SERVICE),
"");
if (StringUtils.equals(statusService, "enabled")) {
this.enabled = true;
} else {
this.enabled = false;
}

setEventListener();
if (!this.enabled) {
LOG.debug("UploadListenerServiceImpl is not active, not registering listener");
return;
} else if (StringUtils.isBlank(this.configurationPath)) {
LOG.warn("UploadListenerServiceImpl requires PID "
+ "biz.netcentric.cq.tools.actool.impl.AcInstallationServiceImpl/'AceService.configurationPath' to be configured");
return;
} else {
setupEventListener();
}
}

private void setEventListener() throws Exception {
if (StringUtils.isNotBlank(this.configurationPath)) {
try {
adminSession = repository.loginService(Constants.USER_AC_SERVICE, null);
private void setupEventListener() throws Exception {
try {
adminSession = repository.loginService(Constants.USER_AC_SERVICE, null);

adminSession
.getWorkspace()
.getObservationManager()
.addEventListener(
adminSession
.getWorkspace()
.getObservationManager()
.addEventListener(

this, // handler
this, // handler

// Event.PROPERTY_ADDED|Event.NODE_ADDED,
// //binary combination of event types
Event.NODE_ADDED | Event.PROPERTY_CHANGED,
this.configurationPath, // path
// Event.PROPERTY_ADDED|Event.NODE_ADDED,
// //binary combination of event types
Event.NODE_ADDED | Event.PROPERTY_CHANGED,
this.configurationPath, // path

true, // is Deep?
true, // is Deep?

null, // uuids filter
null, // uuids filter

null, // nodetypes filter
false);
LOG.info(
"added EventListener for ACE configuration root path: {}",
this.configurationPath);
} catch (RepositoryException e) {
LOG.error("RepositoryException in UploadListenerService:{}", e);
}
} else {
LOG.warn("no root ACE configuration path configured in AceService");
null, // nodetypes filter
false);
LOG.info("Registered event listener for AC configuration root path: {}", this.configurationPath);
} catch (RepositoryException e) {
LOG.error("Exception while registering listener in UploadListenerService: " + e, e);
}
}

@Deactivate
public void deactivate() {
if (adminSession != null) {
try {
adminSession.getWorkspace().getObservationManager().removeEventListener(this);
LOG.info("Unregistered event listener for AC configuration root path: {}", this.configurationPath);
} catch (Exception e) {
LOG.error("Exception while unregistering listener in UploadListenerService: " + e, e);
}
adminSession.logout();
}
}

public void setPath(String path) {
this.configurationPath = path;
try {
setEventListener();
} catch (Exception e) {
LOG.error("Exception in UploadListenerService: {}", e);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -738,17 +738,17 @@ public String getVersion() {
/* --- deprecated methods --- */
@Override
public AcInstallationHistoryPojo execute() {
return execute();
return apply();
}

@Override
public AcInstallationHistoryPojo execute(String configurationRootPath) {
return execute(configurationRootPath);
return apply(configurationRootPath);
}

@Override
public AcInstallationHistoryPojo execute(String[] restrictedToPaths) {
return execute(restrictedToPaths);
return apply(restrictedToPaths);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion accesscontroltool-exampleconfig-package/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<parent>
<groupId>biz.netcentric.cq.tools.accesscontroltool</groupId>
<artifactId>accesscontroltool</artifactId>
<version>2.0.1</version>
<version>2.0.2</version>
</parent>

<!-- ====================================================================== -->
Expand Down
2 changes: 1 addition & 1 deletion accesscontroltool-oakindex-package/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<parent>
<groupId>biz.netcentric.cq.tools.accesscontroltool</groupId>
<artifactId>accesscontroltool</artifactId>
<version>2.0.1</version>
<version>2.0.2</version>
</parent>

<!-- ====================================================================== -->
Expand Down
2 changes: 1 addition & 1 deletion accesscontroltool-package/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<parent>
<groupId>biz.netcentric.cq.tools.accesscontroltool</groupId>
<artifactId>accesscontroltool</artifactId>
<version>2.0.1</version>
<version>2.0.2</version>
</parent>

<!-- ====================================================================== -->
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<groupId>biz.netcentric.cq.tools.accesscontroltool</groupId>
<artifactId>accesscontroltool</artifactId>
<version>2.0.1</version>
<version>2.0.2</version>
<packaging>pom</packaging>

<name>Access Control Tool - Reactor Project</name>
Expand Down

0 comments on commit 1d8b5b4

Please sign in to comment.