| | |
| | | |
| | | /** |
| | | * Start the service. |
| | | * |
| | | * @since 1.4.0 |
| | | */ |
| | | public abstract ITicketService start(); |
| | | |
| | | /** |
| | | * Stop the service. |
| | | * |
| | | * @since 1.4.0 |
| | | */ |
| | | public final ITicketService stop() { |
| | | indexer.close(); |
| | |
| | | |
| | | /** |
| | | * Creates a ticket notifier. The ticket notifier is not thread-safe! |
| | | * |
| | | * @since 1.4.0 |
| | | */ |
| | | public TicketNotifier createNotifier() { |
| | | return new TicketNotifier( |
| | |
| | | * Returns the ready status of the ticket service. |
| | | * |
| | | * @return true if the ticket service is ready |
| | | * @since 1.4.0 |
| | | */ |
| | | public boolean isReady() { |
| | | return true; |
| | |
| | | * |
| | | * @param repository |
| | | * @return true if patchsets are being accepted |
| | | * @since 1.4.0 |
| | | */ |
| | | public boolean isAcceptingNewPatchsets(RepositoryModel repository) { |
| | | return isReady() |
| | |
| | | * |
| | | * @param repository |
| | | * @return true if tickets are being accepted |
| | | * @since 1.4.0 |
| | | */ |
| | | public boolean isAcceptingNewTickets(RepositoryModel repository) { |
| | | return isReady() |
| | |
| | | * |
| | | * @param repository |
| | | * @return true if tickets are allowed to be updated |
| | | * @since 1.4.0 |
| | | */ |
| | | public boolean isAcceptingTicketUpdates(RepositoryModel repository) { |
| | | return isReady() |
| | |
| | | * Returns true if the repository has any tickets |
| | | * @param repository |
| | | * @return true if the repository has tickets |
| | | * @since 1.4.0 |
| | | */ |
| | | public boolean hasTickets(RepositoryModel repository) { |
| | | return indexer.hasTickets(repository); |
| | |
| | | |
| | | /** |
| | | * Closes any open resources used by this service. |
| | | * @since 1.4.0 |
| | | */ |
| | | protected abstract void close(); |
| | | |
| | | /** |
| | | * Reset all caches in the service. |
| | | * @since 1.4.0 |
| | | */ |
| | | public final synchronized void resetCaches() { |
| | | ticketsCache.invalidateAll(); |
| | |
| | | resetCachesImpl(); |
| | | } |
| | | |
| | | /** |
| | | * Reset all caches in the service. |
| | | * @since 1.4.0 |
| | | */ |
| | | protected abstract void resetCachesImpl(); |
| | | |
| | | /** |
| | | * Reset any caches for the repository in the service. |
| | | * @since 1.4.0 |
| | | */ |
| | | public final synchronized void resetCaches(RepositoryModel repository) { |
| | | List<TicketKey> repoKeys = new ArrayList<TicketKey>(); |
| | |
| | | resetCachesImpl(repository); |
| | | } |
| | | |
| | | /** |
| | | * Reset the caches for the specified repository. |
| | | * |
| | | * @param repository |
| | | * @since 1.4.0 |
| | | */ |
| | | protected abstract void resetCachesImpl(RepositoryModel repository); |
| | | |
| | | |
| | |
| | | * |
| | | * @param repository |
| | | * @return the list of labels |
| | | * @since 1.4.0 |
| | | */ |
| | | public List<TicketLabel> getLabels(RepositoryModel repository) { |
| | | String key = repository.name; |
| | |
| | | * @param repository |
| | | * @param label |
| | | * @return a TicketLabel |
| | | * @since 1.4.0 |
| | | */ |
| | | public TicketLabel getLabel(RepositoryModel repository, String label) { |
| | | for (TicketLabel tl : getLabels(repository)) { |
| | |
| | | * @param milestone |
| | | * @param createdBy |
| | | * @return the label |
| | | * @since 1.4.0 |
| | | */ |
| | | public synchronized TicketLabel createLabel(RepositoryModel repository, String label, String createdBy) { |
| | | TicketLabel lb = new TicketMilestone(label); |
| | |
| | | * @param label |
| | | * @param createdBy |
| | | * @return true if the update was successful |
| | | * @since 1.4.0 |
| | | */ |
| | | public synchronized boolean updateLabel(RepositoryModel repository, TicketLabel label, String createdBy) { |
| | | Repository db = null; |
| | |
| | | * @param newName |
| | | * @param createdBy |
| | | * @return true if the rename was successful |
| | | * @since 1.4.0 |
| | | */ |
| | | public synchronized boolean renameLabel(RepositoryModel repository, String oldName, String newName, String createdBy) { |
| | | if (StringUtils.isEmpty(newName)) { |
| | |
| | | * @param label |
| | | * @param createdBy |
| | | * @return true if the delete was successful |
| | | * @since 1.4.0 |
| | | */ |
| | | public synchronized boolean deleteLabel(RepositoryModel repository, String label, String createdBy) { |
| | | if (StringUtils.isEmpty(label)) { |
| | |
| | | * |
| | | * @param repository |
| | | * @return the list of milestones |
| | | * @since 1.4.0 |
| | | */ |
| | | public List<TicketMilestone> getMilestones(RepositoryModel repository) { |
| | | String key = repository.name; |
| | |
| | | * @param repository |
| | | * @param status |
| | | * @return the list of milestones |
| | | * @since 1.4.0 |
| | | */ |
| | | public List<TicketMilestone> getMilestones(RepositoryModel repository, Status status) { |
| | | List<TicketMilestone> matches = new ArrayList<TicketMilestone>(); |
| | |
| | | * @param repository |
| | | * @param milestone |
| | | * @return the milestone or null if it does not exist |
| | | * @since 1.4.0 |
| | | */ |
| | | public TicketMilestone getMilestone(RepositoryModel repository, String milestone) { |
| | | for (TicketMilestone ms : getMilestones(repository)) { |
| | |
| | | * @param milestone |
| | | * @param createdBy |
| | | * @return the milestone |
| | | * @since 1.4.0 |
| | | */ |
| | | public synchronized TicketMilestone createMilestone(RepositoryModel repository, String milestone, String createdBy) { |
| | | TicketMilestone ms = new TicketMilestone(milestone); |
| | |
| | | * @param milestone |
| | | * @param createdBy |
| | | * @return true if successful |
| | | * @since 1.4.0 |
| | | */ |
| | | public synchronized boolean updateMilestone(RepositoryModel repository, TicketMilestone milestone, String createdBy) { |
| | | Repository db = null; |
| | |
| | | * @param newName |
| | | * @param createdBy |
| | | * @return true if successful |
| | | * @since 1.4.0 |
| | | */ |
| | | public synchronized boolean renameMilestone(RepositoryModel repository, String oldName, String newName, String createdBy) { |
| | | if (StringUtils.isEmpty(newName)) { |
| | |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * Deletes a milestone. |
| | | * |
| | |
| | | * @param milestone |
| | | * @param createdBy |
| | | * @return true if successful |
| | | * @since 1.4.0 |
| | | */ |
| | | public synchronized boolean deleteMilestone(RepositoryModel repository, String milestone, String createdBy) { |
| | | if (StringUtils.isEmpty(milestone)) { |
| | |
| | | * |
| | | * @param repository |
| | | * @return a new ticket id |
| | | * @since 1.4.0 |
| | | */ |
| | | public abstract long assignNewId(RepositoryModel repository); |
| | | |
| | |
| | | * @param repository |
| | | * @param ticketId |
| | | * @return true if the ticket exists |
| | | * @since 1.4.0 |
| | | */ |
| | | public abstract boolean hasTicket(RepositoryModel repository, long ticketId); |
| | | |
| | |
| | | * |
| | | * @param repository |
| | | * @return all tickets |
| | | * @since 1.4.0 |
| | | */ |
| | | public List<TicketModel> getTickets(RepositoryModel repository) { |
| | | return getTickets(repository, null); |
| | |
| | | * @param filter |
| | | * optional issue filter to only return matching results |
| | | * @return a list of tickets |
| | | * @since 1.4.0 |
| | | */ |
| | | public abstract List<TicketModel> getTickets(RepositoryModel repository, TicketFilter filter); |
| | | |
| | |
| | | * @param repository |
| | | * @param ticketId |
| | | * @return a ticket, if it exists, otherwise null |
| | | * @since 1.4.0 |
| | | */ |
| | | public final TicketModel getTicket(RepositoryModel repository, long ticketId) { |
| | | TicketKey key = new TicketKey(repository, ticketId); |
| | | TicketModel ticket = ticketsCache.getIfPresent(key); |
| | | |
| | | |
| | | // if ticket not cached |
| | | if (ticket == null) { |
| | | //load ticket |
| | |
| | | * @param repository |
| | | * @param ticketId |
| | | * @return a ticket, if it exists, otherwise null |
| | | * @since 1.4.0 |
| | | */ |
| | | protected abstract TicketModel getTicketImpl(RepositoryModel repository, long ticketId); |
| | | |
| | |
| | | * |
| | | * @param ticket |
| | | * @return the ticket url |
| | | * @since 1.4.0 |
| | | */ |
| | | public String getTicketUrl(TicketModel ticket) { |
| | | final String canonicalUrl = settings.getString(Keys.web.canonicalUrl, "https://localhost:8443"); |
| | |
| | | * @param base |
| | | * @param tip |
| | | * @return the compare url |
| | | * @since 1.4.0 |
| | | */ |
| | | public String getCompareUrl(TicketModel ticket, String base, String tip) { |
| | | final String canonicalUrl = settings.getString(Keys.web.canonicalUrl, "https://localhost:8443"); |
| | |
| | | * Returns true if attachments are supported. |
| | | * |
| | | * @return true if attachments are supported |
| | | * @since 1.4.0 |
| | | */ |
| | | public abstract boolean supportsAttachments(); |
| | | |
| | |
| | | * @param ticketId |
| | | * @param filename |
| | | * @return an attachment, if found, null otherwise |
| | | * @since 1.4.0 |
| | | */ |
| | | public abstract Attachment getAttachment(RepositoryModel repository, long ticketId, String filename); |
| | | |
| | |
| | | * @param repository |
| | | * @param change |
| | | * @return true if successful |
| | | * @since 1.4.0 |
| | | */ |
| | | public TicketModel createTicket(RepositoryModel repository, Change change) { |
| | | return createTicket(repository, 0L, change); |
| | |
| | | * @param ticketId (if <=0 the ticket id will be assigned) |
| | | * @param change |
| | | * @return true if successful |
| | | * @since 1.4.0 |
| | | */ |
| | | public TicketModel createTicket(RepositoryModel repository, long ticketId, Change change) { |
| | | |
| | |
| | | * @param ticketId |
| | | * @param change |
| | | * @return the ticket model if successful |
| | | * @since 1.4.0 |
| | | */ |
| | | public final TicketModel updateTicket(RepositoryModel repository, long ticketId, Change change) { |
| | | if (change == null) { |
| | |
| | | * Deletes all tickets in every repository. |
| | | * |
| | | * @return true if successful |
| | | * @since 1.4.0 |
| | | */ |
| | | public boolean deleteAll() { |
| | | List<String> repositories = repositoryManager.getRepositoryList(); |
| | |
| | | * Deletes all tickets in the specified repository. |
| | | * @param repository |
| | | * @return true if succesful |
| | | * @since 1.4.0 |
| | | */ |
| | | public boolean deleteAll(RepositoryModel repository) { |
| | | boolean success = deleteAllImpl(repository); |
| | |
| | | return success; |
| | | } |
| | | |
| | | /** |
| | | * Delete all tickets for the specified repository. |
| | | * @param repository |
| | | * @return true if successful |
| | | * @since 1.4.0 |
| | | */ |
| | | protected abstract boolean deleteAllImpl(RepositoryModel repository); |
| | | |
| | | /** |
| | |
| | | * @param oldRepositoryName |
| | | * @param newRepositoryName |
| | | * @return true if successful |
| | | * @since 1.4.0 |
| | | */ |
| | | public boolean rename(RepositoryModel oldRepository, RepositoryModel newRepository) { |
| | | if (renameImpl(oldRepository, newRepository)) { |
| | |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * Renames a repository. |
| | | * |
| | | * @param oldRepository |
| | | * @param newRepository |
| | | * @return true if successful |
| | | * @since 1.4.0 |
| | | */ |
| | | protected abstract boolean renameImpl(RepositoryModel oldRepository, RepositoryModel newRepository); |
| | | |
| | | /** |
| | |
| | | * @param ticketId |
| | | * @param deletedBy |
| | | * @return true if successful |
| | | * @since 1.4.0 |
| | | */ |
| | | public boolean deleteTicket(RepositoryModel repository, long ticketId, String deletedBy) { |
| | | TicketModel ticket = getTicket(repository, ticketId); |
| | |
| | | * @param ticket |
| | | * @param deletedBy |
| | | * @return true if successful |
| | | * @since 1.4.0 |
| | | */ |
| | | protected abstract boolean deleteTicketImpl(RepositoryModel repository, TicketModel ticket, String deletedBy); |
| | | |
| | |
| | | * @param comment |
| | | * the revised comment |
| | | * @return the revised ticket if the change was successful |
| | | * @since 1.4.0 |
| | | */ |
| | | public final TicketModel updateComment(TicketModel ticket, String commentId, |
| | | String updatedBy, String comment) { |
| | |
| | | * @param deletedBy |
| | | * the user deleting the comment |
| | | * @return the revised ticket if the deletion was successful |
| | | * @since 1.4.0 |
| | | */ |
| | | public final TicketModel deleteComment(TicketModel ticket, String commentId, String deletedBy) { |
| | | Change deletion = new Change(deletedBy); |
| | |
| | | * @param ticketId |
| | | * @param change |
| | | * @return true, if the change was committed |
| | | * @since 1.4.0 |
| | | */ |
| | | protected abstract boolean commitChangeImpl(RepositoryModel repository, long ticketId, Change change); |
| | | |
| | |
| | | * @param page |
| | | * @param pageSize |
| | | * @return a list of matching tickets |
| | | * @since 1.4.0 |
| | | */ |
| | | public List<QueryResult> searchFor(RepositoryModel repository, String text, int page, int pageSize) { |
| | | return indexer.searchFor(repository, text, page, pageSize); |
| | |
| | | * @param sortBy |
| | | * @param descending |
| | | * @return a list of matching tickets or an empty list |
| | | * @since 1.4.0 |
| | | */ |
| | | public List<QueryResult> queryFor(String query, int page, int pageSize, String sortBy, boolean descending) { |
| | | return indexer.queryFor(query, page, pageSize, sortBy, descending); |
| | |
| | | /** |
| | | * Destroys an existing index and reindexes all tickets. |
| | | * This operation may be expensive and time-consuming. |
| | | * @since 1.4.0 |
| | | */ |
| | | public void reindex() { |
| | | long start = System.nanoTime(); |
| | |
| | | /** |
| | | * Destroys any existing index and reindexes all tickets. |
| | | * This operation may be expensive and time-consuming. |
| | | * @since 1.4.0 |
| | | */ |
| | | public void reindex(RepositoryModel repository) { |
| | | long start = System.nanoTime(); |
| | |
| | | * of ticket updates, namely merging from the web ui. |
| | | * |
| | | * @param runnable |
| | | * @since 1.4.0 |
| | | */ |
| | | public synchronized void exec(Runnable runnable) { |
| | | runnable.run(); |