Skip to content

Commit

Permalink
Merge branch 'release/1.8.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
gruberrolandvaltech committed Jan 31, 2019
2 parents a07fd17 + b7f609b commit b92b7cb
Show file tree
Hide file tree
Showing 24 changed files with 109 additions and 64 deletions.
5 changes: 5 additions & 0 deletions HISTORY
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2019-01-31 1.8.1
- Groovy Console binding:
- Write access in whole /etc
- Do not print empty lines in output

2019-01-16 1.8.0
- Groovy Console binding:
- Path renaming via regex
Expand Down
2 changes: 1 addition & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>de.valtech.aecu</groupId>
<artifactId>aecu</artifactId>
<version>1.8.0</version>
<version>1.8.1</version>
</parent>

<artifactId>aecu.api</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion bundle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>de.valtech.aecu</groupId>
<artifactId>aecu</artifactId>
<version>1.8.0</version>
<version>1.8.1</version>
</parent>

<artifactId>aecu.bundle</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>de.valtech.aecu</groupId>
<artifactId>aecu</artifactId>
<version>1.8.0</version>
<version>1.8.1</version>
</parent>

<artifactId>aecu.core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Valtech GmbH
* Copyright 2018 - 2019 Valtech GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction,
Expand All @@ -18,20 +18,21 @@
*/
package de.valtech.aecu.core.groovy.console.bindings.actions.multivalue;

import de.valtech.aecu.core.groovy.console.bindings.actions.Action;

import org.apache.sling.api.resource.ModifiableValueMap;
import org.apache.sling.api.resource.PersistenceException;
import org.apache.sling.api.resource.Resource;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

import javax.annotation.Nonnull;

import org.apache.sling.api.resource.ModifiableValueMap;
import org.apache.sling.api.resource.PersistenceException;
import org.apache.sling.api.resource.Resource;

import de.valtech.aecu.core.groovy.console.bindings.actions.Action;

/**
* @author Roxana Muresan
*/
Expand All @@ -42,7 +43,7 @@ public class AddMultiValues implements Action {

public AddMultiValues(@Nonnull String name, @Nonnull String[] values) {
this.name = name;
this.values = Arrays.stream(values).filter(f -> f != null).collect(Collectors.toList()).toArray(new String[] {});
this.values = Arrays.stream(values).filter(Objects::nonNull).collect(Collectors.toList()).toArray(new String[] {});
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Valtech GmbH
* Copyright 2018 - 2019 Valtech GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction,
Expand All @@ -18,20 +18,21 @@
*/
package de.valtech.aecu.core.groovy.console.bindings.actions.multivalue;

import de.valtech.aecu.core.groovy.console.bindings.actions.Action;

import org.apache.sling.api.resource.ModifiableValueMap;
import org.apache.sling.api.resource.PersistenceException;
import org.apache.sling.api.resource.Resource;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

import javax.annotation.Nonnull;

import org.apache.sling.api.resource.ModifiableValueMap;
import org.apache.sling.api.resource.PersistenceException;
import org.apache.sling.api.resource.Resource;

import de.valtech.aecu.core.groovy.console.bindings.actions.Action;

/**
* @author Roxana Muresan
*/
Expand All @@ -42,7 +43,7 @@ public class RemoveMultiValues implements Action {

public RemoveMultiValues(@Nonnull String name, @Nonnull String[] values) {
this.name = name;
this.values = Arrays.stream(values).filter(f -> f != null).collect(Collectors.toList()).toArray(new String[] {});
this.values = Arrays.stream(values).filter(Objects::nonNull).collect(Collectors.toList()).toArray(new String[] {});
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Valtech GmbH
* Copyright 2018 - 2019 Valtech GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction,
Expand All @@ -18,20 +18,21 @@
*/
package de.valtech.aecu.core.groovy.console.bindings.actions.multivalue;

import de.valtech.aecu.core.groovy.console.bindings.actions.Action;

import org.apache.sling.api.resource.ModifiableValueMap;
import org.apache.sling.api.resource.PersistenceException;
import org.apache.sling.api.resource.Resource;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

import javax.annotation.Nonnull;

import org.apache.sling.api.resource.ModifiableValueMap;
import org.apache.sling.api.resource.PersistenceException;
import org.apache.sling.api.resource.Resource;

import de.valtech.aecu.core.groovy.console.bindings.actions.Action;

/**
* @author Roxana Muresan
*/
Expand All @@ -43,8 +44,8 @@ public class ReplaceMultiValues implements Action {

public ReplaceMultiValues(@Nonnull String name, @Nonnull String[] oldValues, @Nonnull String[] newValues) {
this.name = name;
this.oldValues = Arrays.stream(oldValues).filter(f -> f != null).collect(Collectors.toList()).toArray(new String[] {});
this.newValues = Arrays.stream(newValues).filter(f -> f != null).collect(Collectors.toList()).toArray(new String[] {});
this.oldValues = Arrays.stream(oldValues).filter(Objects::nonNull).collect(Collectors.toList()).toArray(new String[] {});
this.newValues = Arrays.stream(newValues).filter(Objects::nonNull).collect(Collectors.toList()).toArray(new String[] {});
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Valtech GmbH
* Copyright 2018 - 2019 Valtech GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction,
Expand Down Expand Up @@ -199,12 +199,12 @@ public String getHeader(String name) {

@Override
public Collection<String> getHeaders(String name) {
return Collections.EMPTY_LIST;
return Collections.emptyList();
}

@Override
public Collection<String> getHeaderNames() {
return Collections.EMPTY_LIST;
return Collections.emptyList();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
*/
public class ContentUpgradeImpl implements ContentUpgrade {

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

private BindingContext context = null;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Valtech GmbH
* Copyright 2018 - 2019 Valtech GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction,
Expand All @@ -22,6 +22,7 @@

import javax.annotation.Nonnull;

import org.apache.commons.lang3.StringUtils;
import org.apache.jackrabbit.JcrConstants;
import org.apache.sling.api.resource.PersistenceException;
import org.apache.sling.api.resource.Resource;
Expand Down Expand Up @@ -119,7 +120,10 @@ private void save(ResourceResolver resourceResolver) throws PersistenceException
private void runActions(@Nonnull StringBuffer stringBuffer, @Nonnull Resource resource, @Nonnull List<Action> actions)
throws PersistenceException, AecuException {
for (Action action : actions) {
stringBuffer.append(action.doAction(resource) + "\n");
String output = action.doAction(resource);
if (StringUtils.isNotBlank(output)) {
stringBuffer.append(output + "\n");
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Valtech GmbH
* Copyright 2018 - 2019 Valtech GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction,
Expand Down Expand Up @@ -54,7 +54,7 @@ public class HistoryDataSource {
private static final String ITEM_TYPE = "valtech/aecu/tools/history/dataitem";
public static final String ATTR_HISTORY = "history";

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

@SlingObject
SlingHttpServletRequest request;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Valtech GmbH
* Copyright 2018 - 2019 Valtech GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction,
Expand All @@ -18,13 +18,17 @@
*/
package de.valtech.aecu.core.omnisearch;

import java.util.regex.Pattern;

import javax.annotation.PostConstruct;

import org.apache.commons.lang3.StringUtils;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.injectorspecific.OSGiService;
import org.apache.sling.models.annotations.injectorspecific.SlingObject;
import org.apache.sling.xss.XSSAPI;

import de.valtech.aecu.api.service.ExecutionResult;
import de.valtech.aecu.api.service.HistoryEntry;
Expand All @@ -42,13 +46,18 @@ public class HistorySearchItem extends HistoryDataItem {
private static final String POST_FULLTEXT = "fulltext";
private static final String DOTS = "...";
private static final int RELATED_LENGTH = 20;
private static final String HIGHLIGHT_START = "<span class=\"aecu-highlight\">";
private static final String HIGHLIGHT_END = "</span>";

@SlingObject
private Resource resource;

@SlingObject
private SlingHttpServletRequest request;

@OSGiService
private XSSAPI xssApi;

protected String searchTerm;
private Resource entryResource;

Expand Down Expand Up @@ -129,7 +138,20 @@ private String createSnippet(String text) {
}
String prefix = (start > 0) ? DOTS : StringUtils.EMPTY;
String postfix = (end < text.length() - 3) ? DOTS : StringUtils.EMPTY;
return prefix + text.substring(start, end) + postfix;
String snippet = prefix + text.substring(start, end) + postfix;
return highlight(snippet);
}

/**
* Adds extra HTML to highlight the search term.
*
* @param snippet text snippet
* @return formatted snippet
*/
private String highlight(String snippet) {
String escapedSnippet = xssApi.encodeForHTML(snippet);
Pattern pattern = Pattern.compile("(" + Pattern.quote(searchTerm) + ")", Pattern.CASE_INSENSITIVE);
return pattern.matcher(escapedSnippet).replaceAll(HIGHLIGHT_START + "$1" + HIGHLIGHT_END);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Valtech GmbH
* Copyright 2018 - 2019 Valtech GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction,
Expand Down Expand Up @@ -153,10 +153,7 @@ public boolean isValidScriptName(String name) {
if (!name.endsWith(".groovy")) {
return false;
}
if (name.contains(".fallback.")) {
return false;
}
return true;
return !name.contains(".fallback.");
}

@Override
Expand All @@ -169,8 +166,7 @@ public ExecutionResult execute(String path) throws AecuException {
if (!isValidScriptName(resource.getName())) {
throw new AecuException("Invalid script name");
}
ExecutionResult result = executeScript(resolver, path);
return result;
return executeScript(resolver, path);
} catch (LoginException e) {
throw new AecuException(ERR_NO_RESOLVER, e);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Valtech GmbH
* Copyright 2018 - 2019 Valtech GmbH
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction,
Expand Down Expand Up @@ -372,7 +372,7 @@ public RequestParameter getRequestParameter(String arg0) {

@Override
public List<RequestParameter> getRequestParameterList() {
return Collections.EMPTY_LIST;
return Collections.emptyList();
}

@Override
Expand Down Expand Up @@ -442,7 +442,7 @@ public void logout() throws ServletException {

@Override
public Collection<Part> getParts() throws IOException, ServletException {
return Collections.EMPTY_LIST;
return Collections.emptyList();
}

@Override
Expand Down
Loading

0 comments on commit b92b7cb

Please sign in to comment.