public boolean supportsLocalMode() { return siteConfiguration.getCacheStrategy() == CacheStrategy.all && cache != null; }
public String getId() { return siteConfiguration.getId(); }
@Override public String toString() { return siteConfiguration != null ? siteConfiguration.getName() : null; }
if(config.getAccessUri() != null && config.getEntityDereferencerType() != null && dereferencerComponentInstance == null){ log.debug(" ... EntityDereference not available"); valid = false; if(config.getQueryUri() != null && config.getEntitySearcherType() != null && searcherComponentInstance == null){ log.debug(" ... EntitySearcher not available"); valid = false; if(config.getCacheStrategy() != CacheStrategy.none && cache == null){ log.debug(" ... Local Cache not available"); valid = false; if(config.getCacheStrategy() != CacheStrategy.all && offlineMode != null){ log.debug(" ... Offline Mode is active and CacheStrategy != ALL"); log.info(" - register ReferencedSite '{}'",config.getId()); try { referencedSite = new ReferencedSiteImpl(config,
@Override public QueryResultList<Representation> find(FieldQuery query) throws SiteException { if (siteConfiguration.getCacheStrategy() == CacheStrategy.all) { try { return cache.find(query); } catch (YardException e) { if (entitySearcher == null) { throw new SiteException("Unable to execute query on Cache " + siteConfiguration.getCacheId(), e); } else { log.warn( String.format( "Error while performing query on Cache %s! Try to use remote site %s as fallback!", siteConfiguration.getCacheId(), siteConfiguration.getQueryUri()), e); } } } if (entitySearcher == null) { throw new SiteException(String.format("ReferencedSite %s does not support queries!", getId())); } try { return entitySearcher.find(query); } catch (IOException e) { throw new SiteException("Unable execute Query on remote site " + siteConfiguration.getQueryUri(), e); } }
rep = cache.getRepresentation(id); if (rep == null){ if(siteConfiguration.getCacheStrategy() == CacheStrategy.all) { return null; // do no remote lookups on CacheStrategy.all!! if (dereferencer == null) { throw new SiteException(String.format("Unable to get Represetnation %s form Cache %s", id, siteConfiguration.getCacheId()), e); } else { log.warn( String.format( "Unable to get Represetnation %s form Cache %s. Will dereference from remote site %s", id, siteConfiguration.getCacheId(), siteConfiguration.getAccessUri()), e); throw new SiteException(String.format( "Unable to load Representation for entity %s form remote site %s with dereferencer %s", id, siteConfiguration.getAccessUri(), siteConfiguration.getEntityDereferencerType()), e); log.warn(String.format( "Unable to cache Represetnation %s in Cache %s! Representation not cached!", id, siteConfiguration.getCacheId()), e);
@Override public QueryResultList<Entity> findEntities(FieldQuery query) throws SiteException { List<Entity> results; if (siteConfiguration.getCacheStrategy() == CacheStrategy.all) { try { if (entitySearcher == null) { throw new SiteException("Unable to execute query on Cache " + siteConfiguration.getCacheId(), e); } else { log.warn( String.format( "Error while performing query on Cache %s! Try to use remote site %s as fallback!", siteConfiguration.getCacheId(), siteConfiguration.getQueryUri()), e); throw new SiteException(String.format( "Unable to execute query on remote site %s with entitySearcher %s!", siteConfiguration.getQueryUri(), siteConfiguration.getEntitySearcherType()), e);
if(refConfig.getCacheStrategy() != null){ rep.add(namespace+"cacheStrategy", valueFactory.createReference(namespace+"cacheStrategy-"+refConfig.getCacheStrategy().name())); if(refConfig.getAccessUri() != null){ rep.add(namespace+"accessUri", valueFactory.createReference(refConfig.getAccessUri())); if(refConfig.getQueryUri() != null){ rep.add(namespace+"queryUri", valueFactory.createReference(refConfig.getQueryUri()));
throw new IllegalArgumentException("The parsed SiteConfiguration MUST NOT be NULL!"); if(config.getId() == null || config.getId().isEmpty()){ throw new IllegalArgumentException("The ReferencedSite ID (config#getId()) MUST NOT " + "NULL nor empty!"); if(config.getCacheStrategy() != CacheStrategy.all && dereferencer == null){ throw new IllegalArgumentException("The EntityDerefernencer MUST NOT be NULL if " + "CacheStrategy is NOT FULL (all entities in local Cache)!"); if(config.getCacheStrategy() != CacheStrategy.none && cache == null){ throw new IllegalArgumentException("The Cache MUST NOT be NULL if the " + "CacheStrategy is set to an other value as NONE!"); if (siteConfiguration.getFieldMappings() != null) { log.debug(" > Initialise configured field mappings"); for (String configuredMapping : siteConfiguration.getFieldMappings()) { FieldMapping mapping = FieldMappingUtils.parseFieldMapping(configuredMapping, nsPrefixService);
@Override public InputStream getContent(String id, String contentType) throws SiteException { if (siteConfiguration.getEntityDereferencerType() == null) { throw new SiteException( String.format( "Unable to get Content for Entity %s because No dereferencer configured for ReferencedSite %s", id, getId())); } if (dereferencer == null) { throw new SiteException(String.format("Dereferencer %s for remote site %s is not available", siteConfiguration.getEntityDereferencerType(), siteConfiguration.getAccessUri())); } try { return dereferencer.dereference(id, contentType); } catch (IOException e) { throw new SiteException( String.format( "Unable to load content for Entity %s and mediaType %s from remote site %s by using dereferencer %s", id, contentType, siteConfiguration.getAccessUri(), siteConfiguration.getEntityDereferencerType()), e); } }
if(config.getAccessUri() != null && config.getEntityDereferencerType() != null && dereferencerComponentInstance == null){ log.debug(" ... EntityDereference not available"); valid = false; if(config.getQueryUri() != null && config.getEntitySearcherType() != null && searcherComponentInstance == null){ log.debug(" ... EntitySearcher not available"); valid = false; if(config.getCacheStrategy() != CacheStrategy.none && cache == null){ log.debug(" ... Local Cache not available"); valid = false; if(config.getCacheStrategy() != CacheStrategy.all && offlineMode != null){ log.debug(" ... Offline Mode is active and CacheStrategy != ALL"); log.info(" - register ReferencedSite '{}'",config.getId()); try { referencedSite = new ReferencedSiteImpl(config,
@Override public QueryResultList<String> findReferences(FieldQuery query) throws SiteException { if (siteConfiguration.getCacheStrategy() == CacheStrategy.all) { try { return cache.findReferences(query); } catch (YardException e) { if (entitySearcher == null) { throw new SiteException("Unable to execute query on Cache " + siteConfiguration.getCacheId(), e); } else { log.warn( String.format( "Error while performing query on Cache %s! Try to use remote site %s as fallback!", siteConfiguration.getCacheId(), siteConfiguration.getQueryUri()), e); } } } if (entitySearcher == null) { throw new SiteException(String.format("The referencedSite %s dose not support queries!", getId())); } try { return entitySearcher.findEntities(query); } catch (IOException e) { throw new SiteException("Unable execute Query on remote site " + siteConfiguration.getQueryUri(), e); } }
rep = cache.getRepresentation(id); if (rep == null){ if(siteConfiguration.getCacheStrategy() == CacheStrategy.all) { return null; // do no remote lookups on CacheStrategy.all!! if (dereferencer == null) { throw new SiteException(String.format("Unable to get Represetnation %s form Cache %s", id, siteConfiguration.getCacheId()), e); } else { log.warn( String.format( "Unable to get Represetnation %s form Cache %s. Will dereference from remote site %s", id, siteConfiguration.getCacheId(), siteConfiguration.getAccessUri()), e); throw new SiteException(String.format( "Unable to load Representation for entity %s form remote site %s with dereferencer %s", id, siteConfiguration.getAccessUri(), siteConfiguration.getEntityDereferencerType()), e); log.warn(String.format( "Unable to cache Represetnation %s in Cache %s! Representation not cached!", id, siteConfiguration.getCacheId()), e);
@Override public QueryResultList<Entity> findEntities(FieldQuery query) throws SiteException { List<Entity> results; if (siteConfiguration.getCacheStrategy() == CacheStrategy.all) { try { if (entitySearcher == null) { throw new SiteException("Unable to execute query on Cache " + siteConfiguration.getCacheId(), e); } else { log.warn( String.format( "Error while performing query on Cache %s! Try to use remote site %s as fallback!", siteConfiguration.getCacheId(), siteConfiguration.getQueryUri()), e); throw new SiteException(String.format( "Unable to execute query on remote site %s with entitySearcher %s!", siteConfiguration.getQueryUri(), siteConfiguration.getEntitySearcherType()), e);
throw new IllegalArgumentException("The parsed SiteConfiguration MUST NOT be NULL!"); if(config.getId() == null || config.getId().isEmpty()){ throw new IllegalArgumentException("The ReferencedSite ID (config#getId()) MUST NOT " + "NULL nor empty!"); if(config.getCacheStrategy() != CacheStrategy.all && dereferencer == null){ throw new IllegalArgumentException("The EntityDerefernencer MUST NOT be NULL if " + "CacheStrategy is NOT FULL (all entities in local Cache)!"); if(config.getCacheStrategy() != CacheStrategy.none && cache == null){ throw new IllegalArgumentException("The Cache MUST NOT be NULL if the " + "CacheStrategy is set to an other value as NONE!"); if (siteConfiguration.getFieldMappings() != null) { log.debug(" > Initialise configured field mappings"); for (String configuredMapping : siteConfiguration.getFieldMappings()) { FieldMapping mapping = FieldMappingUtils.parseFieldMapping(configuredMapping, nsPrefixService);
@Override public InputStream getContent(String id, String contentType) throws SiteException { if (siteConfiguration.getEntityDereferencerType() == null) { throw new SiteException( String.format( "Unable to get Content for Entity %s because No dereferencer configured for ReferencedSite %s", id, getId())); } if (dereferencer == null) { throw new SiteException(String.format("Dereferencer %s for remote site %s is not available", siteConfiguration.getEntityDereferencerType(), siteConfiguration.getAccessUri())); } try { return dereferencer.dereference(id, contentType); } catch (IOException e) { throw new SiteException( String.format( "Unable to load content for Entity %s and mediaType %s from remote site %s by using dereferencer %s", id, contentType, siteConfiguration.getAccessUri(), siteConfiguration.getEntityDereferencerType()), e); } }
@Override public QueryResultList<Representation> find(FieldQuery query) throws SiteException { if (siteConfiguration.getCacheStrategy() == CacheStrategy.all) { try { return cache.find(query); } catch (YardException e) { if (entitySearcher == null) { throw new SiteException("Unable to execute query on Cache " + siteConfiguration.getCacheId(), e); } else { log.warn( String.format( "Error while performing query on Cache %s! Try to use remote site %s as fallback!", siteConfiguration.getCacheId(), siteConfiguration.getQueryUri()), e); } } } if (entitySearcher == null) { throw new SiteException(String.format("ReferencedSite %s does not support queries!", getId())); } try { return entitySearcher.find(query); } catch (IOException e) { throw new SiteException("Unable execute Query on remote site " + siteConfiguration.getQueryUri(), e); } }
public boolean supportsLocalMode() { return siteConfiguration.getCacheStrategy() == CacheStrategy.all && cache != null; }
@Override public String toString() { return siteConfiguration != null ? siteConfiguration.getName() : null; }
public String getId() { return siteConfiguration.getId(); }