protected <U> U unwrapProxy(U proxy, java.lang.Class<U> proxyInterface) { return ModificationProxy.unwrap(proxy); }; }
public static <T> T unwrap(T obj) { return ModificationProxy.unwrap(obj); }
public static <T> T unwrap(T obj) { return ModificationProxy.unwrap(obj); }
/** Reattaches a serialized {@link StoreInfo} to the catalog */ public void attach(StoreInfo storeInfo) { storeInfo = ModificationProxy.unwrap(storeInfo); ((StoreInfoImpl) storeInfo).setCatalog(catalog); }
/** Reattaches a serialized {@link StyleInfo} to the catalog */ public void attach(StyleInfo styleInfo) { styleInfo = ModificationProxy.unwrap(styleInfo); ((StyleInfoImpl) styleInfo).setCatalog(catalog); }
/** Reattaches a serialized {@link ResourceInfo} to the catalog */ public void attach(ResourceInfo resourceInfo) { resourceInfo = ModificationProxy.unwrap(resourceInfo); ((ResourceInfoImpl) resourceInfo).setCatalog(catalog); }
/** * Generates a warning log if the Info object is already wrapped with a Secured decorator. This * method is only intended to log a situation where a Catalog Info object is being secured, but * is already secured. Repeated calls to this will keep adding additional wrapper layers and may * eventually cause a StackOverflowError. The log generated is merely to aid in finding the real * issue, as opposed to masking it here. * * @param object {@link CoverageInfo} to check. * @return The original object to be checked. */ private CoverageInfo logIfSecured(CoverageInfo object) { CoverageInfo unwrapped = ModificationProxy.unwrap(object); if (unwrapped instanceof SecuredDataStoreInfo) { logDoubleWrap(unwrapped, object); } return object; }
/** * Generates a warning log if the Info object is already wrapped with a Secured decorator. This * method is only intended to log a situation where a Catalog Info object is being secured, but * is already secured. Repeated calls to this will keep adding additional wrapper layers and may * eventually cause a StackOverflowError. The log generated is merely to aid in finding the real * issue, as opposed to masking it here. * * @param object {@link FeatureTypeInfo} to check. * @return The original object to be checked. */ private FeatureTypeInfo logIfSecured(FeatureTypeInfo object) { FeatureTypeInfo unwrapped = ModificationProxy.unwrap(object); if (unwrapped instanceof SecuredFeatureTypeInfo) { logDoubleWrap(unwrapped, object); } return object; }
/** * Generates a warning log if the Info object is already wrapped with a Secured decorator. This * method is only intended to log a situation where a Catalog Info object is being secured, but * is already secured. Repeated calls to this will keep adding additional wrapper layers and may * eventually cause a StackOverflowError. The log generated is merely to aid in finding the real * issue, as opposed to masking it here. * * @param object {@link WMSLayerInfo} to check. * @return The original object to be checked. */ private WMSLayerInfo logIfSecured(WMSLayerInfo object) { WMSLayerInfo unwrapped = ModificationProxy.unwrap(object); if (unwrapped instanceof SecuredWMSLayerInfo) { logDoubleWrap(unwrapped, object); } return object; }
/** * Generates a warning log if the Info object is already wrapped with a Secured decorator. This * method is only intended to log a situation where a Catalog Info object is being secured, but * is already secured. Repeated calls to this will keep adding additional wrapper layers and may * eventually cause a StackOverflowError. The log generated is merely to aid in finding the real * issue, as opposed to masking it here. * * @param object {@link LayerInfo} to check. * @return The original object to be checked. */ private LayerInfo logIfSecured(LayerInfo object) { LayerInfo unwrapped = ModificationProxy.unwrap(object); if (unwrapped instanceof SecuredLayerInfo) { logDoubleWrap(unwrapped, object); } return object; }
/** * Generates a warning log if the Info object is already wrapped with a Secured decorator. This * method is only intended to log a situation where a Catalog Info object is being secured, but * is already secured. Repeated calls to this will keep adding additional wrapper layers and may * eventually cause a StackOverflowError. The log generated is merely to aid in finding the real * issue, as opposed to masking it here. * * @param object {@link DataStoreInfo} to check. * @return The original object to be checked. */ private DataStoreInfo logIfSecured(DataStoreInfo object) { DataStoreInfo unwrapped = ModificationProxy.unwrap(object); if (unwrapped instanceof SecuredDataStoreInfo) { logDoubleWrap(unwrapped, object); } return object; } }
/** * Generates a warning log if the Info object is already wrapped with a Secured decorator. This * method is only intended to log a situation where a Catalog Info object is being secured, but * is already secured. Repeated calls to this will keep adding additional wrapper layers and may * eventually cause a StackOverflowError. The log generated is merely to aid in finding the real * issue, as opposed to masking it here. * * @param object {@link WMTSLayerInfo} to check. * @return The original object to be checked. */ private WMTSLayerInfo logIfSecured(WMTSLayerInfo object) { WMTSLayerInfo unwrapped = ModificationProxy.unwrap(object); if (unwrapped instanceof SecuredWMTSLayerInfo) { logDoubleWrap(unwrapped, object); } return object; }
/** * Generates a warning log if the Info object is already wrapped with a Secured decorator. This * method is only intended to log a situation where a Catalog Info object is being secured, but * is already secured. Repeated calls to this will keep adding additional wrapper layers and may * eventually cause a StackOverflowError. The log generated is merely to aid in finding the real * issue, as opposed to masking it here. * * @param object {@link CoverageStoreInfo} to check. * @return The original object to be checked. */ private CoverageStoreInfo logIfSecured(CoverageStoreInfo object) { CoverageStoreInfo unwrapped = ModificationProxy.unwrap(object); if (unwrapped instanceof SecuredCoverageStoreInfo) { logDoubleWrap(unwrapped, object); } return object; }
private Collection cloneCollection(Collection oldCollection) { Class<? extends Collection> oldCollectionClass = oldCollection.getClass(); try { Collection clone = oldCollectionClass.newInstance(); for (Object o : oldCollection) { if (o instanceof CatalogInfo) { CatalogInfo replacement = replaceCatalogInfo((CatalogInfo) o); if (replacement != null) { clone.add(unwrap(replacement)); } else { clone.add(o); } } else { clone.add(o); } } return clone; } catch (Exception e) { throw new RuntimeException( "Unexpected failure while cloning collection of class " + oldCollectionClass, e); } }
private static Set<String> fullTextProperties(Info obj) { Set<String> props = ImmutableSet.of(); if (obj != null) { Class<?> clazz = ModificationProxy.unwrap(obj).getClass(); ClassMappings classMappings = ClassMappings.fromImpl(clazz); checkState( classMappings != null, "No class mappings found for class " + clazz.getName()); Class<?> interf = classMappings.getInterface(); props = fullTextProperties(interf); } return props; }
/** * Helper method that removes from a list the catalog objects not visible in the current * context. This method takes care of the proper modification proxy unwrapping \ wrapping. * * @param objects list of catalog object, wrapped with a modification proxy * @param type the class of the list objects * @param filter filter that checks if an element should be visible * @return a list wrapped with a modification proxy that contains the visible catalog objects */ private <T extends CatalogInfo> List<T> filterIsolated( List<T> objects, Class<T> type, Function<T, T> filter) { // unwrap the catalog objects list List<T> unwrapped = ModificationProxy.unwrap(objects); // filter the non visible catalog objects and wrap the resulting list with a modification // proxy return ModificationProxy.createList( unwrapped .stream() .filter(store -> filter.apply(store) != null) .collect(Collectors.toList()), type); }
protected void beforeSaved( CatalogInfo object, List propertyNames, List oldValues, List newValues) { CatalogInfo real = ModificationProxy.unwrap(object); // TODO: protect this original object, perhaps with another proxy getCatalog().fireModified(real, propertyNames, oldValues, newValues); }
protected void afterSaved( CatalogInfo object, List propertyNames, List oldValues, List newValues) { CatalogInfo real = ModificationProxy.unwrap(object); // fire the post modify event getCatalog().firePostModified(real, propertyNames, oldValues, newValues); }
List<String> getDirtyProperties() { List<String> propertyNames = new ArrayList<String>(); for (String propertyName : properties().keySet()) { // in the case this property is another proxy, check that it is actually dirty Object value = properties.get(propertyName); if (value instanceof Proxy) { ModificationProxy h = handler(value); if (h != null && !h.isDirty()) { // proxy reports it is not dirty, only return this property if the underling // value is not the same as the current value of the property on the object Object curr = unwrap(value); try { Object orig = unwrap(getter(propertyName).invoke(proxyObject, null)); if (curr == orig) { continue; } } catch (Exception e) { throw new RuntimeException(e); } } } propertyNames.add(propertyName); } return propertyNames; }
/** Flag which indicates whether any properties of the object being proxied are changed. */ public boolean isDirty() { boolean dirty = false; for (Iterator i = properties().entrySet().iterator(); i.hasNext() && !dirty; ) { Map.Entry e = (Map.Entry) i.next(); if (e.getValue() instanceof Proxy) { ModificationProxy h = handler(e.getValue()); if (h != null && !h.isDirty()) { continue; } } else { try { Object orig = unwrap(getter((String) e.getKey()).invoke(proxyObject, null)); if (orig == null) { if (e.getValue() == null) { continue; } } else if (e.getValue() != null && orig.equals(e.getValue())) { continue; } } catch (Exception ex) { throw new RuntimeException(ex); } } dirty = true; } return dirty; }