Returns the number of revisions for the specified article.

@param articleID
ID of the article
@return number of revisions

@throws WikiApiException
if an error occurs
771024
public int getNumberOfRevisions(final int articleID)
        throws WikiApiException
    {

        try {
            if (articleID < 1) {
                throw new IllegalArgumentException();
            }

            PreparedStatement statement = null;
            ResultSet result = null;
            String revCounters;

            try {
                // Retrieve the fullRevisionPK and calculate the limit
                statement = this.connection.prepareStatement("SELECT RevisionCounter "
                        + "FROM index_articleID_rc_ts " + "WHERE ArticleID=? LIMIT 1");
                statement.setInt(1, articleID);
                result = statement.executeQuery();

                if (result.next()) {

                    revCounters = result.getString(1);

                }
                else {
                    throw new WikiPageNotFoundException("The article with the ID " + articleID
                            + " was not found.");
                }
            }
            finally {
                if (statement != null) {
                    statement.close();
                }
                if (result != null) {
                    result.close();
                }
            }

            int index = revCounters.lastIndexOf(' ');
            if (index == -1) {
                throw new WikiApiException("Article data is inconsistent");
            }

            return Integer.parseInt(revCounters.substring(index + 1, revCounters.length()));

        }
        catch (WikiApiException e) {
            throw e;
        }
        catch (Exception e) {
            throw new WikiApiException(e);
        }
    }
1360676
@Override
	public TermedStatementDocument performEdit(WbEditingAction action, boolean editAsBot, String summary)
			throws IOException, MediaWikiApiErrorException {
		Map<String, TermImpl> labelUpdates = getLabelUpdates();
		Map<String, TermImpl> descriptionUpdates = getDescriptionUpdates();
		Map<String, List<TermImpl>> aliasUpdates = getAliasUpdates();
		if (labelUpdates.isEmpty() && descriptionUpdates.isEmpty() && aliasUpdates.isEmpty()) {
			return (TermedStatementDocument) super.performEdit(action, editAsBot, summary);	
		} else {
			if (super.isEmptyEdit()) {
				if(labelUpdates.size() == 1
					&& descriptionUpdates.isEmpty()
					&& aliasUpdates.isEmpty()) {
					// we only have a label in one language to update, so we use "wbsetlabel"
					String language = labelUpdates.keySet().iterator().next();
					MonolingualTextValue value = labelUpdates.get(language);
					
					JsonNode response = action.wbSetLabel(
							currentDocument.getEntityId().getId(),
							null, null, null, language, value.getText(), editAsBot,
							currentDocument.getRevisionId(), summary);
					
					MonolingualTextValue respondedLabel = getDatamodelObjectFromResponse(response,
							Arrays.asList("entity","labels",language), TermImpl.class);
					long revisionId = getRevisionIdFromResponse(response);
					
					return this.currentDocument.withRevisionId(revisionId).withLabel(respondedLabel);
				} else if (labelUpdates.isEmpty()
					&& descriptionUpdates.size() == 1
					&& aliasUpdates.isEmpty()) {
					// we only have a label in one language to update, so we use "wbsetlabel"
					String language = descriptionUpdates.keySet().iterator().next();
					MonolingualTextValue value = descriptionUpdates.get(language);
					
					JsonNode response = action.wbSetDescription(
							currentDocument.getEntityId().getId(),
							null, null, null, language, value.getText(), editAsBot,
							currentDocument.getRevisionId(), summary);
					
					MonolingualTextValue respondedDescription = getDatamodelObjectFromResponse(response,
							Arrays.asList("entity","descriptions",language), TermImpl.class);
					long revisionId = getRevisionIdFromResponse(response);
					
					return currentDocument.withRevisionId(revisionId).withDescription(respondedDescription);
				} else if (labelUpdates.isEmpty()
						&& descriptionUpdates.isEmpty()
						&& aliasUpdates.size() == 1) {
					// we only have aliases in one language to update, so we use "wbsetaliases"
					String language = aliasUpdates.keySet().iterator().next();
					List<MonolingualTextValue> addedValues = getAddedAliases(language);
					List<MonolingualTextValue> removedValues = getRemovedAliases(language);
					List<String> addedStrings = new ArrayList<>(addedValues.size());
					for(MonolingualTextValue v : addedValues) {
						addedStrings.add(v.getText());
					}
					List<String> removedStrings = new ArrayList<>(removedValues.size());
					for(MonolingualTextValue v : removedValues) {
						removedStrings.add(v.getText());
					}
					
					JsonNode response = action.wbSetAliases(
							currentDocument.getEntityId().getId(),
							null, null, null, language, addedStrings, removedStrings, null, editAsBot,
							currentDocument.getRevisionId(), summary);
					
					long revisionId = getRevisionIdFromResponse(response);

					TermImpl[] respondedAliases = getDatamodelObjectFromResponse(response,
							Arrays.asList("entity","aliases",language), TermImpl[].class);
					List<MonolingualTextValue> newAliases = Arrays.asList(respondedAliases);
					
					return currentDocument.withRevisionId(revisionId).withAliases(language, newAliases);
			    }
			}
			
			// All other cases: we do a full-blown "wbeditentity"
			EntityDocument response = action.wbEditEntity(currentDocument
				.getEntityId().getId(), null, null, null, getJsonUpdateString(),
				false, editAsBot, currentDocument
				.getRevisionId(), summary);
			return (TermedStatementDocument) response;
    	}
	}
276586
def wiki_versions_list(self, page_id, updater_id):
        
        params = {
            'earch[updater_id]': updater_id,
            'search[wiki_page_id]': page_id
            }
        return self._get('wiki_page_versions.json', params)
753445
def get_wikidata_qnum(wikiarticle, wikisite):
    
    resp = requests.get('https://www.wikidata.org/w/api.php', timeout=5, params={
        'action': 'wbgetentities',
        'titles': wikiarticle,
        'sites': wikisite,
        'props': '',
        'format': 'json'
    }).json()
    return list(resp['entities'])[0]
184028
public StatementDocument performEdit(WbEditingAction action, boolean editAsBot, String summary)
			throws IOException, MediaWikiApiErrorException {
		if (isEmptyEdit()) {
			return currentDocument;
		} else if (toDelete.isEmpty() && getUpdatedStatements().size() == 1) {
			// we can use "wbsetclaim" because we only have one statement to change
			List<Statement> statements = getUpdatedStatements();
			Statement statement = statements.get(0);
			
			if (statement.getStatementId() == null || statement.getStatementId().isEmpty()) {
				statement = statement.withStatementId(guidGenerator.freshStatementId(currentDocument.getEntityId().getId()));

			}
			
			JsonNode response = action.wbSetClaim(
						JsonSerializer.getJsonString(statement), editAsBot,
						currentDocument.getRevisionId(), summary);
			
			StatementImpl.PreStatement preStatement = getDatamodelObjectFromResponse(response, Collections.singletonList("claim"), StatementImpl.PreStatement.class);
			Statement returnedStatement = preStatement.withSubject(statement.getClaim().getSubject());
			long revisionId = getRevisionIdFromResponse(response);
			
			return currentDocument.withStatement(returnedStatement).withRevisionId(revisionId);
		} else if (!toDelete.isEmpty() && getUpdatedStatements().size() == toDelete.size() && toDelete.size() <= 50) {
			// we can use "wbremoveclaims" because we are only removing statements
			
			JsonNode response = action.wbRemoveClaims(toDelete, editAsBot, currentDocument.getRevisionId(), summary);
			
			long revisionId = getRevisionIdFromResponse(response);
			
			return currentDocument.withoutStatementIds(new HashSet<>(toDelete)).withRevisionId(revisionId);
		} else {
			return (StatementDocument) action.wbEditEntity(currentDocument
				.getEntityId().getId(), null, null, null, getJsonUpdateString(),
				false, editAsBot, currentDocument
				.getRevisionId(), summary);
		}
	}
337242
public Task<Revision> next()
		throws ArticleReaderException
	{

		try {
			this.keywords.reset();

			// if new article read header, otherwise use old one
			if (this.lastTaskCompleted) {
				this.lastTaskCompleted = false;

				this.taskPartCounter = 1;
				this.taskRevisionCounter = -1;

				if (!readHeader()) {

					this.lastTaskCompleted = true;
					return null;

				}
			}
			else {
				this.taskPartCounter++;
			}

			Task<Revision> task = new Task<Revision>(this.taskHeader,
					this.taskPartCounter);
			task.add(readRevision());

			int r = read();
			while (r != -1) {
				if (this.keywords.check((char) r)) {

					switch (this.keywords.getValue()) {

					case KEY_START_REVISION:

						if (task.byteSize() >= LIMIT_TASK_SIZE_REVISIONS) {
							this.lastTaskCompleted = false;

							if (this.taskPartCounter == 1) {
								task.setTaskType(TaskTypes.TASK_PARTIAL_FIRST);
							}
							else {
								task.setTaskType(TaskTypes.TASK_PARTIAL);
							}

							return task;
						}

						task.add(readRevision());
						break;

					case KEY_END_PAGE:

						this.lastTaskCompleted = true;
						if (this.taskPartCounter > 1) {
							task.setTaskType(TaskTypes.TASK_PARTIAL_LAST);
						}

						return task;

					default:
						throw new IOException();
					}

					this.keywords.reset();
				}

				r = read();
			}

			throw ErrorFactory
					.createArticleReaderException(ErrorKeys.DELTA_CONSUMERS_TASK_READER_WIKIPEDIAXMLREADER_UNEXPECTED_END_OF_FILE);

		}
		catch (ArticleReaderException e) {
			throw e;
		}
		catch (Exception e) {
			throw new ArticleReaderException(e);
		}
	}
550965
@Override
	public Task<Revision> next()
		throws ArticleReaderException
	{
		this.startTime = System.currentTimeMillis();

		Task<Revision> task = super.next();

		processingTimeRead += System.currentTimeMillis() - startTime;

		if (task != null) {
			if (task.getTaskType() == TaskTypes.TASK_PARTIAL_LAST
					|| task.getTaskType() == TaskTypes.TASK_FULL) {

				lastTaskCompleted = true;

				ArticleInformation info = task.getHeader();
				info.setEnteringTime(enteringTime);
				info.setOriginalSize(this.getBytePosition() - taskStartPosition);
				info.setProcessingTimeRead(processingTimeRead);
				info.setReadRevisionCounter(readRevisionCounter);

			}
			else {
				lastTaskCompleted = false;
			}
		}
		else {
			lastTaskCompleted = true;
		}

		return task;
	}
236368
def _get_next_version(self, revisions):
        
        versions = [0]
        for v in revisions:
            if v.isdigit():
                versions.append(int(v))
        return six.text_type(sorted(versions)[-1] + 1)
1141468
def page_revisions(request, page_id, template_name='wagtailrollbacks/edit_handlers/revisions.html'):
    
    page        = get_object_or_404(Page, pk=page_id)
    page_perms  = page.permissions_for_user(request.user)

    if not page_perms.can_edit():
        raise PermissionDenied

    page_num    = request.GET.get('p', 1)
    revisions   = get_revisions(page, page_num)

    return render(
        request,
        template_name,
        {
            'page':         page,
            'revisions':    revisions,
            'p':            page_num,
        }
    )
432658
public void close()
		throws WikiApiException
	{

		try {
			this.revisionIndex.finalizeIndex();
			this.chronoIndex.finalizeIndex();

			info.setEndRevisionCount(lastRev.getRevisionCounter());
			this.infoList.add(info);

			this.articleIndex.add(currentArticleID, startTime, endTime,
					infoList);
			this.articleIndex.finalizeIndex();

			send();

			this.indexWriter.finish();

			if (connection != null) {
				this.connection.close();
			}

		}
		catch (SQLException sql) {
			sql.printStackTrace();
			throw new WikiApiException(sql);
		}
		catch (IOException sql) {
			sql.printStackTrace();
			throw new WikiApiException(sql);
		}
	}
966919
public void generate()
		throws WikiApiException
	{
		Indexer data = null;
		try {
			data = new Indexer(config);

			System.out.println("GENERATING INDEX STARTED");

			long bufferSize = config.getBufferSize();
			Revision rev;
			long count = 0;
			long last = 0, now, start = System.currentTimeMillis();

			Iterator<Revision> it = new IndexIterator(config);
			while (it.hasNext()) {

				if (++count % bufferSize == 0) {
					now = System.currentTimeMillis() - start;
					System.out.println(Time.toClock(now) + "\t" + (now - last)
							+ "\tINDEXING " + count);
					last = now;
				}

				rev = it.next();
				data.index(rev);
			}

			System.out.println("GENERATING INDEX ENDED + ("
					+ Time.toClock(System.currentTimeMillis() - start) + ")");

		}
		catch (Exception e) {

			throw new WikiApiException(e);

		}
		finally {
			if (data != null) {
				data.close();
			}
		}
	}
436353
private int getNumDoc(String docID) {
    if (goneContext != null ) {
      removeDoc(docID);
    }
    for (int i = 0; i < documents.size(); i++) {
      if (documents.get(i).getDocID().equals(docID)) {  //  document exist
        if(!testMode && documents.get(i).getXComponent() == null) {
          XComponent xComponent = OfficeTools.getCurrentComponent(xContext);
          if (xComponent == null) {
            MessageHandler.printToLogFile("Error: Document (ID: " + docID + ") has no XComponent -> Internal space will not be deleted when document disposes");
          } else {
            try {
              xComponent.addEventListener(xEventListener);
            } catch (Throwable t) {
              MessageHandler.printToLogFile("Error: Document (ID: " + docID + ") has no XComponent -> Internal space will not be deleted when document disposes");
              xComponent = null;
            }
            if(xComponent != null) {
              documents.get(i).setXComponent(xContext, xComponent);
              MessageHandler.printToLogFile("Fixed: XComponent set for Document (ID: " + docID + ")");
            }
          }
        }
        return i;
      }
    }
    //  Add new document
    XComponent xComponent = null;
    if (!testMode) {              //  xComponent == null for test cases 
      xComponent = OfficeTools.getCurrentComponent(xContext);
      if (xComponent == null) {
        MessageHandler.printToLogFile("Error: Document (ID: " + docID + ") has no XComponent -> Internal space will not be deleted when document disposes");
      } else {
        try {
          xComponent.addEventListener(xEventListener);
        } catch (Throwable t) {
          MessageHandler.printToLogFile("Error: Document (ID: " + docID + ") has no XComponent -> Internal space will not be deleted when document disposes");
          xComponent = null;
        }
      }
    }
    documents.add(new SingleDocument(xContext, config, docID, xComponent));
    setMenuTextForSwitchOff(xContext);
    if (debugMode) {
      MessageHandler.printToLogFile("Document " + docNum + " created; docID = " + docID);
    }
    return documents.size() - 1;
  }
747855
public final int getTotalPages() {
    if (getTotalItems() < getPageSize()) {
      return 1;
    } else {
      final int remainder = getTotalItems() % getPageSize();
      final int quotient = getTotalItems() / getPageSize();
      return (0 == remainder) ? quotient : (quotient + 1);
    }
  }
1338793
def revision_number(self, value):
        
        if not isinstance(value, int) or value < 1:
            tmpl = "revision property requires positive int, got '%s'"
            raise ValueError(tmpl % value)
        revision = self.get_or_add_revision()
        revision.text = str(value)
1160871
public String getWikiAttachmentEndpoint(Object wikiId, Object attachmentId) throws BacklogException {
        return buildEndpoint("wikis/" + wikiId + "/attachments/" + attachmentId);
    }
33424
public function getPublishedRevisionId($siteId, $name, $type = PageTypes::NORMAL)
    {
        /** @var \Doctrine\ORM\QueryBuilder $queryBuilder */
        $queryBuilder = $this->_em->createQueryBuilder();
        $queryBuilder->select('publishedRevision.revisionId')
            ->from(\Rcm\Entity\Page::class, 'page')
            ->join('page.publishedRevision', 'publishedRevision')
            ->join('page.site', 'site')
            ->where('site.siteId = :siteId')
            ->andWhere('page.name = :pageName')
            ->andWhere('page.pageType = :pageType')
            ->setParameter('siteId', $siteId)
            ->setParameter('pageName', $name)
            ->setParameter('pageType', $type);

        try {
            return $queryBuilder->getQuery()->getSingleScalarResult();
        } catch (NoResultException $e) {
            return null;
        }
    }
1335916
@Override
	public Revision next()
	{
		try {

			int revCount, articleID;

			revCount = result.getInt(3);
			articleID = result.getInt(5);

			if (articleID != this.currentArticleID) {
				this.currentRevCounter = 0;
				this.currentArticleID = articleID;
			}

			if (revCount - 1 != this.currentRevCounter) {

				logger.error("Invalid RevCounter -" + " [ArticleId "
						+ articleID + ", RevisionId " + result.getInt(4)
						+ ", RevisionCounter " +revCount + "] - Expected: "
						+ (this.currentRevCounter + 1));

				this.currentRevCounter = revCount;
				this.previousRevision = null;

				return null;
			}

			this.currentRevCounter = revCount;
			this.primaryKey = result.getInt(1);

			Revision revision = new Revision(revCount);
			revision.setPrimaryKey(this.primaryKey);
			if (!shouldLoadRevisionText) {
				String currentRevision;

				Diff diff;
				RevisionDecoder decoder = new RevisionDecoder(
						config.getCharacterSet());

				if (binaryData) {
					decoder.setInput(result.getBinaryStream(2), true);
				}
				else {
					decoder.setInput(result.getString(2));
				}
				diff = decoder.decode();

				try {
					currentRevision = diff.buildRevision(previousRevision);
				}
				catch (Exception e) {
					this.previousRevision = null;
					logger.error("Reconstruction failed -"
							+ " [ArticleId " + result.getInt(5)
							+ ", RevisionId " + result.getInt(4)
							+ ", RevisionCounter " + result.getInt(3) + "]");
					return null;
				}

				previousRevision = currentRevision;
				revision.setRevisionText(currentRevision);
			} else {
				if(revApi==null){
					revApi = new RevisionApi(config);
				}
				revision.setRevisionApi(revApi);
			}

			revision.setRevisionID(result.getInt(4));
			revision.setArticleID(articleID);
			revision.setTimeStamp(new Timestamp(result.getLong(6)));
			revision.setFullRevisionID(result.getInt(7));
			revision.setContributorName(result.getString(8));
			revision.setContributorId(result.getInt(9));
			revision.setComment(result.getString(10));
			revision.setMinor(result.getBoolean(11));
			revision.setContributorIsRegistered(result.getBoolean(12));

			return revision;

		}
		catch (DecodingException | SQLException | IOException | WikiApiException e) {
			throw new RuntimeException(e);
		}
	}