/** * Note: this implementation does not yet take into account the mapping * of joined subclasses like Job->UpdateJob. */ public String getSQLJoin(String fromType, String fromAlias, String toType, String toAlias) { String fromPath = "UNKNOWN"; String toPath = "UNKNOWN"; final Relationship fromRel = _getRelationship(fromType, toType); final Relationship toRel = _getRelationship(toType, fromType); if (fromRel != null && !fromRel.collection) { fromPath = fromRel.relationshipName; toPath = "id"; } else if (toRel != null && !toRel.collection) { toPath = toRel.relationshipName; fromPath = "id"; } else { StringBuilder sb = new StringBuilder(); sb.append("fromType="); sb.append(fromType); sb.append(";toType="); sb.append(toType); throw new InternalException("Unhandled SQL Join! -- " + sb); } return String.format("%s.%s = %s.%s", fromAlias, fromPath, toAlias, toPath); }
lockedByHolder.put(key, lockedByFields(key, m)); Map<String, Relationship> value = new HashMap<String, Relationship>(); ClassMetadata cm = m.get(key); for (Class<?> c : hierarchy(m, key)) { Locks locks = locksHolder.get(c.getName()); locks.fillRelationships(sfi, value); for (String key : m.keySet()) { ClassMetadata cm = m.get(key); Map<String, String> queries = countQueriesAndEditTargets(key, lockedByHolder.get(key)); collectionCountHolder.putAll(queries);
/** * Listener method which waits for a {@link ContextRefreshedEvent} and then * extracts the {@link SessionFactory} from the {@link ApplicationContext} * and pases it to {@link #setSessionFactory(SessionFactory)}. */ @Override public void handleContextRefreshedEvent(ContextRefreshedEvent cre) { ApplicationContext ctx = cre.getApplicationContext(); if (ctx.containsBean("sessionFactory")) { SessionFactory sessionFactory = (SessionFactory) ctx .getBean("sessionFactory"); setSessionFactory(sessionFactory); } else { log.warn("No session factory found. Cannot initialize"); } }
/** * Simplified factory method which generates all the security primitives * internally. Primarily useful for generated testing instances. * @param sm the session manager * @param sf the session factory * @param cache the session cache * @return a configured security system */ public static BasicSecuritySystem selfConfigure(SessionManager sm, ServiceFactory sf, SessionCache cache) { CurrentDetails cd = new CurrentDetails(cache); SystemTypes st = new SystemTypes(); TokenHolder th = new TokenHolder(); Roles roles = new Roles(); final SessionProvider sessionProvider = new SessionProviderInMemory(roles, new NodeProviderInMemory(""), null); final OmeroInterceptor oi = new OmeroInterceptor(roles, st, new ExtendedMetadata.Impl(), cd, th, new PerSessionStats(cd), new LightAdminPrivileges(roles), null, new HashSet<String>(), new HashSet<String>()); SecurityFilterHolder holder = new SecurityFilterHolder( cd, new OneGroupSecurityFilter(roles), new AllGroupsSecurityFilter(null, roles), new SharingSecurityFilter(roles, null)); BasicSecuritySystem sec = new BasicSecuritySystem(oi, st, cd, sm, sessionProvider, new EventProviderInMemory(), roles, sf, new TokenHolder(), Collections.<SecurityFilter>singletonList(holder), new DefaultPolicyService(), new BasicACLVoter(cd, st, th, holder, sessionProvider, new ReadOnlyStatus(false, false))); return sec; }
/** * Walks the data on what locks what * for "from" argument to see if there is any direct relationship to the * "to" argument. If there is, the name will be returned. Otherwise, null. */ public String getRelationship(String from, String to) { Relationship r = _getRelationship(from, to); if (r != null) { return r.relationshipName; } return null; }