public Object jsGet_session() { try { return property.getSession(); } catch (RepositoryException re) { return Undefined.instance; } }
public void call() throws RepositoryException { prop.setValue("modified"); prop.getSession().save(); } }, Event.PROPERTY_CHANGED);
public void call() throws RepositoryException { Session s = prop.getSession(); prop.remove(); s.save(); } }, Event.PROPERTY_REMOVED);
/** * Tests if getSession() is same as through which the Property was acquired */ public void testGetSession() throws RepositoryException { assertSame("getSession must return the Session through which " + "the Property was acquired.", property.getSession(), session); }
@Override public Session getSession() throws RepositoryException { return getWrappedProperty().getSession(); }
private Value[] toValues(List<String> strings) throws RepositoryException { final List<Value> values = new ArrayList<>(strings.size()); final ValueFactory valueFactory = property.getSession().getValueFactory(); for (String string : strings) { values.add(valueFactory.createValue(string)); } return values.toArray(new Value[values.size()]); } }
public Property addProperty(String key, Value value) throws RepositoryException { Node parent = getOrCreateParent(key); if (parent.hasProperty(key)) { throw new ItemExistsException(key); } Property p = parent.setProperty(key, value); treeManager.split(this, parent, p); if (autoSave) { p.getSession().save(); } return p; }
public Property addProperty(String key, Value value) throws RepositoryException { Node parent = getOrCreateParent(key); if (parent.hasProperty(key)) { throw new ItemExistsException(key); } Property p = parent.setProperty(key, value); treeManager.split(this, parent, p); if (autoSave) { p.getSession().save(); } return p; }
public Property addProperty(String key, Value value) throws RepositoryException { Node parent = getOrCreateParent(key); if (parent.hasProperty(key)) { throw new ItemExistsException(key); } Property p = parent.setProperty(key, value); treeManager.split(this, parent, p); if (autoSave) { p.getSession().save(); } return p; }
public static boolean propertyIsIdentical(final Property jcrProperty, final ModelProperty modelProperty) throws RepositoryException, IOException { return propertyIsIdentical(jcrProperty, modelProperty, determineVerifiedValues(modelProperty, jcrProperty.getSession())); }
@Override public void setObject(Date object) { Calendar calendar = new GregorianCalendar(); calendar.setTime(object); try { valueModel.setValue(valueModel.getJcrPropertymodel().getProperty().getSession().getValueFactory() .createValue(calendar)); } catch (RepositoryException ex) { log.error(ex.getMessage(), ex); } super.setObject(object); }
@Override public void setObject(Date object) { Calendar calendar = new GregorianCalendar(); calendar.setTime(object); try { valueModel.setValue(valueModel.getJcrPropertymodel().getProperty().getSession().getValueFactory() .createValue(calendar)); } catch (RepositoryException ex) { log.error(ex.getMessage(), ex); } super.setObject(object); }
/** * Test the restore of a OnParentVersion-ABORT property * * @throws javax.jcr.RepositoryException */ public void testRestorePropJcr2() throws RepositoryException { try { VersionManager versionManager = p.getSession().getWorkspace().getVersionManager(); String path = p.getParent().getPath(); versionManager.checkout(path); versionManager.checkin(path); fail("On checkin of N which has a property with OnParentVersion ABORT defined, an UnsupportedRepositoryOperationException must be thrown."); } catch (VersionException e) { // success } }
private static boolean isPartOfHippoDocument(final Property property) throws RepositoryException { final Node root = property.getSession().getRootNode(); Node current = property.getParent(); while (!current.isSame(root)) { Node parent = current.getParent(); if (parent.isNodeType(HippoNodeType.NT_HANDLE) && current.isNodeType(HippoNodeType.NT_DOCUMENT)) { return true; } current = parent; } return false; }
public Link(Property property) { try { setJCRNode(property.getParent()); setWorkspace(property.getSession().getWorkspace().toString()); setProperty(property); setPropertyName(property.getName()); } catch (RepositoryException e) { throw new RuntimeRepositoryException(e); } }
@Test public void testWorkspaceReturnsLogicalName3() throws RepositoryException { // GIVEN Node root = MgnlContext.getJCRSession("magnolia-mgnlSystem").getRootNode(); root.addNode("test", NodeTypes.ContentNode.NAME).setProperty("testProp", "testVal"); root.getSession().save(); // WHEN String name = root.getNode("test").getProperty("testProp").getSession().getWorkspace().getName(); // THEN assertTrue(name.equals("magnolia-mgnlSystem")); }
/** * Test the restore of a OnParentVersion-IGNORE property * * @throws javax.jcr.RepositoryException */ public void testRestorePropJcr2() throws RepositoryException { Node propParent = p.getParent(); VersionManager versionManager = propParent.getSession().getWorkspace().getVersionManager(); String path = propParent.getPath(); versionManager.checkout(path); Version v = versionManager.checkin(path); versionManager.checkout(path); p.setValue(newPropValue); p.getSession().save(); versionManager.restore(v, false); assertEquals("On restore of a OnParentVersion-IGNORE property P, the current value of P must be left unchanged.", p.getString(), newPropValue); }
/** * Special purpose override, makes sure the JcrPropertyValueModel will never be null or "" * (non-Javadoc) * @see org.apache.wicket.model.IModel#setObject(java.lang.Object) */ public void setObject(String object) { if (object == null) { return; } String value = (String) object; if (value.length() > 0) { try { model.setValue(model.getJcrPropertymodel().getProperty().getSession().getValueFactory().createValue(value)); } catch(RepositoryException ex) { log.error(ex.getMessage(), ex); } } } }
@Override public NodeData getWrappedNodeData() { try { // DHM.getNodeData() can still return null and the var itself is transient and won't survive serialization if (nodeData == null || (nodeData.isExist() && !nodeData.getJCRProperty().getSession().isLive())) { nodeData = getHierarchyManager().getNodeData(getPath()); } } catch (RepositoryException e) { log.error("can't reinitialize node {}", getPath(), e); } return nodeData; }
@Test public void setStringProperty() throws RepositoryException, IOException { Node parentNode = getNode(TEST_PATH); addProperty(parentNode, "string", getAdminSession().getValueFactory().createValue("string \" value")); Property property = parentNode.getProperty("string"); property.setValue("new value"); assertTrue(parentNode.isModified()); assertTrue(property.isModified()); assertFalse(property.isNew()); property.getSession().save(); Session session2 = createAnonymousSession(); try { Property property2 = session2.getProperty(TEST_PATH + "/string"); assertEquals("new value", property2.getString()); } finally { session2.logout(); } }