/** * @deprecated since 5.0 use {@link NodeTypes.RenderableMixin#getTemplate(Node)} */ public static String getTemplate(Node node) { return getMetaData(node).getTemplate(); }
/** * Return iconFileName for a node. * * @param node node to read status from * @return file name for an icon */ public static String getActivationStatusIcon(Node node) { MetaData metaData = info.magnolia.jcr.util.MetaDataUtil.getMetaData(node); String iconFileName; switch (metaData.getActivationStatus()) { case MetaData.ACTIVATION_STATUS_MODIFIED: iconFileName = "indicator_yellow.gif"; break; case MetaData.ACTIVATION_STATUS_ACTIVATED: iconFileName = "indicator_green.gif"; break; default: iconFileName = "indicator_red.gif"; } return iconFileName; }
private void updateTemplate(Node node, Map<String, String> templateIdMap) throws RepositoryException { MetaData meta = MetaDataUtil.getMetaData(node); String template = meta.getTemplate(); if (StringUtils.isNotEmpty(template) && templateIdMap.containsKey(template)) { String newTemplate = templateIdMap.get(template); meta.setTemplate(newTemplate); reportDebug("Updating " + node.getPath() + ": old template " + template + " replaced by " + newTemplate); } else if (StringUtils.isNotEmpty(template)) { reportSystem("Unknown template name (" + template + ") at " + node.getPath() + ". Leaving unchanged."); } if (savePartiallyMigratedContent()) { // save immediately to lower amount of nodes in memory that needs to be evaluated on saving single page conversions node.getSession().save(); } }
if (MediaEl.module().isSingleinstance() && !MetaDataUtil.getMetaData(currContent).getIsActivated()) MetaDataUtil.getMetaData(currContent).setActivated();
MetaData metaData = MetaDataUtil.getMetaData(paragraph); if (StringUtils.isEmpty(metaData.getTemplate()))
public String save() { success = false; Node node = NodeUtilsExt.getNodeByIdOrPath(PlaylistConstants.REPO, path); if (node != null) { try { node.setProperty("title", title); node.setProperty("description", description); if (MediaEl.module().isSingleinstance()) { MetaDataUtil.getMetaData(node).setActivated(); } node.getSession().save(); success = true; } catch (RepositoryException e) { } } return VIEW_EXTJS; }
public String saveMedia() { success = false; Node node = NodeUtilsExt.getNodeByIdOrPath(MediaModule.REPO, mediaHandle); if (node != null) { try { node.setProperty("title", title); node.setProperty("description", description); if (MediaEl.module().isSingleinstance()) { MetaDataUtil.getMetaData(node).setActivated(); } node.getSession().save(); success = true; } catch (RepositoryException e) { } } return VIEW_EXTJS; }
/** * The transformation of the footer is not correctly handled by the default migration. It is transform as a component but must be an area. */ private void transformFooter(Node page) throws PathNotFoundException, RepositoryException{ if(page.hasNode("footer")) { Node node = page.getNode("footer"); String type = MgnlNodeType.NT_AREA; node.setPrimaryType(type); reportSystem("Changing Node Type from "+node.getPrimaryNodeType().getName()+" to "+type+" for the following node: "+node.getPath()); // Area has no template try { MetaDataUtil.getMetaData(node).removeProperty("mgnl:template"); } catch (PathNotFoundException e) { // ignore - mgnl:template could be missing in some cases. } reportRequestUserAction("The node "+node.getPath()+" was identified as a STK footer area." +"It has been transform into an area. Please double check that it is used as a STK footer area."); } }
MetaDataUtil.getMetaData(media).setActivated(); media.getSession().save();
/** * @deprecated since 5.0 use {@link info.magnolia.jcr.util.NodeTypes.LastModified#update(javax.jcr.Node)}. */ public static void updateMetaData(Node node) throws RepositoryException { MetaData md = getMetaData(node); md.setModificationDate(); md.setAuthorId(MgnlContext.getUser().getName()); }
MetaDataUtil.getMetaData(media).setActivated();
@Test public void testGetMetaData() throws Exception { // WHEN MetaData md = MetaDataUtil.getMetaData(testNode); // THEN assertNotNull(md); }
MetaDataUtil.getMetaData(newContent).setUnActivated();
@Test public void testUpdateMetaData() throws Exception { // GIVEN final String testUserName = "test"; final Context ctx = mock(Context.class); final User user = mock(User.class); MgnlContext.setInstance(ctx); when(ctx.getUser()).thenReturn(user); when(user.getName()).thenReturn(testUserName); MetaData metaData = MetaDataUtil.getMetaData(testNode); // WHEN MetaDataUtil.updateMetaData(testNode); // THEN Date lastMod = metaData.getModificationDate().getTime(); long diff = System.currentTimeMillis() - lastMod.getTime(); assertTrue("lastMod hast not been updated in the last 500ms - it was only " + diff + "ms!", diff < 500); assertEquals(testUserName, metaData.getAuthorId()); }
while (parent.getDepth() != 0 && !MetaDataUtil.getMetaData(parent).getIsActivated())
/** * @param parentPath * @param node * @throws RepositoryException * @throws ExchangeException */ protected void activateSingleNode(String parentPath, Node node) throws RepositoryException, ExchangeException { if (MediaConfigurationManager.NT_MEDIA.equals(node.getPrimaryNodeType().getName()) && MetaDataUtil.getMetaData(node).getIsActivated()) { // already activated media, should deactivate in order to remove stale resolutions log .warn( "Activating already active media {}, will deactivate existing node in order to remove stale resolutions", NodeUtil.getPathIfPossible(node)); getSyndicator().deactivate(info.magnolia.cms.util.ContentUtil.asContent(node)); } checkFolderActivation(node); getSyndicator().activate( parentPath, info.magnolia.cms.util.ContentUtil.asContent(node), getOrderingInfo(info.magnolia.cms.util.ContentUtil.asContent(node))); }
/** * {@inheritDoc} */ @SuppressWarnings("unchecked") @Override protected void doExecute(InstallContext installContext) throws RepositoryException, TaskExecutionException { Criteria criteria = JCRCriteriaFactory .createCriteria() .setWorkspace(RepositoryConstants.WEBSITE) .add(Restrictions.eq("@jcr:primaryType", MgnlNodeType.NT_COMPONENT)) .add(Restrictions.eq("MetaData/mgnl:template", actualTemplate)) .addOrder(Order.desc("@jcr:score")); log.debug("Running query: {}", criteria.toXpathExpression()); AdvancedResult result = criteria.execute(); for (AdvancedResultItem page : result.getItems()) { log.warn("Replacing template {} with {} in {}", new Object[]{ MetaDataUtil.getTemplate(page), newTemplate, page.getHandle() }); MetaDataUtil.getMetaData(page).setTemplate(newTemplate); } }
/** * {@inheritDoc} */ @SuppressWarnings("unchecked") @Override protected void doExecute(InstallContext installContext) throws RepositoryException, TaskExecutionException { Criteria criteria = JCRCriteriaFactory .createCriteria() .setWorkspace(RepositoryConstants.WEBSITE) .add(Restrictions.eq("@jcr:primaryType", MgnlNodeType.NT_PAGE)) .add(Restrictions.not(Restrictions.eq("MetaData/mgnl:template", actualTemplate))) .addOrder(Order.desc("@jcr:score")); log.debug("Running query: {}", criteria.toXpathExpression()); AdvancedResult result = criteria.execute(); for (AdvancedResultItem page : result.getItems()) { log.warn("Replacing template {} with {} in {}", new Object[]{ MetaDataUtil.getTemplate(page), newTemplate, page.getHandle() }); MetaDataUtil.getMetaData(page).setTemplate(newTemplate); } } }
returnValue = MetaDataUtil.getMetaData(content).getStringProperty(property);
mb.setMetaData(MetaDataUtil.getMetaData(media)); mb.setHandle(media.getPath()); mb.setName(PropertyUtil.getString(media, MediaTypeHandler.METADATA_NAME));