Skip to content

Commit

Permalink
ObjectRetriever: removed duplicate validateObjectType() call
Browse files Browse the repository at this point in the history
It is called in updateLoadedObject() called just before removed line.
  • Loading branch information
virgo47 committed Nov 8, 2021
1 parent 7d71684 commit 5a5fdb0
Showing 1 changed file with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import com.evolveum.prism.xml.ns._public.types_3.PolyStringType;

/**
* @author lazyman, mederly
*/
@Component
public class ObjectRetriever {

Expand Down Expand Up @@ -195,7 +192,6 @@ public <T extends ObjectType> PrismObject<T> getObjectInternal(Session session,

LOGGER.trace("Transforming data to JAXB type.");
PrismObject<T> prismObject = updateLoadedObject(fullObject, type, oid, options, null, session);
validateObjectType(prismObject, type);

// this was implemented to allow report parsing errors as warnings to upper layers;
// however, it causes problems when serialization problems are encountered: in such cases, we put
Expand Down Expand Up @@ -246,7 +242,7 @@ public <F extends FocusType> PrismObject<F> searchShadowOwnerAttempt(String shad

session.getTransaction().commit();

} catch (SchemaException | RuntimeException ex) {
} catch (SchemaException | RuntimeException | ObjectNotFoundException ex) {
baseHelper.handleGeneralException(ex, session, result);
} finally {
baseHelper.cleanupSessionAndResult(session, result);
Expand Down Expand Up @@ -491,7 +487,7 @@ private <C extends Containerable> void processAssignmentsQuery(List<C> list, RQu
*/
private <T extends ObjectType> PrismObject<T> updateLoadedObject(GetObjectResult result,
Class<T> type, String oid, Collection<SelectorOptions<GetOperationOptions>> options,
Holder<PrismObject<T>> partialValueHolder, Session session) throws SchemaException {
Holder<PrismObject<T>> partialValueHolder, Session session) throws SchemaException, ObjectNotFoundException {

GetOperationOptions rootOptions = SelectorOptions.findRootOptions(options);
boolean raw = GetOperationOptions.isRaw(rootOptions);
Expand Down Expand Up @@ -768,11 +764,11 @@ private MutableItemDefinition<?> createDynamicDefinition(RExtItem extItem, ItemN
}

private <T extends ObjectType> void validateObjectType(PrismObject<T> prismObject, Class<T> type)
throws SchemaException {
throws ObjectNotFoundException {
if (prismObject == null || !type.isAssignableFrom(prismObject.getCompileTimeClass())) {
throw new SchemaException("Expected to find '" + type.getSimpleName() + "' but found '"
throw new ObjectNotFoundException("Expected to find '" + type.getSimpleName() + "' but found '"
+ prismObject.getCompileTimeClass().getSimpleName() + "' (" + prismObject.toDebugName()
+ "). Bad OID in a reference?");
+ "). Bad OID in a reference?", prismObject.getOid());
}
if (InternalsConfig.consistencyChecks) {
prismObject.checkConsistence();
Expand Down Expand Up @@ -849,7 +845,7 @@ public <T extends ObjectType> void searchObjectsIterativeAttempt(Class<T> type,
}

session.getTransaction().commit();
} catch (SchemaException | QueryException | RuntimeException ex) {
} catch (SchemaException | QueryException | RuntimeException | ObjectNotFoundException ex) {
baseHelper.handleGeneralException(ex, session, result);
} finally {
baseHelper.cleanupSessionAndResult(session, result);
Expand Down

0 comments on commit 5a5fdb0

Please sign in to comment.