/* Populates all @versionList entities with @version and @current tags for a page
325852
function processVersionLists (entity, version, versions) {
  quantum.select(entity)
    .selectAll('versionList', {recursive: true})
    .forEach(versionList => {
      versionList.content(versions.map(v => {
        return { type: 'version', params: [v], content: [] }
      }))
      versionList.add({ type: 'current', params: [version], content: [] })
    })
}
768440
public static void doMetaUpdateVersionsOnStores(AdminClient adminClient,
                                                        List<StoreDefinition> oldStoreDefs,
                                                        List<StoreDefinition> newStoreDefs) {
            Set<String> storeNamesUnion = new HashSet<String>();
            Map<String, StoreDefinition> oldStoreDefinitionMap = new HashMap<String, StoreDefinition>();
            Map<String, StoreDefinition> newStoreDefinitionMap = new HashMap<String, StoreDefinition>();
            List<String> storesChanged = new ArrayList<String>();
            for(StoreDefinition storeDef: oldStoreDefs) {
                String storeName = storeDef.getName();
                storeNamesUnion.add(storeName);
                oldStoreDefinitionMap.put(storeName, storeDef);
            }
            for(StoreDefinition storeDef: newStoreDefs) {
                String storeName = storeDef.getName();
                storeNamesUnion.add(storeName);
                newStoreDefinitionMap.put(storeName, storeDef);
            }
            for(String storeName: storeNamesUnion) {
                StoreDefinition oldStoreDef = oldStoreDefinitionMap.get(storeName);
                StoreDefinition newStoreDef = newStoreDefinitionMap.get(storeName);
                if(oldStoreDef == null && newStoreDef != null || oldStoreDef != null
                   && newStoreDef == null || oldStoreDef != null && newStoreDef != null
                   && !oldStoreDef.equals(newStoreDef)) {
                    storesChanged.add(storeName);
                }
            }
            System.out.println("Updating metadata version for the following stores: "
                               + storesChanged);
            try {
                adminClient.metadataMgmtOps.updateMetadataversion(adminClient.getAdminClientCluster()
                                                                             .getNodeIds(),
                                                                  storesChanged);
            } catch(Exception e) {
                System.err.println("Error while updating metadata version for the specified store.");
            }
        }
274896
private void updateVersionedChildNodes(List<String> versionUuids) throws RepositoryException, IOException
   {
      SessionDataManager dataManager = userSession.getTransientNodesManager();

      NodeData versionStorage = (NodeData)dataManager.getItemData(Constants.VERSIONSTORAGE_UUID);

      for (String versionUuid : versionUuids)
      {
         NodeData versionHistoryData =
            (NodeData)dataManager.getItemData(versionStorage, new QPathEntry("", versionUuid, 1), ItemType.NODE);

         PropertyData versionableUuidProp =
            (PropertyData)dataManager.getItemData(versionHistoryData, new QPathEntry(Constants.JCR_VERSIONABLEUUID, 1),
               ItemType.PROPERTY);

         String versionableUuid = ValueDataUtil.getString(versionableUuidProp.getValues().get(0));

         // fetch child versionable node

         NodeData versionedChild = (NodeData)dataManager.getItemData(versionableUuid);

         if (versionedChild != null && versionedChild.getQPath().isDescendantOf(versionableNode.getData().getQPath()))
         {
            // find latest version
            String latestVersionUuid = null;
            for (int versionNumber = 1;; versionNumber++)
            {
               NodeData nodeData =
                  (NodeData)dataManager.getItemData(versionHistoryData, new QPathEntry("", Integer
                     .toString(versionNumber), 1), ItemType.NODE);

               if (nodeData == null)
               {
                  break;
               }
               else
               {
                  latestVersionUuid = nodeData.getIdentifier();
               }
            }

            if (latestVersionUuid == null)
            {
               // fetch root version
               NodeData rootVersion =
                  (NodeData)dataManager.getItemData(versionHistoryData, new QPathEntry(Constants.JCR_ROOTVERSION, 1),
                     ItemType.NODE);
               latestVersionUuid = rootVersion.getIdentifier();
            }

            PropertyData propVersionHistory =
               (PropertyData)dataManager.getItemData(versionedChild, new QPathEntry(Constants.JCR_VERSIONHISTORY, 1),
                  ItemType.PROPERTY);
            String prevVerHistoryId = ValueDataUtil.getString(propVersionHistory.getValues().get(0));

            PropertyData propBaseVersion =
               (PropertyData)dataManager.getItemData(versionedChild, new QPathEntry(Constants.JCR_BASEVERSION, 1),
                  ItemType.PROPERTY);

            PropertyData propPredecessors =
               (PropertyData)dataManager.getItemData(versionedChild, new QPathEntry(Constants.JCR_PREDECESSORS, 1),
                  ItemType.PROPERTY);

            TransientPropertyData newVersionHistoryProp =
               TransientPropertyData.createPropertyData(versionedChild, Constants.JCR_VERSIONHISTORY,
                  PropertyType.REFERENCE, false, new TransientValueData(new Identifier(versionUuid)));

            // jcr:baseVersion
            TransientPropertyData newBaseVersionProp =
               TransientPropertyData.createPropertyData(versionedChild, Constants.JCR_BASEVERSION,
                  PropertyType.REFERENCE, false, new TransientValueData(new Identifier(latestVersionUuid)));

            // jcr:predecessors
            List<ValueData> predecessorValues = new ArrayList<ValueData>();
            predecessorValues.add(new TransientValueData(new Identifier(latestVersionUuid)));
            TransientPropertyData newPredecessorsProp =
               TransientPropertyData.createPropertyData(versionedChild, Constants.JCR_PREDECESSORS,
                  PropertyType.REFERENCE, true, predecessorValues);

            //remove previous version of childnode nad update properties
            NodeData prevVersionHistory = (NodeData)dataManager.getItemData(prevVerHistoryId);

            PlainChangesLogImpl changesLog = new PlainChangesLogImpl();
            if (!prevVerHistoryId.equals(versionUuid))
            {
               RemoveVisitor rv = new RemoveVisitor();
               rv.visit(prevVersionHistory);
               changesLog.addAll(rv.getRemovedStates());
            }
            changesLog.add(ItemState.createAddedState(newVersionHistoryProp));
            changesLog.add(ItemState.createAddedState(newBaseVersionProp));
            changesLog.add(ItemState.createAddedState(newPredecessorsProp));

            PlainChangesLogImpl changesLogDelete = new PlainChangesLogImpl();
            changesLogDelete.add(ItemState.createDeletedState(propVersionHistory));
            changesLogDelete.add(ItemState.createDeletedState(propBaseVersion));
            changesLogDelete.add(ItemState.createDeletedState(propPredecessors));
            dataKeeper.save(changesLogDelete);
            // remove version history
            dataKeeper.save(changesLog);
            userSession.save();
            if (LOG.isDebugEnabled())
            {
               LOG.debug("Completed: Import version history for node with path="
                  + versionedChild.getQPath().getAsString() + " and UUID=" + versionedChild.getIdentifier());
            }
         }
      }
   }
90031
public void saveImplementedVersion(Page page, Integer version) {
        Integer previousImplementedVersion = getImplementedVersion(page);
        if (previousImplementedVersion != null && version != null && previousImplementedVersion == version)
            return;

        if (previousImplementedVersion != null)
            savePreviousImplementedVersion(page, previousImplementedVersion);

        String value = version != null ? String.valueOf(version) : null;
        ContentEntityObject entityObject = getContentEntityManager().getById(page.getId());
        getContentPropertyManager().setStringProperty(entityObject, IMPLEMENTED_VERSION, value);
    }
1203107
public List<Entity> pageForEntityList(Entity where, int page, int numPerPage) throws SQLException {
		return pageForEntityList(where, new Page(page, numPerPage));
	}
900447
public void savePreviousImplementedVersion(Page page, Integer version) {
        String value = version != null ? String.valueOf(version) : null;
        ContentEntityObject entityObject = getContentEntityManager().getById(page.getId());
        getContentPropertyManager().setStringProperty(entityObject, PREVIOUS_IMPLEMENTED_VERSION, value);
    }
786822
public function allSitePagesAction()
    {
        $entityMgr = $this->getServiceLocator()->get(
            'Doctrine\ORM\EntityManager'
        );
        $currentSite = $this->getServiceLocator()->get(
            \Rcm\Service\CurrentSite::class
        );
        $siteId = $currentSite->getSiteId();

        /** @var Site $site */
        $site = $entityMgr->getRepository(
            Site::class
        )->findOneBy(
            [
                'siteId' => $siteId
            ]
        );

        $pages = $site->getPages();

        $uriFormat = $this->params()->fromQuery('format', null);

        $return = [];

        /** @var Page $page */
        foreach ($pages as $page) {
            $pageName = $page->getName();
            $pageUrl = $this->urlToPage($pageName, $page->getPageType());

            if (!empty($uriFormat)
                && $uriFormat == 'tinyMceLinkList'
            ) {
                $return[] = [
                    'title' => $pageUrl,
                    'value' => $pageUrl
                ];
            } else {
                $return[$pageUrl] = $pageName;
            }
        }
        asort($return);

        return new JsonModel($return);
    }
1357781
public static VersionInfoProperties versionInfoProperties(final String version, final String commit, final String urlTemplate) {
        final VersionInfoProperties p = new VersionInfoProperties();
        p.version = version;
        p.commit = commit;
        p.urlTemplate = urlTemplate;
        return p;
    }
703177
private static String parseVersionId(String query) {
        if (query != null) {
            String[] params = VERSION_ID_PATTERN.split(query);
            for (String param : params) {
                if (param.startsWith("versionId=")) {
                    return decode(param.substring(10));
                }
            }
        }
        return null;
    }
737205
function getNewVersions() {
  return getTags()
    .then(tags => {
      var newVersions = []
      for(tag of tags) {
        if (semver.gt(tag.name, update.latest) || (
            semver.eq(tag.name, update.latest) && (semver(tag.name).build[0] || 0) > (semver(update.latest).build[0] || 0)
          )) {
          newVersions.push(tag)
        }
      }
      newVersions.reverse()
      // order versions from lower to greater
      console.log(chalk.blue('New versions available: ' + (newVersions.map(v => v.name).join(', ') || 'none') + '.'))
      return newVersions
    })
    .catch(e => console.log(e.stack))
}
992363
def post_versions_list(self, updater_name=None, updater_id=None,
                           post_id=None, start_id=None):
        
        params = {
            'search[updater_name]': updater_name,
            'search[updater_id]': updater_id,
            'search[post_id]': post_id,
            'search[start_id]': start_id
            }
        return self._get('post_versions.json', params)
1283464
function getAllTags(version, cwd, repo, cb) {
  var str = 'git for-each-ref --format="%(tag)" --sort=\'*authordate\' refs/tags | sed \'1!G;h;$!d\'';
  exec(str, {cwd: cwd}, function (err, stdout, stderr) {

    var output = '';

    if (err) { return cb(err); }

    var stdoutAsString = stdout.toString('utf8');

    // Get the latest tag
    var lastTag = stdoutAsString.split('\n')[0];

    getTagDate(lastTag, function (err, tagDateAsString) {
      if (err) { return cb(err); }

      output += format('## [%s] -%s\n\n', version, tagDateAsString);
      output += '### Fixed\n\n';

      var str = 'git --no-pager log --pretty="format:- [] %%s (\\`%%an\\`)%%n  https://github.com/%s/commit/%H" "%s..HEAD"';
      str = format(str, repo, lastTag);

      exec(str, {cwd: cwd}, function (err, stdout, stderr) {
        if (err) { return cb(err); }
        output += stdout;

        return cb(null, output);
      });
    });
  });
}
423614
static function load($class_name, $object_id, $version)
	{
		static $cache = array();
		$hash = '__load:'.$class_name.'-'.$object_id.'-'.$version;
		if(!empty($cache[$hash]))
			return $cache[$hash];

		$object = bors_load($class_name, $object_id);
//		echo $object;
		foreach(bors_find_all(__CLASS__, array(
			'target_class_name' => $class_name,
			'target_id' => $object_id,
			'target_version' => $version,
		)) as $x)
		{
//			echo "{$x->property_name()} = {$x->value()}<br/>\n";
			$object->set_attr('versioning_properties',
				array_merge(
					$object->attr('versioning_properties', array()),
					array($x->property_name() => $object->get($x->property_name()))
				)
			);

			$object->set($x->property_name(), $x->value(), false);
//			$object->set_attr('versioning_property', $x->property_name());
		}

		return $cache[$hash] = $object;
	}
719678
public Integer getPreviousImplementedVersion(Page page) {
        ContentEntityObject entityObject = getContentEntityManager().getById(page.getId());
        String value = getContentPropertyManager().getStringProperty(entityObject, PREVIOUS_IMPLEMENTED_VERSION);
        return value == null ? null : Integer.valueOf(value);
    }
898186
protected function updateDependentPages()
    {
        // Skip live stage
        if (Versioned::get_stage() === Versioned::LIVE) {
            return;
        }

        // Need to flush cache to avoid outdated versionnumber references
        $this->flushCache();

        // Need to mark pages depending to this one as broken
        /** @var Page $page */
        foreach ($this->DependentPages() as $page) {
            // Update sync link tracking
            $page->syncLinkTracking();
            if ($page->isChanged()) {
                $page->write();
            }
        }
    }
519581
private void parseVersionXML( final List versionList, final List platformList, final String dir,
                                  final JnlpResource versionRes )
    {
        if ( !versionRes.exists() )
        {
            return;
        }

        // Parse XML into a more understandable format
        XMLNode root = null;
        try
        {
            DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
            Document doc = docBuilder.parse( new BufferedInputStream( versionRes.getResource().openStream() ) );
            doc.getDocumentElement().normalize();

            // Convert document into an XMLNode structure, since we already got utility methods
            //  to handle these. We should really use the data-binding stuff here - but that will come
            //  later
            //
            root = XMLParsing.convert( doc.getDocumentElement() );
        }
        catch ( SAXParseException err )
        {
            _log.addWarning( "servlet.log.warning.xml.parsing", versionRes.getPath(),
                             Integer.toString( err.getLineNumber() ), err.getMessage() );
            return;
        }
        catch ( Throwable t )
        {
            _log.addWarning( "servlet.log.warning.xml.reading", versionRes.getPath(), t );
            return;
        }

        // Check that root element is a <jnlp> tag
        if ( !root.getName().equals( "jnlp-versions" ) )
        {
            _log.addWarning( "servlet.log.warning.xml.missing-jnlp", versionRes.getPath() );
            return;
        }

        // Visit all <resource> elements
        XMLParsing.visitElements( root, "<resource>", new XMLParsing.ElementVisitor()
        {
            public void visitElement( XMLNode node )
            {
                XMLNode pattern = XMLParsing.findElementPath( node, "<pattern>" );
                if ( pattern == null )
                {
                    _log.addWarning( "servlet.log.warning.xml.missing-pattern", versionRes.getPath() );
                }
                else
                {
                    // Parse pattern
                    String name = XMLParsing.getElementContent( pattern, "<name>", "" );
                    String versionId = XMLParsing.getElementContent( pattern, "<version-id>" );
                    String[] os = XMLParsing.getMultiElementContent( pattern, "<os>" );
                    String[] arch = XMLParsing.getMultiElementContent( pattern, "<arch>" );
                    String[] locale = XMLParsing.getMultiElementContent( pattern, "<locale>" );
                    // Get return request
                    String file = XMLParsing.getElementContent( node, "<file>" );
                    if ( versionId == null || file == null )
                    {
                        _log.addWarning( "servlet.log.warning.xml.missing-elems", versionRes.getPath() );
                    }
                    else
                    {
                        JnlpResource res =
                                new JnlpResource( _servletContext, name, versionId, os, arch, locale, dir + file,
                                                  versionId );
                        if ( res.exists() )
                        {
                            versionList.add( res );
                            if ( _log.isDebugLevel() )
                            {
                                _log.addDebug( "Read resource: " + res );
                            }
                        }
                        else
                        {
                            _log.addWarning( "servlet.log.warning.missing-file", file, versionRes.getPath() );
                        }
                    }
                }
            }
        } );

        // Visit all <resource> elements
        XMLParsing.visitElements( root, "<platform>", new XMLParsing.ElementVisitor()
        {
            public void visitElement( XMLNode node )
            {
                XMLNode pattern = XMLParsing.findElementPath( node, "<pattern>" );
                if ( pattern == null )
                {
                    _log.addWarning( "servlet.log.warning.xml.missing-pattern", versionRes.getPath() );
                }
                else
                {
                    // Parse pattern
                    String name = XMLParsing.getElementContent( pattern, "<name>", "" );
                    String versionId = XMLParsing.getElementContent( pattern, "<version-id>" );
                    String[] os = XMLParsing.getMultiElementContent( pattern, "<os>" );
                    String[] arch = XMLParsing.getMultiElementContent( pattern, "<arch>" );
                    String[] locale = XMLParsing.getMultiElementContent( pattern, "<locale>" );
                    // Get return request
                    String file = XMLParsing.getElementContent( node, "<file>" );
                    String productId = XMLParsing.getElementContent( node, "<product-version-id>" );

                    if ( versionId == null || file == null || productId == null )
                    {
                        _log.addWarning( "servlet.log.warning.xml.missing-elems2", versionRes.getPath() );
                    }
                    else
                    {
                        JnlpResource res =
                                new JnlpResource( _servletContext, name, versionId, os, arch, locale, dir + file,
                                                  productId );
                        if ( res.exists() )
                        {
                            platformList.add( res );
                            if ( _log.isDebugLevel() )
                            {
                                _log.addDebug( "Read platform resource: " + res );
                            }
                        }
                        else
                        {
                            _log.addWarning( "servlet.log.warning.missing-file", file, versionRes.getPath() );
                        }
                    }
                }
            }
        } );
    }
1293443
public void updateTags(Reference reference, Collection<String> tags) {
		getResourceFactory()
				.getApiResource("/tag/" + reference.toURLFragment())
				.entity(tags, MediaType.APPLICATION_JSON_TYPE).put();
	}