Skip to content

Commit

Permalink
Fix compilation issues in admin-gui
Browse files Browse the repository at this point in the history
ConfigurationException thrown from resource schema factory method should
be correctly handled.

Also, a bug in SynchronizationPolicyFactory#forDefinitionBean was fixed.
  • Loading branch information
mederly committed Apr 27, 2022
1 parent d98e856 commit b5a52f8
Show file tree
Hide file tree
Showing 20 changed files with 70 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import java.util.List;
import java.util.Map;

import com.evolveum.midpoint.util.exception.ConfigurationException;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.ajax.AjaxRequestTarget;
Expand Down Expand Up @@ -192,7 +194,7 @@ protected List<String> load() {
availableIntentValues.add(def.getIntent());
}
}
} catch (SchemaException ex) {
} catch (SchemaException | ConfigurationException ex) {
LOGGER.error("Cannot get refined resource schema for resource {}. {}", selectedResource.getName().getOrig(), ex.getLocalizedMessage());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import com.evolveum.midpoint.schema.processor.ResourceSchema;
import com.evolveum.midpoint.schema.processor.ResourceSchemaFactory;

import com.evolveum.midpoint.util.exception.ConfigurationException;

import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxEventBehavior;
import org.apache.wicket.ajax.AjaxRequestTarget;
Expand Down Expand Up @@ -516,7 +518,7 @@ protected List<String> load() {
availableIntentValues.add(def.getIntent());
}
}
} catch (SchemaException ex) {
} catch (SchemaException | ConfigurationException ex) {
LOGGER.error("Cannot get refined resource schema for resource {}. {}", selectedResource.getName().getOrig(), ex.getLocalizedMessage());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ public static ObjectFilter getShadowTypeFilterForAssociation(ConstructionType co
filter.addCondition(intentFilter);
query.setFilter(filter); // TODO this overwrites existing filter (created in previous cycle iteration)... is it OK? [med]
}
} catch (SchemaException ex) {
} catch (SchemaException | ConfigurationException ex) {
LOGGER.error("Couldn't create query filter for ShadowType for association: {}", ex.getErrorTypeMessage());
}
return query.getFilter();
Expand Down Expand Up @@ -2922,7 +2922,7 @@ public static ItemVisibility checkShadowActivationAndPasswordVisibility(ItemWrap
try {
ResourceSchema resourceSchema = ResourceSchemaFactory.getCompleteSchema(resource);
ocd = ResourceObjectDefinitionResolver.getDefinitionForShadow(resourceSchema, shadowType);
} catch (SchemaException e) {
} catch (SchemaException | ConfigurationException e) {
LOGGER.error("Cannot find refined definition for {} in {}", shadowType, resource);
}
ResourceObjectTypeDefinitionType resourceObjectTypeDefinitionType =
Expand Down Expand Up @@ -3023,7 +3023,7 @@ public static boolean isAssociationSupported(ShadowType shadowType, IModel<Resou
try {
ResourceSchema resourceSchema = ResourceSchemaFactory.getCompleteSchema(resource.asPrismObject());
ocd = ResourceObjectDefinitionResolver.getDefinitionForShadow(resourceSchema, shadowType);
} catch (SchemaException e) {
} catch (SchemaException | ConfigurationException e) {
LOGGER.error("Cannot find refined definition for {} in {}", shadowType, resource);
}

Expand Down Expand Up @@ -4944,7 +4944,7 @@ public static Collection<String> getIntentsForKind(PrismObject<ResourceType> res
} else {
return List.of();
}
} catch (SchemaException e) {
} catch (SchemaException | ConfigurationException e) {
return List.of();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.task.api.Task;

import com.evolveum.midpoint.util.exception.ConfigurationException;

import org.apache.wicket.model.IModel;
import org.springframework.stereotype.Component;

Expand Down Expand Up @@ -147,7 +149,7 @@ private List<ItemName> getChoicesList(PrismPropertyPanelContext<ItemPathType> ct
Collection<? extends ResourceAttributeDefinition<?>> attrDefs = rOcd.getAttributeDefinitions();
return attrDefs.stream().map(a -> a.getItemName()).collect(Collectors.toList());

} catch (SchemaException e) {
} catch (SchemaException | ConfigurationException e) {
LOGGER.warn("Cannot get resource attribute definitions");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ private Collection<ResourceAssociationDefinition> loadRefinedAssociationDefiniti
ResourceSchema refinedResourceSchema;
try {
refinedResourceSchema = ResourceSchemaFactory.getCompleteSchema(resource);
} catch (SchemaException e) {
} catch (SchemaException | ConfigurationException e) {
LOGGER.error("Cannot get refined schema for {}, {}", resource, e.getMessage(), e);
result.recordPartialError("Could not get fined schema for " + resource, e);
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.DebugUtil;
import com.evolveum.midpoint.util.exception.ConfigurationException;
import com.evolveum.midpoint.util.exception.ExpressionEvaluationException;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.exception.SystemException;
Expand Down Expand Up @@ -111,7 +112,7 @@ private void initModels() {
Task task = getPageBase().createSimpleTask("visualize");
primaryScenes = getPageBase().getModelInteractionService().visualizeDeltas(primaryDeltas, task, task.getResult());
secondaryScenes = getPageBase().getModelInteractionService().visualizeDeltas(secondaryDeltas, task, task.getResult());
} catch (SchemaException | ExpressionEvaluationException e) {
} catch (SchemaException | ExpressionEvaluationException | ConfigurationException e) {
throw new SystemException(e); // TODO
}
if (LOGGER.isTraceEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import java.util.stream.Collectors;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.util.exception.ConfigurationException;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
Expand Down Expand Up @@ -608,7 +610,7 @@ private ShadowType createNewShadow(ResourceType resource, ResourceObjectTypeDefi
return shadow;
}

private ResourceSchema getRefinedSchema(ResourceType resource) throws SchemaException {
private ResourceSchema getRefinedSchema(ResourceType resource) throws SchemaException, ConfigurationException {
ResourceSchema refinedSchema = ResourceSchemaFactory.getCompleteSchema(resource.asPrismObject(), LayerType.PRESENTATION);
if (refinedSchema == null) {
Task task = getPageBase().createSimpleTask(FocusPersonasTabPanel.class.getSimpleName() + ".loadResource");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.evolveum.midpoint.schema.util.ConnectorTypeUtil;
import com.evolveum.midpoint.schema.util.ResourceTypeUtil;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.exception.ConfigurationException;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.exception.SystemException;
import com.evolveum.midpoint.web.page.admin.resources.PageResourceWizard;
Expand Down Expand Up @@ -124,7 +125,7 @@ public PrismContainerWrapper<ConnectorConfigurationType> getConfigurationModelOb
//
// }

public ResourceSchema getRefinedSchema() throws SchemaException {
public ResourceSchema getRefinedSchema() throws SchemaException, ConfigurationException {
return ResourceSchemaFactory.getCompleteSchema(getObjectWrapperModel().getObject().getObjectOld().asObjectable());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

import com.evolveum.midpoint.schema.util.ShadowUtil;

import com.evolveum.midpoint.util.exception.ConfigurationException;

import org.apache.wicket.AttributeModifier;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.form.OnChangeAjaxBehavior;
Expand Down Expand Up @@ -138,7 +140,7 @@ public Iterator<String> getIterator(String input) {
} else {
return Collections.emptyIterator();
}
} catch (SchemaException e) {
} catch (SchemaException | ConfigurationException e) {
return Collections.emptyIterator();
}
}
Expand Down Expand Up @@ -189,7 +191,7 @@ public String getObject() {
if (ocDef != null) {
return ocDef.getObjectClassDefinition().getTypeName().getLocalPart();
}
} catch (SchemaException e) {
} catch (SchemaException | ConfigurationException e) {
// TODO?
}

Expand Down Expand Up @@ -290,7 +292,7 @@ private List<QName> createObjectClassChoices(IModel<PrismObjectWrapper<ResourceT
ResourceSchema refinedSchema;
try {
refinedSchema = ResourceSchemaFactory.getCompleteSchema(model.getObject().getObject());
} catch (SchemaException e) {
} catch (SchemaException | ConfigurationException e) {
warn("Could not determine defined object classes for resource");
return new ArrayList<>();
}
Expand All @@ -312,10 +314,10 @@ private ResourceContentResourcePanel initResourceContent(IModel<PrismObjectWrapp
ResourceContentResourcePanel resourceContent = new ResourceContentResourcePanel(ID_TABLE, loadResourceModel(),
getObjectClass(), getKind(), getIntent(), searchMode, getPanelConfiguration()){
@Override
protected ResourceSchema getRefinedSchema() throws SchemaException {
protected ResourceSchema getRefinedSchema() throws SchemaException, ConfigurationException {
try {
return super.getRefinedSchema();
} catch (SchemaException e) {
} catch (SchemaException | ConfigurationException e) {
return getObjectDetailsModels().getRefinedSchema();
}
}
Expand All @@ -331,10 +333,10 @@ private ResourceContentRepositoryPanel initRepoContent(IModel<PrismObjectWrapper
ResourceContentRepositoryPanel repositoryContent = new ResourceContentRepositoryPanel(ID_TABLE, loadResourceModel(),
getObjectClass(), getKind(), getIntent(), searchMode, getPanelConfiguration()){
@Override
protected ResourceSchema getRefinedSchema() throws SchemaException {
protected ResourceSchema getRefinedSchema() throws SchemaException, ConfigurationException {
try {
return super.getRefinedSchema();
} catch (SchemaException e) {
} catch (SchemaException | ConfigurationException e) {
return getObjectDetailsModels().getRefinedSchema();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ private ReadOnlyModel<InfoBoxType> createSchemaStatusInfoBoxModel() {
} else {
numberMessage = getPageBase().getString("PageResource.resource.noSchema");
}
} catch (SchemaException e) {
} catch (SchemaException | ConfigurationException e) {
backgroundColor = "bg-danger";
icon = "fa fa-warning";
numberMessage = getPageBase().getString("PageResource.resource.schemaError");
Expand All @@ -413,7 +413,7 @@ private List<TaskType> getTasksFor(
List<PrismObject<TaskType>> tasks,
SynchronizationPolicy synchronizationPolicy,
PrismObject<ResourceType> resource)
throws SchemaException {
throws SchemaException, ConfigurationException {
List<TaskType> syncTasks = new ArrayList<>();
for (PrismObject<TaskType> task : tasks) {
ShadowKindType taskKindValue = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

import com.evolveum.midpoint.schema.processor.ResourceSchemaFactory;

import com.evolveum.midpoint.util.exception.ConfigurationException;

import org.apache.commons.lang3.StringUtils;

import com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper;
Expand Down Expand Up @@ -45,7 +47,7 @@ public String getResourceOid() {
return resourceOid;
}

public ResourceSchema getRefinedSchema(PrismObject<ResourceType> resource) throws SchemaException {
public ResourceSchema getRefinedSchema(PrismObject<ResourceType> resource) throws SchemaException, ConfigurationException {
if (resource != null) {
return ResourceSchemaFactory.getCompleteSchema(resource);
}
Expand All @@ -69,7 +71,7 @@ public String getIntent(PrismObject<ResourceType> resource) {
if (def instanceof ResourceObjectTypeDefinition) {
intent = ((ResourceObjectTypeDefinition) def).getIntent();
}
} catch (SchemaException e) {
} catch (SchemaException | ConfigurationException e) {
LOGGER.error("Cannot get default object class definition, {}", e.getMessage(), e);
intent = "default";
}
Expand All @@ -78,7 +80,8 @@ public String getIntent(PrismObject<ResourceType> resource) {
return intent;
}

private ResourceObjectDefinition findDefaultObjectClassDefinition(PrismObject<ResourceType> resource) throws SchemaException {
private ResourceObjectDefinition findDefaultObjectClassDefinition(PrismObject<ResourceType> resource)
throws SchemaException, ConfigurationException {
ResourceSchema schema = getRefinedSchema(resource);
if (schema == null) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

import com.evolveum.midpoint.schema.processor.ResourceSchemaFactory;

import com.evolveum.midpoint.util.exception.ConfigurationException;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.form.DropDownChoice;
import org.apache.wicket.markup.html.form.Form;
Expand Down Expand Up @@ -121,7 +123,7 @@ public String getObject() {
}
}
}
} catch (SchemaException ex) {
} catch (SchemaException | ConfigurationException ex) {
LOGGER.error("Cannot get refined resource schema for resource {}. {}", resourceModel.getObject().getName().getOrig(), ex.getLocalizedMessage());
}

Expand Down Expand Up @@ -185,7 +187,7 @@ public List<String> getObject() {
}
}
}
} catch (SchemaException ex) {
} catch (SchemaException | ConfigurationException ex) {
LOGGER.error("Cannot get refined resource schema for resource {}. {}", resourceModel.getObject().getName().getOrig(), ex.getLocalizedMessage());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import java.util.ArrayList;
import java.util.List;

import com.evolveum.midpoint.util.exception.ConfigurationException;

import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.markup.html.form.IChoiceRenderer;
import org.apache.wicket.model.IModel;
Expand Down Expand Up @@ -36,7 +38,7 @@ public List<? extends ResourceObjectTypeDefinition> getObject() {
ResourceSchema refinedSchema;
try {
refinedSchema = ResourceSchemaFactory.getCompleteSchema(resourceModel.getObject());
} catch (SchemaException e) {
} catch (SchemaException | ConfigurationException e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
return new ArrayList<>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.evolveum.midpoint.prism.path.ItemPath;

import com.evolveum.midpoint.util.exception.ConfigurationException;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType;

import org.apache.wicket.markup.html.WebMarkupContainer;
Expand Down Expand Up @@ -117,7 +118,7 @@ private void initModels() {
Task task = getPageBase().createSimpleTask("visualize");
primaryScenes = getPageBase().getModelInteractionService().visualizeDeltas(primaryDeltas, task, task.getResult());
secondaryScenes = getPageBase().getModelInteractionService().visualizeDeltas(secondaryDeltas, task, task.getResult());
} catch (SchemaException | ExpressionEvaluationException e) {
} catch (SchemaException | ExpressionEvaluationException | ConfigurationException e) {
throw new SystemException(e); // TODO
}
if (LOGGER.isTraceEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.evolveum.midpoint.schema.processor.ResourceSchema;
import com.evolveum.midpoint.schema.processor.ResourceSchemaFactory;
import com.evolveum.midpoint.schema.util.ResourceTypeUtil;
import com.evolveum.midpoint.util.exception.ConfigurationException;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.logging.LoggingUtils;
import com.evolveum.midpoint.util.logging.Trace;
Expand Down Expand Up @@ -350,7 +351,7 @@ private ResourceSchema loadResourceSchema() {
}

return ResourceSchemaFactory.getCompleteSchema(resource);
} catch (SchemaException|RuntimeException ex) {
} catch (SchemaException|RuntimeException|ConfigurationException ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't parse resource schema.", ex);
getSession().error(getString("SchemaListPanel.message.couldntParseSchema") + " " + ex.getMessage());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public QName getObjectClass() {
return objectClass;
}

public ResourceObjectDefinition getDefinitionByKind() throws SchemaException {
public ResourceObjectDefinition getDefinitionByKind() throws SchemaException, ConfigurationException {
ResourceSchema refinedSchema = getRefinedSchema();
if (refinedSchema == null) {
warn("No schema found in resource. Please check your configuration and try to test connection for the resource.");
Expand All @@ -178,7 +178,7 @@ public ResourceObjectDefinition getDefinitionByKind() throws SchemaException {
}
}

public ResourceObjectDefinition getDefinitionByObjectClass() throws SchemaException {
public ResourceObjectDefinition getDefinitionByObjectClass() throws SchemaException, ConfigurationException {
ResourceSchema refinedSchema = getRefinedSchema();
if (refinedSchema == null) {
warn("No schema found in resource. Please check your configuration and try to test connection for the resource.");
Expand All @@ -188,7 +188,7 @@ public ResourceObjectDefinition getDefinitionByObjectClass() throws SchemaExcept

}

protected ResourceSchema getRefinedSchema() throws SchemaException {
protected ResourceSchema getRefinedSchema() throws SchemaException, ConfigurationException {
return ResourceSchemaFactory.getCompleteSchema(resourceModel.getObject());
}

Expand Down Expand Up @@ -471,7 +471,7 @@ private List<TaskType> getTasksForKind(List<PrismObject<TaskType>> tasks) {
ResourceObjectDefinition objectClassDef = null;
try {
objectClassDef = getDefinitionByKind();
} catch (SchemaException e) {
} catch (SchemaException | ConfigurationException e) {
LOGGER.error("Failed to search for objectClass definition. Reason: {}", e.getMessage(), e);
}
if (objectClassDef == null) {
Expand Down Expand Up @@ -521,7 +521,7 @@ protected ObjectQuery createQuery() {
if (rOcDef != null) {
baseQuery = rOcDef.createShadowSearchQuery(resourceModel.getObject().getOid());
}
} catch (SchemaException ex) {
} catch (SchemaException | ConfigurationException ex) {
LoggingUtils.logUnexpectedException(LOGGER,
"Could not crate query for shadows: " + ex.getMessage(), ex);
}
Expand Down

0 comments on commit b5a52f8

Please sign in to comment.