public static void set(Node node, String comment) throws RepositoryException { checkNodeType(node, NAME, DELETED, DELETED_BY, COMMENT); node.setProperty(DELETED, getCurrentCalendar()); node.setProperty(DELETED_BY, getCurrentUserName()); node.setProperty(COMMENT, comment); } }
/** * Sets the current date as the node's creation date and uses {@link info.magnolia.context.MgnlContext} to set the name of the creating * user. Used with nodes having the <code>mgnl:created</code> mixin. */ public static void set(Node node) throws RepositoryException { set(node, getCurrentUserName(), getCurrentCalendar()); }
/** * Sets the date of modification. * It should not be necessary to call this method explicitly as all Magnolia treated node instances are self updating the property defined by mixin. * * @see info.magnolia.jcr.wrapper.MgnlPropertySettingContentDecorator for more details. */ public static void update(Node node, Calendar lastModified) throws RepositoryException { update(node, getCurrentUserName(), lastModified); }
/** * Sets the name of the user that performed the most recent activation as well as to current time, last activated version name and last activated version creation time. */ public static void update(Node node, String userName, boolean isActivated, Version version) throws RepositoryException { checkNodeType(node, Activatable.NAME, LAST_ACTIVATED, LAST_ACTIVATED_BY, ACTIVATION_STATUS, LAST_ACTIVATED_VERSION); node.setProperty(LAST_ACTIVATED, getCurrentCalendar()); node.setProperty(LAST_ACTIVATED_BY, userName); node.setProperty(ACTIVATION_STATUS, isActivated); if (version != null) { node.setProperty(LAST_ACTIVATED_VERSION, version.getName()); node.setProperty(LAST_ACTIVATED_VERSION_CREATED, version.getCreated()); } }
/** * Set the versioning comment on the node. */ public static void set(Node node, String comment) throws RepositoryException { checkNodeType(node, NAME, COMMENT); node.setProperty(COMMENT, comment); } }
/** * Sets the date of modification to current Calendar and uses {@link info.magnolia.context.MgnlContext} to set the name of the user. * It should not be necessary to call this method explicitly as all Magnolia treated node instances are self updating the property defined by mixin. * * @see info.magnolia.jcr.wrapper.MgnlPropertySettingContentDecorator for more details. */ public static void update(Node node) throws RepositoryException { update(node, getCurrentCalendar()); }
@Test public void getCurrentUserName() { // GIVEN AbstractSystemContext ctx = mock(AbstractSystemContext.class); User user = mock(User.class); when(user.getName()).thenReturn(UserManager.SYSTEM_USER); when(ctx.getUser()).thenReturn(user); Context originalContext = mock(Context.class); User originalUser = mock(User.class); when(originalUser.getName()).thenReturn("testUser"); when(originalContext.getUser()).thenReturn(originalUser); when(ctx.getOriginalContext()).thenReturn(originalContext); MgnlContext.setInstance(ctx); // WHEN final String currentUserName = NodeTypes.getCurrentUserName(); // THEN assertEquals("System [testUser]", currentUserName); } }
/** * Sets the template assigned to the node. Used with nodes having the <code>mgnl:renderable</code> mixin. */ public static void set(Node node, String template) throws RepositoryException { checkNodeType(node, NAME, TEMPLATE); node.setProperty(TEMPLATE, template); } }
/** * Sets the date of modification and the name of the user modifying a node. * It should not be necessary to call this method explicitly as all Magnolia treated node instances are self updating the property defined by mixin. * * @see info.magnolia.jcr.wrapper.MgnlPropertySettingContentDecorator for more details. */ public static void update(Node node, String userName, Calendar lastModified) throws RepositoryException { checkNodeType(node, LastModified.NAME, LAST_MODIFIED, LAST_MODIFIED_BY); node.setProperty(LAST_MODIFIED, lastModified); node.setProperty(LAST_MODIFIED_BY, userName); }
/** * Sets the supplied date as the node's creation date and sets the name of the creating user. Also sets the date of * modification and the user last having modified the node to the same values. Used with nodes having the * <code>mgnl:created</code> mixin. */ public static void set(Node node, String userName, Calendar created) throws RepositoryException { checkNodeType(node, NAME, CREATED, CREATED_BY); node.setProperty(CREATED, created); node.setProperty(CREATED_BY, userName); LastModified.update(node, userName, created); } }