MemRepository extends DBSRepositoryBase { @Override public PartialList<State> queryAndFetch(Expression expression, DBSExpressionEvaluator evaluator, OrderByClause orderByClause, int limit, int offset, int countUpTo, boolean deepCopy, boolean fulltextScore) { List<State> maps = new ArrayList<>(); for (State state : states.values()) { if (evaluator.matches(state)) { if (deepCopy) { state = StateHelper.deepCopy(state); } maps.add(state); } } if (orderByClause != null) { Collections.sort(maps, new OrderByComparator(orderByClause, evaluator)); } int totalSize = maps.size(); if (countUpTo == -1) { } else if (countUpTo == 0) { totalSize = -1; } else { if (totalSize > countUpTo) { totalSize = -2; } } if (limit != 0) { int size = maps.size(); maps.subList(0, offset > size ? size : offset).clear(); size = maps.size(); if (limit < size) { maps.subList(limit, size).clear(); } } return new PartialList<>(maps, totalSize); } MemRepository(String repositoryName); @Override void shutdown(); @Override String generateNewId(); @Override State readState(String id); @Override List<State> readStates(List<String> ids); @Override void createState(State state); @Override void updateState(String id, StateDiff diff); @Override void deleteStates(Set<String> ids); @Override State readChildState(String parentId, String name,
            Set<String> ignored); @Override boolean hasChild(String parentId, String name, Set<String> ignored); @Override List<State> queryKeyValue(String key, String value,
            Set<String> ignored); @Override void queryKeyValueArray(String key, Object value, Set<String> ids,
            Map<String, String> proxyTargets,
            Map<String, Object[]> targetProxies); @Override boolean queryKeyValuePresence(String key, String value,
            Set<String> ignored); @Override PartialList<State> queryAndFetch(Expression expression,
            DBSExpressionEvaluator evaluator, OrderByClause orderByClause,
            int limit, int offset, int countUpTo, boolean deepCopy,
            boolean fulltextScore); static void applyDiff(State state, StateDiff stateDiff); static Serializable applyDiff(Serializable value, ListDiff listDiff);  }
@Test public void testProxySchemas() throws Exception { DocumentModel folder = new DocumentModelImpl("/", "folder", "Folder"); folder = session.createDocument(folder); DocumentModel doc = new DocumentModelImpl("/", "file", "File"); doc = session.createDocument(doc); DocumentModel proxy = session.publishDocument(doc, folder); session.save(); try { doc.setPropertyValue("info:info", "docinfo"); doc = session.saveDocument(doc); session.save(); } catch (PropertyNotFoundException e) { assertTrue(e.getMessage().contains("info:info")); } assertNull(proxy.getPropertyValue("info:info")); proxy.setPropertyValue("info:info", "proxyinfo"); proxy = session.saveDocument(proxy); session.save(); closeSession(); openSession(); DocumentModel root = session.getRootDocument(); proxy = session.getDocument(proxy.getRef()); assertEquals("proxyinfo", proxy.getPropertyValue("info:info")); String nxql; DocumentModelList list; nxql = "SELECT * FROM Document WHERE info:info = 'proxyinfo' AND ecm:isProxy = 1"; list = session.query(nxql); assertEquals(1, list.size()); nxql = "SELECT * FROM Document WHERE info:info = 'proxyinfo'"; list = session.query(nxql); assertEquals(1, list.size()); nxql = "SELECT * FROM Document WHERE info:info = 'proxyinfo' AND ecm:isProxy = 0"; list = session.query(nxql); assertEquals(0, list.size()); nxql = "SELECT ecm:uuid, info:info FROM File WHERE info:info IS NOT NULL"; IterableQueryResult res = session.queryAndFetch(nxql, "NXQL"); Map<Serializable, String> actual = new HashMap<Serializable, String>(); for (Map<String, Serializable> map : res) { Serializable uuid = map.get("ecm:uuid"); String info = (String) map.get("info:info"); actual.put(uuid.toString(), info); } res.close(); assertEquals(Collections.singletonMap(proxy.getId(), "proxyinfo"), actual); session.copy(folder.getRef(), root.getRef(), "folderCopy"); DocumentModel proxyCopy = session.getDocument(new PathRef( "/folderCopy/file")); assertTrue(proxyCopy.isProxy()); assertEquals("proxyinfo", proxyCopy.getPropertyValue("info:info")); }