Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
skublik committed Oct 3, 2023
2 parents 34562a5 + 13b3dc3 commit f2199eb
Show file tree
Hide file tree
Showing 14 changed files with 130 additions and 38 deletions.
22 changes: 11 additions & 11 deletions dist/src/main/bin/ninja.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ BASE_DIR=$(cd "${SCRIPT_DIR}/.." && pwd -P)
: "${MIDPOINT_HOME:="${BASE_DIR}/var"}"

if [[ ! -f "${BASE_DIR}/lib/ninja.jar" ]]; then
echo "ERROR: ninja.jar not found in ${BASE_DIR}/lib directory"
echo "ERROR: ninja.jar not found in ${BASE_DIR}/lib directory" >&2
exit 1
fi

Expand All @@ -33,14 +33,14 @@ ENV_UNMAP_PREFIX="MP_UNSET_"
# Apply bin/setenv.sh if it exists. This setenv.sh does not depend on MIDPOINT_HOME.
# The script can either append or overwrite JAVA_OPTS, e.g. to set -Dmidpoint.nodeId.
if [[ -r "${SCRIPT_DIR}/setenv.sh" ]]; then
echo "Applying setenv.sh from ${SCRIPT_DIR} directory."
echo "Applying setenv.sh from ${SCRIPT_DIR} directory." >&2
# shellcheck disable=SC1091
. "${SCRIPT_DIR}/setenv.sh"
fi

# Apply $MIDPOINT_HOME/setenv.sh if it exists. This is flexible and related to chosen MIDPOINT_HOME.
if [[ -r "${MIDPOINT_HOME}/setenv.sh" ]]; then
echo "Applying setenv.sh from ${MIDPOINT_HOME} directory."
echo "Applying setenv.sh from ${MIDPOINT_HOME} directory." >&2
# shellcheck disable=SC1091
. "${MIDPOINT_HOME}/setenv.sh"
fi
Expand All @@ -55,20 +55,20 @@ fi

if [ "${MP_ENTRY_POINT:-}" != "" ]; then # /opt/midpoint-dirs-docker-entrypoint
if [ -e "${MP_ENTRY_POINT}" ]; then
echo "Processing ${MP_ENTRY_POINT} directory..."
echo "Processing ${MP_ENTRY_POINT} directory..." >&2
for i in $(find "${MP_ENTRY_POINT}" -mindepth 1 -maxdepth 1 -type d); do
l_name="$(basename "${i}")"
[ ! -e "${MIDPOINT_HOME}/${l_name}" ] && mkdir -p "${MIDPOINT_HOME}/${l_name}"
for s in $(find "${i}" -mindepth 1 -maxdepth 1 -type f -follow -exec basename \{\} \;); do
if [ ! -e "${MIDPOINT_HOME}/${l_name}/${s}" -a ! -e "${MIDPOINT_HOME}/${l_name}/${s}.done" ]; then
echo "COPY ${i}/${s} => ${MIDPOINT_HOME}/${l_name}/${s}"
echo "COPY ${i}/${s} => ${MIDPOINT_HOME}/${l_name}/${s}" >&2
cp "${i}/${s}" "${MIDPOINT_HOME}/${l_name}/${s}"
else
echo "SKIP: ${i}/${s}"
echo "SKIP: ${i}/${s}" >&2
fi
done
done
echo "- - - - - - - - - - - - - - - - - - - - -"
echo "- - - - - - - - - - - - - - - - - - - - -" >&2
unset l_name
fi
fi
Expand Down Expand Up @@ -108,7 +108,7 @@ if [ "${MP_NO_ENV_COMPAT:-}" != "1" ]; then
;;
*)
if [ "${db_port:-}" == "" -a "${REPO_URL:-}" == "" ]; then
echo "~~~~~ please supply JDBC port for your repository ~~~~~"
echo "~~~~~ please supply JDBC port for your repository ~~~~~" >&2
exit 1
fi
;;
Expand Down Expand Up @@ -142,7 +142,7 @@ while read line; do
[ "${_key: -5}" = ".FILE" ] && _key="${_key::$((${#_key} - 5))}_FILE"
###

echo "Processing variable (MAP) ... ${_key} .:. ${_val}"
echo "Processing variable (MAP) ... ${_key} .:. ${_val}" >&2

if [ "${_key:0:1}" = "." ]; then
JAVA_OPTS="${JAVA_OPTS:-} -D${_key:1}=\"${_val}\""
Expand All @@ -160,7 +160,7 @@ while read line; do
[ "${_key: -5}" = ".FILE" ] && _key="${_key::$((${#_key} - 5))}_FILE"
###

echo "Processing variable (UNMAP) ... ${_key} .:. ${_val}"
echo "Processing variable (UNMAP) ... ${_key} .:. ${_val}" >&2

JAVA_OPTS="$(echo -n "${JAVA_OPTS:-}" | sed "s/ -D${_key}=\"[^\"]*\"//g;s/ -D${_key}=[^[:space:]]*//g")"
done < <(env | grep "^${ENV_UNMAP_PREFIX}")
Expand Down Expand Up @@ -210,7 +210,7 @@ done
# Technically we could do one exec, but then we can't quote -Dloader.path argument, because it
# would be empty and considered a class name by the "java -jar" command.
if [ -n "${JDBC_DRIVER:-}" ]; then
echo "Using JDBC driver path: ${JDBC_DRIVER}"
echo "Using JDBC driver path: ${JDBC_DRIVER}" >&2
eval "${_RUNJAVA}" ${JAVA_OPTS} "-Dloader.path=${JDBC_DRIVER}" -jar "${BASE_DIR}/lib/ninja.jar" -m "${MIDPOINT_HOME}" "$@"
else
eval "${_RUNJAVA}" ${JAVA_OPTS} -jar "${BASE_DIR}/lib/ninja.jar" -m "${MIDPOINT_HOME}" "$@"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@
import javax.xml.namespace.QName;

import com.evolveum.midpoint.gui.api.page.PageAdminLTE;
import com.evolveum.midpoint.prism.impl.query.OrFilterImpl;
import com.evolveum.midpoint.prism.query.AndFilter;
import com.evolveum.midpoint.schema.util.ObjectQueryUtil;
import com.evolveum.midpoint.util.QNameUtil;
import com.evolveum.prism.xml.ns._public.query_3.SearchFilterType;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;

import com.evolveum.midpoint.gui.api.page.PageBase;
Expand Down Expand Up @@ -252,9 +255,40 @@ public ObjectQuery createObjectQuery(VariablesMap variables, PageBase pageBase,
// }
query = mergeQueries(query, customizeContentQuery);
LOGGER.debug("Created query: {}", query);

ObjectFilter allowedSearchTypesFilter = createAllowedSearchTypesFilter(pageBase);
if (allowedSearchTypesFilter != null) {
query.addFilter(allowedSearchTypesFilter);
}

return query;
}

private ObjectFilter createAllowedSearchTypesFilter(PageBase pageBase) {
if (!isSearchTypeAvailable()) {
List<ObjectFilter> typeFilters = new ArrayList<>();
type.getAvailableValues()
.forEach(t -> {
Class cl = WebComponentUtil.qnameToClass(pageBase.getPrismContext(), t);
typeFilters.add(PrismContext.get().queryFor(cl).type(t).buildFilter());
});
return OrFilterImpl.createOr(typeFilters);

}
return null;
}

private boolean isSearchTypeAvailable() {
if (type != null && CollectionUtils.isNotEmpty(type.getAvailableValues())) {
Class<? extends ObjectType> searchTypeClass = (Class<? extends ObjectType>) getTypeClass();
QName typeQname = WebComponentUtil.classToQName(searchTypeClass);
return type.getAvailableValues()
.stream()
.anyMatch(t -> QNameUtil.match(typeQname, t));
}
return true;
}

private QueryWrapper determineQueryWrapper() {
SearchBoxModeType searchMode = getSearchMode();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public class PageRoleAnalysis extends PageAdmin {
private static final String DOT_CLASS = PageRoleAnalysis.class.getName() + ".";
private static final String OP_DELETE_SESSION = DOT_CLASS + "deleteSession";
private static final String ID_MAIN_FORM = "mainForm";
private static final String ID_CHART_PANEL = "chartPanel";
private static final String ID_TABLE = "table";

public PageRoleAnalysis(PageParameters params) {
Expand All @@ -91,10 +92,6 @@ public PageRoleAnalysis(PageParameters params) {
protected void onInitialize() {
super.onInitialize();
initLayout();

RoleAnalysisChartPanel roleAnalysisChartPanel = new RoleAnalysisChartPanel("chartPanel");
roleAnalysisChartPanel.setOutputMarkupId(true);
add(roleAnalysisChartPanel);
}

private InlineMenuItem createDeleteInlineMenu() {
Expand Down Expand Up @@ -154,15 +151,19 @@ public IModel<String> getConfirmationMessageModel() {
}

protected void initLayout() {

Form<?> mainForm = new MidpointForm<>(ID_MAIN_FORM);
add(mainForm);

if (!isNativeRepo()) {
mainForm.add(new ErrorPanel(ID_TABLE,
() -> getString("PageRoleAnalysis.menu.nonNativeRepositoryWarning")));
mainForm.add(new ErrorPanel(ID_TABLE, createStringResource("RoleAnalysis.menu.nonNativeRepositoryWarning")));
add(new EmptyPanel(ID_CHART_PANEL));
return;
}

RoleAnalysisChartPanel roleAnalysisChartPanel = new RoleAnalysisChartPanel(ID_CHART_PANEL);
roleAnalysisChartPanel.setOutputMarkupId(true);
add(roleAnalysisChartPanel);

MainObjectListPanel<RoleAnalysisSessionType> table = new MainObjectListPanel<>(ID_TABLE, RoleAnalysisSessionType.class) {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.apache.wicket.markup.repeater.RepeatingView;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.StringResourceModel;
import org.apache.wicket.util.string.StringValue;

import com.evolveum.midpoint.authentication.api.authorization.AuthorizationAction;
import com.evolveum.midpoint.authentication.api.authorization.PageDescriptor;
Expand All @@ -30,6 +31,7 @@
import com.evolveum.midpoint.gui.impl.component.icon.LayeredIconCssStyle;
import com.evolveum.midpoint.gui.impl.component.wizard.AbstractWizardPanel;
import com.evolveum.midpoint.gui.impl.component.wizard.WizardPanelHelper;
import com.evolveum.midpoint.gui.impl.error.ErrorPanel;
import com.evolveum.midpoint.gui.impl.page.admin.DetailsFragment;
import com.evolveum.midpoint.gui.impl.page.admin.assignmentholder.AssignmentHolderDetailsModel;
import com.evolveum.midpoint.gui.impl.page.admin.assignmentholder.PageAssignmentHolderDetails;
Expand All @@ -45,8 +47,6 @@
import com.evolveum.midpoint.web.util.OnePageParameterEncoder;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

import org.apache.wicket.util.string.StringValue;

//TODO correct authorizations
@PageDescriptor(
urls = {
Expand Down Expand Up @@ -212,6 +212,15 @@ private boolean canShowWizard() {
}

protected DetailsFragment createDetailsFragment() {
if (!isNativeRepo()) {
return new DetailsFragment(ID_DETAILS_VIEW, ID_TEMPLATE_VIEW, PageRoleAnalysisSession.this) {
@Override
protected void initFragmentLayout() {
add(new ErrorPanel(ID_TEMPLATE,
createStringResource("RoleAnalysis.menu.nonNativeRepositoryWarning")));
}
};
}

if (canShowWizard()) {
setShowedByWizard(true);
Expand Down Expand Up @@ -271,7 +280,7 @@ protected void initFragmentLayout() {
Constructor<? extends AbstractWizardPanel> constructor = clazz.getConstructor(String.class, WizardPanelHelper.class);
AbstractWizardPanel wizard = constructor.newInstance(ID_TEMPLATE, createObjectWizardPanelHelper());
add(wizard);
} catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) {
} catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException ignored) {

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ private void useInObjectListPerformed(AjaxRequestTarget target) {
} catch (Exception e) {
result.recordFatalError(getString("PageRepositoryQuery.message.couldNotParseQuery", e.getMessage()), e);
showResult(result);
target.add(getFeedbackPanel());
target.add(this);
}
}
Expand Down Expand Up @@ -510,6 +511,7 @@ private void queryPerformed(QueryPlaygroundPanel.Action action, AjaxRequestTarge
}

showResult(result);
target.add(getFeedbackPanel());
target.add(this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
package com.evolveum.midpoint.web.page.admin.reports;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
Expand Down Expand Up @@ -330,6 +331,9 @@ public IModel<List<ObjectReferenceType>> extractDataModel(IModel<SelectableBean<
}

private void resolveReportTypeName(ObjectReferenceType reportRef) {
if (reportRef == null) {
return;
}
if (reportRef.getTargetName() != null && StringUtils.isNotEmpty(reportRef.getTargetName().getOrig())) {
return;
}
Expand Down Expand Up @@ -638,17 +642,16 @@ private String getReportFileName() {

public static String getReportFileName(ReportDataType currentReport) {
try {
OperationResult result = new OperationResult(OPERATION_GET_REPORT_FILENAME);
// ReportOutputType reportOutput = WebModelServiceUtils.loadObject(ReportOutputType.class, currentReport.getOid(), getPageBase(),
// null, result).asObjectable();
String fileName = currentReport.getFilePath();
if (fileName.contains("/")) {
fileName = fileName.substring(fileName.lastIndexOf("/") + 1);
String filePath = currentReport.getFilePath();
if (filePath != null) {
var fileName = new File(filePath).getName();
if (StringUtils.isNotEmpty(fileName)) {
return fileName;
}
}
return fileName;
} catch (Exception ex) {
//nothing to do
} catch (RuntimeException ex) {
// ignored
}
return null;
return "report"; // A fallback - this should not really occur
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1393,8 +1393,8 @@ private static void setExtensionItemRealValues(PrismContainerValue<?> parent, Ex
// return getExtensionItemRealValue(parent.asPrismContainerValue(), name);
// }

public static <T> T getExtensionItemRealValue(PrismContainerValue<?> parent, ItemName name) {
Item<?, ?> item = parent.findItem(ItemPath.create(ObjectType.F_EXTENSION, name));
public static <T> T getExtensionItemRealValue(PrismContainerValue<?> parent, ItemPath path) {
Item<?, ?> item = parent.findItem(ItemPath.create(ObjectType.F_EXTENSION, path));
if (item != null) {
//noinspection unchecked
return (T) item.getRealValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public ModuleAuthenticationImpl clone() {
}

public void setCorrelators(List<CorrelationModuleConfigurationType> correlators) {
this.correlators = correlators;
this.correlators = new ArrayList<>(correlators);
sortCorrelators();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1316,6 +1316,9 @@ Object executeAdHocProvisioningScript(String resourceOid, String language, Strin
*/
Boolean isEvaluateNew();

/** Just a convenience method to allow writing `midpoint.evaluateNew` even after Groovy upgrade in 4.8. */
Boolean getEvaluateNew();

/**
* Returns all non-negative values from all focus mappings (targeted to given path)
* from all non-negative evaluated assignments.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2082,6 +2082,11 @@ public Boolean isEvaluateNew() {
return scriptContext.isEvaluateNew();
}

@Override
public Boolean getEvaluateNew() {
return isEvaluateNew();
}

@Override
@NotNull
public Collection<PrismValue> collectAssignedFocusMappingsResults(@NotNull ItemPath path) throws SchemaException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.query.ObjectFilter;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.provisioning.api.LiveSyncEventHandler;
import com.evolveum.midpoint.provisioning.api.LiveSyncOptions;
Expand Down Expand Up @@ -189,6 +190,17 @@ public String toString() {
return new PostSearchFilterImpl();
}

public @NotNull ObjectFilter getKindIntentFilter() {
var builder = PrismContext.get().queryFor(ShadowType.class).all();
if (kind != null) {
builder = builder.and().item(ShadowType.F_KIND).eq(kind);
}
if (intent != null) {
builder = builder.and().item(ShadowType.F_INTENT).eq(intent);
}
return builder.buildFilter();
}

public String getContextDescription() {
return String.valueOf(resource); // TODO something more human friendly
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ public void customizeQuery(@NotNull SearchSpecification<ShadowType> searchSpecif
ShadowType.F_FULL_SYNCHRONIZATION_TIMESTAMP :
ShadowType.F_SYNCHRONIZATION_TIMESTAMP;

// TODO maybe we should filter on kind/intent here as well, and not rely on objectsFilter?
searchSpecification.setQuery(
getBeans().prismContext.queryFor(ShadowType.class)
.block()
Expand All @@ -97,6 +96,7 @@ public void customizeQuery(@NotNull SearchSpecification<ShadowType> searchSpecif
.endBlock()
.and().item(ShadowType.F_RESOURCE_REF).ref(processingScope.getResourceOid())
.and().item(ShadowType.F_OBJECT_CLASS).eq(processingScope.getResolvedObjectClassName())
.and().filter(processingScope.getKindIntentFilter())
.build());
}

Expand Down

0 comments on commit f2199eb

Please sign in to comment.