summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/com/gitblit/AccessRestrictionFilter.java34
-rw-r--r--src/main/java/com/gitblit/AddIndexedBranch.java26
-rw-r--r--src/main/java/com/gitblit/AuthenticationFilter.java16
-rw-r--r--src/main/java/com/gitblit/BranchGraphServlet.java10
-rw-r--r--src/main/java/com/gitblit/ConfigUserService.java123
-rw-r--r--src/main/java/com/gitblit/Constants.java132
-rw-r--r--src/main/java/com/gitblit/DownloadZipFilter.java16
-rw-r--r--src/main/java/com/gitblit/DownloadZipServlet.java26
-rw-r--r--src/main/java/com/gitblit/EnforceAuthenticationFilter.java24
-rw-r--r--src/main/java/com/gitblit/FederationClient.java6
-rw-r--r--src/main/java/com/gitblit/FederationPullExecutor.java20
-rw-r--r--src/main/java/com/gitblit/FederationServlet.java8
-rw-r--r--src/main/java/com/gitblit/FileSettings.java11
-rw-r--r--src/main/java/com/gitblit/GCExecutor.java52
-rw-r--r--src/main/java/com/gitblit/GitBlit.java594
-rw-r--r--src/main/java/com/gitblit/GitBlitException.java4
-rw-r--r--src/main/java/com/gitblit/GitBlitServer.java52
-rw-r--r--src/main/java/com/gitblit/GitFilter.java34
-rw-r--r--src/main/java/com/gitblit/GitblitSslContextFactory.java12
-rw-r--r--src/main/java/com/gitblit/GitblitTrustManager.java18
-rw-r--r--src/main/java/com/gitblit/HtpasswdUserService.java20
-rw-r--r--src/main/java/com/gitblit/IStoredSettings.java48
-rw-r--r--src/main/java/com/gitblit/IUserService.java109
-rw-r--r--src/main/java/com/gitblit/JsonServlet.java10
-rw-r--r--src/main/java/com/gitblit/Launcher.java6
-rw-r--r--src/main/java/com/gitblit/LdapUserService.java95
-rw-r--r--src/main/java/com/gitblit/LogoServlet.java14
-rw-r--r--src/main/java/com/gitblit/LuceneExecutor.java220
-rw-r--r--src/main/java/com/gitblit/MailExecutor.java23
-rw-r--r--src/main/java/com/gitblit/PAMUserService.java14
-rw-r--r--src/main/java/com/gitblit/PagesFilter.java28
-rw-r--r--src/main/java/com/gitblit/PagesServlet.java8
-rw-r--r--src/main/java/com/gitblit/RedmineUserService.java23
-rw-r--r--src/main/java/com/gitblit/RobotsTxtServlet.java6
-rw-r--r--src/main/java/com/gitblit/RpcFilter.java10
-rw-r--r--src/main/java/com/gitblit/RpcServlet.java6
-rw-r--r--src/main/java/com/gitblit/SalesforceUserService.java9
-rw-r--r--src/main/java/com/gitblit/SparkleShareInviteServlet.java22
-rw-r--r--src/main/java/com/gitblit/SyndicationFilter.java12
-rw-r--r--src/main/java/com/gitblit/SyndicationServlet.java32
-rw-r--r--src/main/java/com/gitblit/WebXmlSettings.java6
-rw-r--r--src/main/java/com/gitblit/WindowsUserService.java18
-rw-r--r--src/main/java/com/gitblit/authority/AuthorityWorker.java1
-rw-r--r--src/main/java/com/gitblit/authority/CertificateStatusRenderer.java5
-rw-r--r--src/main/java/com/gitblit/authority/CertificatesTableModel.java13
-rw-r--r--src/main/java/com/gitblit/authority/DefaultOidsPanel.java16
-rw-r--r--src/main/java/com/gitblit/authority/GitblitAuthority.java168
-rw-r--r--src/main/java/com/gitblit/authority/Launcher.java19
-rw-r--r--src/main/java/com/gitblit/authority/NewCertificateConfig.java17
-rw-r--r--src/main/java/com/gitblit/authority/NewClientCertificateDialog.java48
-rw-r--r--src/main/java/com/gitblit/authority/NewSSLCertificateDialog.java34
-rw-r--r--src/main/java/com/gitblit/authority/RequestFocusListener.java2
-rw-r--r--src/main/java/com/gitblit/authority/UserCertificateConfig.java15
-rw-r--r--src/main/java/com/gitblit/authority/UserCertificateModel.java14
-rw-r--r--src/main/java/com/gitblit/authority/UserCertificatePanel.java79
-rw-r--r--src/main/java/com/gitblit/authority/UserCertificateTableModel.java7
-rw-r--r--src/main/java/com/gitblit/authority/UserOidsPanel.java14
-rw-r--r--src/main/java/com/gitblit/authority/Utils.java27
-rw-r--r--src/main/java/com/gitblit/authority/X509CertificateViewer.java29
-rw-r--r--src/main/java/com/gitblit/client/BooleanCellRenderer.java5
-rw-r--r--src/main/java/com/gitblit/client/BranchRenderer.java7
-rw-r--r--src/main/java/com/gitblit/client/ClosableTabComponent.java4
-rw-r--r--src/main/java/com/gitblit/client/DateCellRenderer.java7
-rw-r--r--src/main/java/com/gitblit/client/EditRegistrationDialog.java8
-rw-r--r--src/main/java/com/gitblit/client/EditRepositoryDialog.java93
-rw-r--r--src/main/java/com/gitblit/client/EditTeamDialog.java23
-rw-r--r--src/main/java/com/gitblit/client/EditUserDialog.java49
-rw-r--r--src/main/java/com/gitblit/client/FeedEntryTableModel.java7
-rw-r--r--src/main/java/com/gitblit/client/FeedsPanel.java17
-rw-r--r--src/main/java/com/gitblit/client/FeedsTableModel.java7
-rw-r--r--src/main/java/com/gitblit/client/GitblitClient.java32
-rw-r--r--src/main/java/com/gitblit/client/GitblitManager.java8
-rw-r--r--src/main/java/com/gitblit/client/GitblitManagerLauncher.java19
-rw-r--r--src/main/java/com/gitblit/client/GitblitPanel.java19
-rw-r--r--src/main/java/com/gitblit/client/GitblitRegistration.java4
-rw-r--r--src/main/java/com/gitblit/client/GitblitWorker.java1
-rw-r--r--src/main/java/com/gitblit/client/IndicatorsRenderer.java8
-rw-r--r--src/main/java/com/gitblit/client/JPalette.java11
-rw-r--r--src/main/java/com/gitblit/client/MessageRenderer.java17
-rw-r--r--src/main/java/com/gitblit/client/NameRenderer.java5
-rw-r--r--src/main/java/com/gitblit/client/PropertiesTableModel.java7
-rw-r--r--src/main/java/com/gitblit/client/RegistrantPermissionsPanel.java27
-rw-r--r--src/main/java/com/gitblit/client/RegistrantPermissionsTableModel.java11
-rw-r--r--src/main/java/com/gitblit/client/RegistrationsDialog.java11
-rw-r--r--src/main/java/com/gitblit/client/RegistrationsTableModel.java7
-rw-r--r--src/main/java/com/gitblit/client/RepositoriesPanel.java25
-rw-r--r--src/main/java/com/gitblit/client/RepositoriesTableModel.java7
-rw-r--r--src/main/java/com/gitblit/client/SearchDialog.java13
-rw-r--r--src/main/java/com/gitblit/client/SettingCellRenderer.java5
-rw-r--r--src/main/java/com/gitblit/client/SettingPanel.java2
-rw-r--r--src/main/java/com/gitblit/client/SettingsPanel.java12
-rw-r--r--src/main/java/com/gitblit/client/SettingsTableModel.java7
-rw-r--r--src/main/java/com/gitblit/client/StatusPanel.java5
-rw-r--r--src/main/java/com/gitblit/client/SubscribedRepositoryRenderer.java5
-rw-r--r--src/main/java/com/gitblit/client/SubscriptionsDialog.java8
-rw-r--r--src/main/java/com/gitblit/client/TeamsPanel.java16
-rw-r--r--src/main/java/com/gitblit/client/TeamsTableModel.java7
-rw-r--r--src/main/java/com/gitblit/client/Translation.java10
-rw-r--r--src/main/java/com/gitblit/client/UsersPanel.java22
-rw-r--r--src/main/java/com/gitblit/client/UsersTableModel.java7
-rw-r--r--src/main/java/com/gitblit/client/Utils.java6
-rw-r--r--src/main/java/com/gitblit/fanout/FanoutClient.java64
-rw-r--r--src/main/java/com/gitblit/fanout/FanoutConstants.java4
-rw-r--r--src/main/java/com/gitblit/fanout/FanoutNioService.java43
-rw-r--r--src/main/java/com/gitblit/fanout/FanoutService.java142
-rw-r--r--src/main/java/com/gitblit/fanout/FanoutServiceConnection.java18
-rw-r--r--src/main/java/com/gitblit/fanout/FanoutSocketService.java26
-rw-r--r--src/main/java/com/gitblit/fanout/FanoutStats.java16
-rw-r--r--src/main/java/com/gitblit/git/GitDaemon.java22
-rw-r--r--src/main/java/com/gitblit/git/GitDaemonClient.java6
-rw-r--r--src/main/java/com/gitblit/git/GitDaemonService.java1
-rw-r--r--src/main/java/com/gitblit/git/GitServlet.java4
-rw-r--r--src/main/java/com/gitblit/git/GitblitReceivePack.java2
-rw-r--r--src/main/java/com/gitblit/git/GitblitUploadPackFactory.java14
-rw-r--r--src/main/java/com/gitblit/git/RepositoryResolver.java14
-rw-r--r--src/main/java/com/gitblit/models/Activity.java18
-rw-r--r--src/main/java/com/gitblit/models/AnnotatedLine.java4
-rw-r--r--src/main/java/com/gitblit/models/DailyLogEntry.java13
-rw-r--r--src/main/java/com/gitblit/models/FederationModel.java14
-rw-r--r--src/main/java/com/gitblit/models/FederationProposal.java4
-rw-r--r--src/main/java/com/gitblit/models/FederationSet.java2
-rw-r--r--src/main/java/com/gitblit/models/FeedEntryModel.java2
-rw-r--r--src/main/java/com/gitblit/models/FeedModel.java2
-rw-r--r--src/main/java/com/gitblit/models/ForkModel.java22
-rw-r--r--src/main/java/com/gitblit/models/GitClientApplication.java10
-rw-r--r--src/main/java/com/gitblit/models/GitNote.java4
-rw-r--r--src/main/java/com/gitblit/models/GravatarProfile.java6
-rw-r--r--src/main/java/com/gitblit/models/Metric.java4
-rw-r--r--src/main/java/com/gitblit/models/PathModel.java18
-rw-r--r--src/main/java/com/gitblit/models/ProjectModel.java16
-rw-r--r--src/main/java/com/gitblit/models/RefLogEntry.java80
-rw-r--r--src/main/java/com/gitblit/models/RefModel.java4
-rw-r--r--src/main/java/com/gitblit/models/RegistrantAccessPermission.java24
-rw-r--r--src/main/java/com/gitblit/models/RepositoryCommit.java14
-rw-r--r--src/main/java/com/gitblit/models/RepositoryModel.java44
-rw-r--r--src/main/java/com/gitblit/models/RepositoryUrl.java4
-rw-r--r--src/main/java/com/gitblit/models/SearchResult.java22
-rw-r--r--src/main/java/com/gitblit/models/ServerSettings.java12
-rw-r--r--src/main/java/com/gitblit/models/ServerStatus.java4
-rw-r--r--src/main/java/com/gitblit/models/SettingModel.java22
-rw-r--r--src/main/java/com/gitblit/models/SubmoduleModel.java7
-rw-r--r--src/main/java/com/gitblit/models/TeamModel.java40
-rw-r--r--src/main/java/com/gitblit/models/UserModel.java94
-rw-r--r--src/main/java/com/gitblit/models/UserPreferences.java14
-rw-r--r--src/main/java/com/gitblit/models/UserRepositoryPreferences.java8
-rw-r--r--src/main/java/com/gitblit/utils/ActivityUtils.java22
-rw-r--r--src/main/java/com/gitblit/utils/ArrayUtils.java10
-rw-r--r--src/main/java/com/gitblit/utils/Base64.java14
-rw-r--r--src/main/java/com/gitblit/utils/ByteFormat.java12
-rw-r--r--src/main/java/com/gitblit/utils/ClientLogger.java10
-rw-r--r--src/main/java/com/gitblit/utils/CommitCache.java68
-rw-r--r--src/main/java/com/gitblit/utils/CompressionUtils.java36
-rw-r--r--src/main/java/com/gitblit/utils/ConnectionUtils.java12
-rw-r--r--src/main/java/com/gitblit/utils/ContainerUtils.java8
-rw-r--r--src/main/java/com/gitblit/utils/DeepCopier.java3
-rw-r--r--src/main/java/com/gitblit/utils/DiffUtils.java38
-rw-r--r--src/main/java/com/gitblit/utils/FederationUtils.java26
-rw-r--r--src/main/java/com/gitblit/utils/FileUtils.java40
-rw-r--r--src/main/java/com/gitblit/utils/GitBlitDiffFormatter.java26
-rw-r--r--src/main/java/com/gitblit/utils/HttpUtils.java34
-rw-r--r--src/main/java/com/gitblit/utils/JGitUtils.java172
-rw-r--r--src/main/java/com/gitblit/utils/JnaUtils.java6
-rw-r--r--src/main/java/com/gitblit/utils/JsonUtils.java32
-rw-r--r--src/main/java/com/gitblit/utils/MarkdownUtils.java8
-rw-r--r--src/main/java/com/gitblit/utils/MetricUtils.java12
-rw-r--r--src/main/java/com/gitblit/utils/ModelUtils.java2
-rw-r--r--src/main/java/com/gitblit/utils/ObjectCache.java6
-rw-r--r--src/main/java/com/gitblit/utils/PatchFormatter.java5
-rw-r--r--src/main/java/com/gitblit/utils/RefLogUtils.java78
-rw-r--r--src/main/java/com/gitblit/utils/RpcUtils.java90
-rw-r--r--src/main/java/com/gitblit/utils/StringUtils.java108
-rw-r--r--src/main/java/com/gitblit/utils/SyndicationUtils.java12
-rw-r--r--src/main/java/com/gitblit/utils/TimeUtils.java40
-rw-r--r--src/main/java/com/gitblit/utils/X509Utils.java262
-rw-r--r--src/main/java/com/gitblit/wicket/AuthorizationStrategy.java2
-rw-r--r--src/main/java/com/gitblit/wicket/CacheControl.java8
-rw-r--r--src/main/java/com/gitblit/wicket/ExternalImage.java1
-rw-r--r--src/main/java/com/gitblit/wicket/GitBlitWebSession.java23
-rw-r--r--src/main/java/com/gitblit/wicket/GitblitParamUrlCodingStrategy.java16
-rw-r--r--src/main/java/com/gitblit/wicket/GitblitRedirectException.java4
-rw-r--r--src/main/java/com/gitblit/wicket/GitblitWicketFilter.java21
-rw-r--r--src/main/java/com/gitblit/wicket/PageRegistration.java30
-rw-r--r--src/main/java/com/gitblit/wicket/SessionlessForm.java28
-rw-r--r--src/main/java/com/gitblit/wicket/StringChoiceRenderer.java4
-rw-r--r--src/main/java/com/gitblit/wicket/WicketUtils.java13
-rw-r--r--src/main/java/com/gitblit/wicket/charting/GoogleChart.java6
-rw-r--r--src/main/java/com/gitblit/wicket/charting/GoogleCharts.java5
-rw-r--r--src/main/java/com/gitblit/wicket/charting/GoogleLineChart.java4
-rw-r--r--src/main/java/com/gitblit/wicket/charting/GooglePieChart.java10
-rw-r--r--src/main/java/com/gitblit/wicket/charting/SecureChart.java4
-rw-r--r--src/main/java/com/gitblit/wicket/charting/SecureChartDataEncoding.java11
-rw-r--r--src/main/java/com/gitblit/wicket/freemarker/Freemarker.java6
-rw-r--r--src/main/java/com/gitblit/wicket/freemarker/FreemarkerPanel.java26
-rw-r--r--src/main/java/com/gitblit/wicket/ng/NgController.java15
-rw-r--r--src/main/java/com/gitblit/wicket/pages/ActivityPage.java10
-rw-r--r--src/main/java/com/gitblit/wicket/pages/BasePage.java44
-rw-r--r--src/main/java/com/gitblit/wicket/pages/BlamePage.java13
-rw-r--r--src/main/java/com/gitblit/wicket/pages/BlobDiffPage.java2
-rw-r--r--src/main/java/com/gitblit/wicket/pages/BlobPage.java22
-rw-r--r--src/main/java/com/gitblit/wicket/pages/ChangePasswordPage.java6
-rw-r--r--src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java8
-rw-r--r--src/main/java/com/gitblit/wicket/pages/CommitPage.java21
-rw-r--r--src/main/java/com/gitblit/wicket/pages/ComparePage.java31
-rw-r--r--src/main/java/com/gitblit/wicket/pages/DashboardPage.java16
-rw-r--r--src/main/java/com/gitblit/wicket/pages/DocsPage.java3
-rw-r--r--src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.java100
-rw-r--r--src/main/java/com/gitblit/wicket/pages/EditTeamPage.java6
-rw-r--r--src/main/java/com/gitblit/wicket/pages/EditUserPage.java24
-rw-r--r--src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage.java10
-rw-r--r--src/main/java/com/gitblit/wicket/pages/FederationRegistrationPage.java5
-rw-r--r--src/main/java/com/gitblit/wicket/pages/ForkPage.java2
-rw-r--r--src/main/java/com/gitblit/wicket/pages/ForksPage.java25
-rw-r--r--src/main/java/com/gitblit/wicket/pages/GitSearchPage.java4
-rw-r--r--src/main/java/com/gitblit/wicket/pages/GravatarProfilePage.java6
-rw-r--r--src/main/java/com/gitblit/wicket/pages/HistoryPage.java4
-rw-r--r--src/main/java/com/gitblit/wicket/pages/LogPage.java2
-rw-r--r--src/main/java/com/gitblit/wicket/pages/LogoutPage.java6
-rw-r--r--src/main/java/com/gitblit/wicket/pages/LuceneSearchPage.java40
-rw-r--r--src/main/java/com/gitblit/wicket/pages/MarkdownPage.java6
-rw-r--r--src/main/java/com/gitblit/wicket/pages/MetricsPage.java4
-rw-r--r--src/main/java/com/gitblit/wicket/pages/MyDashboardPage.java34
-rw-r--r--src/main/java/com/gitblit/wicket/pages/OverviewPage.java13
-rw-r--r--src/main/java/com/gitblit/wicket/pages/ProjectPage.java31
-rw-r--r--src/main/java/com/gitblit/wicket/pages/ProjectsPage.java5
-rw-r--r--src/main/java/com/gitblit/wicket/pages/RawPage.java12
-rw-r--r--src/main/java/com/gitblit/wicket/pages/ReflogPage.java2
-rw-r--r--src/main/java/com/gitblit/wicket/pages/RepositoriesPage.java4
-rw-r--r--src/main/java/com/gitblit/wicket/pages/ReviewProposalPage.java4
-rw-r--r--src/main/java/com/gitblit/wicket/pages/RootPage.java39
-rw-r--r--src/main/java/com/gitblit/wicket/pages/RootSubPage.java12
-rw-r--r--src/main/java/com/gitblit/wicket/pages/SendProposalPage.java2
-rw-r--r--src/main/java/com/gitblit/wicket/pages/SummaryPage.java11
-rw-r--r--src/main/java/com/gitblit/wicket/pages/TagPage.java4
-rw-r--r--src/main/java/com/gitblit/wicket/pages/TagsPage.java2
-rw-r--r--src/main/java/com/gitblit/wicket/pages/TreePage.java13
-rw-r--r--src/main/java/com/gitblit/wicket/pages/UserPage.java21
-rw-r--r--src/main/java/com/gitblit/wicket/pages/UsersPage.java4
-rw-r--r--src/main/java/com/gitblit/wicket/panels/ActivityPanel.java10
-rw-r--r--src/main/java/com/gitblit/wicket/panels/BasePanel.java12
-rw-r--r--src/main/java/com/gitblit/wicket/panels/BranchesPanel.java15
-rw-r--r--src/main/java/com/gitblit/wicket/panels/BulletListPanel.java1
-rw-r--r--src/main/java/com/gitblit/wicket/panels/CommitLegendPanel.java1
-rw-r--r--src/main/java/com/gitblit/wicket/panels/CompressedDownloadsPanel.java11
-rw-r--r--src/main/java/com/gitblit/wicket/panels/DigestsPanel.java36
-rw-r--r--src/main/java/com/gitblit/wicket/panels/DropDownMenu.java1
-rw-r--r--src/main/java/com/gitblit/wicket/panels/FederationProposalsPanel.java1
-rw-r--r--src/main/java/com/gitblit/wicket/panels/FederationRegistrationsPanel.java1
-rw-r--r--src/main/java/com/gitblit/wicket/panels/FederationTokensPanel.java1
-rw-r--r--src/main/java/com/gitblit/wicket/panels/FilterableProjectList.java28
-rw-r--r--src/main/java/com/gitblit/wicket/panels/FilterableRepositoryList.java38
-rw-r--r--src/main/java/com/gitblit/wicket/panels/GravatarImage.java8
-rw-r--r--src/main/java/com/gitblit/wicket/panels/HistoryPanel.java25
-rw-r--r--src/main/java/com/gitblit/wicket/panels/LinkPanel.java2
-rw-r--r--src/main/java/com/gitblit/wicket/panels/LogPanel.java11
-rw-r--r--src/main/java/com/gitblit/wicket/panels/NavigationPanel.java1
-rw-r--r--src/main/java/com/gitblit/wicket/panels/ObjectContainer.java4
-rw-r--r--src/main/java/com/gitblit/wicket/panels/PagerPanel.java7
-rw-r--r--src/main/java/com/gitblit/wicket/panels/PathBreadcrumbsPanel.java1
-rw-r--r--src/main/java/com/gitblit/wicket/panels/ReflogPanel.java40
-rw-r--r--src/main/java/com/gitblit/wicket/panels/RefsPanel.java13
-rw-r--r--src/main/java/com/gitblit/wicket/panels/RegistrantPermissionsPanel.java45
-rw-r--r--src/main/java/com/gitblit/wicket/panels/RepositoriesPanel.java11
-rw-r--r--src/main/java/com/gitblit/wicket/panels/RepositoryUrlPanel.java71
-rw-r--r--src/main/java/com/gitblit/wicket/panels/SearchPanel.java1
-rw-r--r--src/main/java/com/gitblit/wicket/panels/ShockWaveComponent.java10
-rw-r--r--src/main/java/com/gitblit/wicket/panels/TagsPanel.java3
-rw-r--r--src/main/java/com/gitblit/wicket/panels/TeamsPanel.java1
-rw-r--r--src/main/java/com/gitblit/wicket/panels/UsersPanel.java3
-rw-r--r--src/test/java/com/gitblit/tests/HtpasswdUserServiceTest.java1
-rw-r--r--src/test/java/com/gitblit/tests/JnaUtilsTest.java10
270 files changed, 3350 insertions, 3080 deletions
diff --git a/src/main/java/com/gitblit/AccessRestrictionFilter.java b/src/main/java/com/gitblit/AccessRestrictionFilter.java
index 495d3438..cadf9155 100644
--- a/src/main/java/com/gitblit/AccessRestrictionFilter.java
+++ b/src/main/java/com/gitblit/AccessRestrictionFilter.java
@@ -32,22 +32,22 @@ import com.gitblit.utils.StringUtils;
/**
* The AccessRestrictionFilter is an AuthenticationFilter that confirms that the
* requested repository can be accessed by the anonymous or named user.
- *
+ *
* The filter extracts the name of the repository from the url and determines if
* the requested action for the repository requires a Basic authentication
* prompt. If authentication is required and no credentials are stored in the
* "Authorization" header, then a basic authentication challenge is issued.
- *
+ *
* http://en.wikipedia.org/wiki/Basic_access_authentication
- *
+ *
* @author James Moger
- *
+ *
*/
public abstract class AccessRestrictionFilter extends AuthenticationFilter {
/**
* Extract the repository name from the url.
- *
+ *
* @param url
* @return repository name
*/
@@ -55,7 +55,7 @@ public abstract class AccessRestrictionFilter extends AuthenticationFilter {
/**
* Analyze the url and returns the action of the request.
- *
+ *
* @param url
* @return action of the request
*/
@@ -63,14 +63,14 @@ public abstract class AccessRestrictionFilter extends AuthenticationFilter {
/**
* Determine if a non-existing repository can be created using this filter.
- *
+ *
* @return true if the filter allows repository creation
*/
protected abstract boolean isCreationAllowed();
-
+
/**
* Determine if the action may be executed on the repository.
- *
+ *
* @param repository
* @param action
* @return true if the action may be performed
@@ -79,7 +79,7 @@ public abstract class AccessRestrictionFilter extends AuthenticationFilter {
/**
* Determine if the repository requires authentication.
- *
+ *
* @param repository
* @param action
* @return true if authentication required
@@ -89,7 +89,7 @@ public abstract class AccessRestrictionFilter extends AuthenticationFilter {
/**
* Determine if the user can access the repository and perform the specified
* action.
- *
+ *
* @param repository
* @param user
* @param action
@@ -99,7 +99,7 @@ public abstract class AccessRestrictionFilter extends AuthenticationFilter {
/**
* Allows a filter to create a repository, if one does not exist.
- *
+ *
* @param user
* @param repository
* @param action
@@ -108,11 +108,11 @@ public abstract class AccessRestrictionFilter extends AuthenticationFilter {
protected RepositoryModel createRepository(UserModel user, String repository, String action) {
return null;
}
-
+
/**
* doFilter does the actual work of preprocessing the request to ensure that
* the user may proceed.
- *
+ *
* @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest,
* javax.servlet.ServletResponse, javax.servlet.FilterChain)
*/
@@ -125,7 +125,7 @@ public abstract class AccessRestrictionFilter extends AuthenticationFilter {
String fullUrl = getFullUrl(httpRequest);
String repository = extractRepositoryName(fullUrl);
-
+
if (GitBlit.self().isCollectingGarbage(repository)) {
logger.info(MessageFormat.format("ARF: Rejecting request for {0}, busy collecting garbage!", repository));
httpResponse.sendError(HttpServletResponse.SC_FORBIDDEN);
@@ -155,7 +155,7 @@ public abstract class AccessRestrictionFilter extends AuthenticationFilter {
model = createRepository(user, repository, urlRequestType);
}
}
-
+
if (model == null) {
// repository not found. send 404.
logger.info(MessageFormat.format("ARF: {0} ({1})", fullUrl,
@@ -164,7 +164,7 @@ public abstract class AccessRestrictionFilter extends AuthenticationFilter {
return;
}
}
-
+
// Confirm that the action may be executed on the repository
if (!isActionAllowed(model, urlRequestType)) {
logger.info(MessageFormat.format("ARF: action {0} on {1} forbidden ({2})",
diff --git a/src/main/java/com/gitblit/AddIndexedBranch.java b/src/main/java/com/gitblit/AddIndexedBranch.java
index 7a16bbd9..4b668c4e 100644
--- a/src/main/java/com/gitblit/AddIndexedBranch.java
+++ b/src/main/java/com/gitblit/AddIndexedBranch.java
@@ -40,9 +40,9 @@ import com.gitblit.utils.StringUtils;
/**
* Utility class to add an indexBranch setting to matching repositories.
- *
+ *
* @author James Moger
- *
+ *
*/
public class AddIndexedBranch {
@@ -56,17 +56,17 @@ public class AddIndexedBranch {
jc.usage();
return;
}
-
+
// create a lowercase set of excluded repositories
Set<String> exclusions = new TreeSet<String>();
for (String exclude : params.exclusions) {
exclusions.add(exclude.toLowerCase());
}
-
+
// determine available repositories
File folder = new File(params.folder);
List<String> repoList = JGitUtils.getRepositoryList(folder, false, true, -1, null);
-
+
int modCount = 0;
int skipCount = 0;
for (String repo : repoList) {
@@ -77,23 +77,23 @@ public class AddIndexedBranch {
break;
}
}
-
+
if (skip) {
System.out.println("skipping " + repo);
skipCount++;
continue;
}
-
+
try {
// load repository config
File gitDir = FileKey.resolve(new File(folder, repo), FS.DETECTED);
Repository repository = new FileRepositoryBuilder().setGitDir(gitDir).build();
StoredConfig config = repository.getConfig();
config.load();
-
+
Set<String> indexedBranches = new LinkedHashSet<String>();
-
+
// add all local branches to index
if(params.addAllLocalBranches) {
List<RefModel> list = JGitUtils.getLocalBranches(repository, true, -1);
@@ -107,7 +107,7 @@ public class AddIndexedBranch {
System.out.println(MessageFormat.format("adding [gitblit] indexBranch={0} for {1}", params.branch, repo));
indexedBranches.add(params.branch);
}
-
+
String [] branches = config.getStringList("gitblit", null, "indexBranch");
if (!ArrayUtils.isEmpty(branches)) {
for (String branch : branches) {
@@ -122,11 +122,11 @@ public class AddIndexedBranch {
e.printStackTrace();
}
}
-
+
System.out.println(MessageFormat.format("updated {0} repository configurations, skipped {1}", modCount, skipCount));
}
-
+
/**
* JCommander Parameters class for AddIndexedBranch.
@@ -142,7 +142,7 @@ public class AddIndexedBranch {
@Parameter(names = { "--skip" }, description = "Skip the named repository (simple fizzy matching is supported)", required = false)
public List<String> exclusions = new ArrayList<String>();
-
+
@Parameter(names = { "--all-local-branches" }, description = "Add all local branches to index. If specified, the --branch parameter is not considered.", required = false)
public boolean addAllLocalBranches = false;
}
diff --git a/src/main/java/com/gitblit/AuthenticationFilter.java b/src/main/java/com/gitblit/AuthenticationFilter.java
index 388452e4..640bf176 100644
--- a/src/main/java/com/gitblit/AuthenticationFilter.java
+++ b/src/main/java/com/gitblit/AuthenticationFilter.java
@@ -42,11 +42,11 @@ import com.gitblit.utils.StringUtils;
/**
* The AuthenticationFilter is a servlet filter that preprocesses requests that
* match its url pattern definition in the web.xml file.
- *
+ *
* http://en.wikipedia.org/wiki/Basic_access_authentication
- *
+ *
* @author James Moger
- *
+ *
*/
public abstract class AuthenticationFilter implements Filter {
@@ -59,17 +59,17 @@ public abstract class AuthenticationFilter implements Filter {
/**
* doFilter does the actual work of preprocessing the request to ensure that
* the user may proceed.
- *
+ *
* @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest,
* javax.servlet.ServletResponse, javax.servlet.FilterChain)
*/
@Override
public abstract void doFilter(final ServletRequest request, final ServletResponse response,
final FilterChain chain) throws IOException, ServletException;
-
+
/**
* Allow the filter to require a client certificate to continue processing.
- *
+ *
* @return true, if a client certificate is required
*/
protected boolean requiresClientCertificate() {
@@ -78,7 +78,7 @@ public abstract class AuthenticationFilter implements Filter {
/**
* Returns the full relative url of the request.
- *
+ *
* @param httpRequest
* @return url
*/
@@ -95,7 +95,7 @@ public abstract class AuthenticationFilter implements Filter {
/**
* Returns the user making the request, if the user has authenticated.
- *
+ *
* @param httpRequest
* @return user
*/
diff --git a/src/main/java/com/gitblit/BranchGraphServlet.java b/src/main/java/com/gitblit/BranchGraphServlet.java
index 05c3c658..293a2919 100644
--- a/src/main/java/com/gitblit/BranchGraphServlet.java
+++ b/src/main/java/com/gitblit/BranchGraphServlet.java
@@ -55,9 +55,9 @@ import com.gitblit.utils.StringUtils;
/**
* Handles requests for branch graphs
- *
+ *
* @author James Moger
- *
+ *
*/
public class BranchGraphServlet extends HttpServlet {
@@ -82,7 +82,7 @@ public class BranchGraphServlet extends HttpServlet {
/**
* Returns an url to this servlet for the specified parameters.
- *
+ *
* @param baseURL
* @param repository
* @param objectId
@@ -148,7 +148,7 @@ public class BranchGraphServlet extends HttpServlet {
}
// fetch the requested commits plus some extra so that the last
- // commit displayed *likely* has correct lane assignments
+ // commit displayed *likely* has correct lane assignments
CommitList commitList = new CommitList();
commitList.source(rw);
commitList.fillTo(2*Math.max(requestedCommits, maxCommits));
@@ -190,7 +190,7 @@ public class BranchGraphServlet extends HttpServlet {
// create an image buffer and render the lanes
BufferedImage image = new BufferedImage(graphWidth, rowHeight*numCommits, BufferedImage.TYPE_INT_ARGB);
-
+
Graphics2D g = null;
try {
g = image.createGraphics();
diff --git a/src/main/java/com/gitblit/ConfigUserService.java b/src/main/java/com/gitblit/ConfigUserService.java
index 44687b49..6b721a83 100644
--- a/src/main/java/com/gitblit/ConfigUserService.java
+++ b/src/main/java/com/gitblit/ConfigUserService.java
@@ -45,16 +45,16 @@ import com.gitblit.utils.StringUtils;
/**
* ConfigUserService is Gitblit's default user service implementation since
* version 0.8.0.
- *
+ *
* Users and their repository memberships are stored in a git-style config file
* which is cached and dynamically reloaded when modified. This file is
* plain-text, human-readable, and may be edited with a text editor.
- *
+ *
* Additionally, this format allows for expansion of the user model without
* bringing in the complexity of a database.
- *
+ *
* @author James Moger
- *
+ *
*/
public class ConfigUserService implements IUserService {
@@ -63,21 +63,21 @@ public class ConfigUserService implements IUserService {
private static final String USER = "user";
private static final String PASSWORD = "password";
-
+
private static final String DISPLAYNAME = "displayName";
-
+
private static final String EMAILADDRESS = "emailAddress";
-
+
private static final String ORGANIZATIONALUNIT = "organizationalUnit";
-
+
private static final String ORGANIZATION = "organization";
-
+
private static final String LOCALITY = "locality";
-
+
private static final String STATEPROVINCE = "stateProvince";
-
+
private static final String COUNTRYCODE = "countryCode";
-
+
private static final String COOKIE = "cookie";
private static final String REPOSITORY = "repository";
@@ -89,9 +89,9 @@ public class ConfigUserService implements IUserService {
private static final String PRERECEIVE = "preReceiveScript";
private static final String POSTRECEIVE = "postReceiveScript";
-
+
private static final String STARRED = "starred";
-
+
private static final String LOCALE = "locale";
private final File realmFile;
@@ -105,7 +105,7 @@ public class ConfigUserService implements IUserService {
private final Map<String, TeamModel> teams = new ConcurrentHashMap<String, TeamModel>();
private volatile long lastModified;
-
+
private volatile boolean forceReload;
public ConfigUserService(File realmFile) {
@@ -114,7 +114,7 @@ public class ConfigUserService implements IUserService {
/**
* Setup the user service.
- *
+ *
* @param settings
* @since 0.7.0
*/
@@ -124,7 +124,7 @@ public class ConfigUserService implements IUserService {
/**
* Does the user service support changes to credentials?
- *
+ *
* @return true or false
* @since 1.0.0
*/
@@ -135,7 +135,7 @@ public class ConfigUserService implements IUserService {
/**
* Does the user service support changes to user display name?
- *
+ *
* @return true or false
* @since 1.0.0
*/
@@ -146,7 +146,7 @@ public class ConfigUserService implements IUserService {
/**
* Does the user service support changes to user email address?
- *
+ *
* @return true or false
* @since 1.0.0
*/
@@ -157,17 +157,18 @@ public class ConfigUserService implements IUserService {
/**
* Does the user service support changes to team memberships?
- *
+ *
* @return true or false
* @since 1.0.0
- */
+ */
+ @Override
public boolean supportsTeamMembershipChanges() {
return true;
}
-
+
/**
* Does the user service support cookie authentication?
- *
+ *
* @return true or false
*/
@Override
@@ -177,7 +178,7 @@ public class ConfigUserService implements IUserService {
/**
* Returns the cookie value for the specified user.
- *
+ *
* @param model
* @return cookie value
*/
@@ -195,7 +196,7 @@ public class ConfigUserService implements IUserService {
/**
* Authenticate a user based on their cookie.
- *
+ *
* @param cookie
* @return a user object or null
*/
@@ -210,7 +211,7 @@ public class ConfigUserService implements IUserService {
if (cookies.containsKey(hash)) {
model = cookies.get(hash);
}
-
+
if (model != null) {
// clone the model, otherwise all changes to this object are
// live and unpersisted
@@ -221,7 +222,7 @@ public class ConfigUserService implements IUserService {
/**
* Authenticate a user based on a username and password.
- *
+ *
* @param username
* @param password
* @return a user object or null
@@ -255,16 +256,16 @@ public class ConfigUserService implements IUserService {
/**
* Logout a user.
- *
+ *
* @param user
*/
@Override
- public void logout(UserModel user) {
+ public void logout(UserModel user) {
}
-
+
/**
* Retrieve the user object for the specified username.
- *
+ *
* @param username
* @return a user object or null
*/
@@ -282,7 +283,7 @@ public class ConfigUserService implements IUserService {
/**
* Updates/writes a complete user object.
- *
+ *
* @param model
* @return true if update is successful
*/
@@ -293,7 +294,7 @@ public class ConfigUserService implements IUserService {
/**
* Updates/writes all specified user objects.
- *
+ *
* @param models a list of user models
* @return true if update is successful
* @since 1.2.0
@@ -317,7 +318,7 @@ public class ConfigUserService implements IUserService {
} else {
// do not clobber existing team definition
// maybe because this is a federated user
- t.addUser(model.username);
+ t.addUser(model.username);
}
}
@@ -343,7 +344,7 @@ public class ConfigUserService implements IUserService {
/**
* Updates/writes and replaces a complete user object keyed by username.
* This method allows for renaming a user.
- *
+ *
* @param username
* the old username
* @param model
@@ -401,7 +402,7 @@ public class ConfigUserService implements IUserService {
/**
* Deletes the user object from the user service.
- *
+ *
* @param model
* @return true if successful
*/
@@ -412,7 +413,7 @@ public class ConfigUserService implements IUserService {
/**
* Delete the user object with the specified username
- *
+ *
* @param username
* @return true if successful
*/
@@ -448,7 +449,7 @@ public class ConfigUserService implements IUserService {
/**
* Returns the list of all teams available to the login service.
- *
+ *
* @return list of all teams
* @since 0.8.0
*/
@@ -462,7 +463,7 @@ public class ConfigUserService implements IUserService {
/**
* Returns the list of all teams available to the login service.
- *
+ *
* @return list of all teams
* @since 0.8.0
*/
@@ -478,7 +479,7 @@ public class ConfigUserService implements IUserService {
/**
* Returns the list of all users who are allowed to bypass the access
* restriction placed on the specified repository.
- *
+ *
* @param role
* the repository name
* @return list of all usernames that can bypass the access restriction
@@ -504,7 +505,7 @@ public class ConfigUserService implements IUserService {
/**
* Sets the list of all teams who are allowed to bypass the access
* restriction placed on the specified repository.
- *
+ *
* @param role
* the repository name
* @param teamnames
@@ -542,7 +543,7 @@ public class ConfigUserService implements IUserService {
/**
* Retrieve the team object for the specified team name.
- *
+ *
* @param teamname
* @return a team object or null
* @since 0.8.0
@@ -561,7 +562,7 @@ public class ConfigUserService implements IUserService {
/**
* Updates/writes a complete team object.
- *
+ *
* @param model
* @return true if update is successful
* @since 0.8.0
@@ -573,7 +574,7 @@ public class ConfigUserService implements IUserService {
/**
* Updates/writes all specified team objects.
- *
+ *
* @param models a list of team models
* @return true if update is successful
* @since 1.2.0
@@ -596,7 +597,7 @@ public class ConfigUserService implements IUserService {
/**
* Updates/writes and replaces a complete team object keyed by teamname.
* This method allows for renaming a team.
- *
+ *
* @param teamname
* the old teamname
* @param model
@@ -628,7 +629,7 @@ public class ConfigUserService implements IUserService {
/**
* Deletes the team object from the user service.
- *
+ *
* @param model
* @return true if successful
* @since 0.8.0
@@ -640,7 +641,7 @@ public class ConfigUserService implements IUserService {
/**
* Delete the team object with the specified teamname
- *
+ *
* @param teamname
* @return true if successful
* @since 0.8.0
@@ -661,7 +662,7 @@ public class ConfigUserService implements IUserService {
/**
* Returns the list of all users available to the login service.
- *
+ *
* @return list of all usernames
*/
@Override
@@ -671,10 +672,10 @@ public class ConfigUserService implements IUserService {
Collections.sort(list);
return list;
}
-
+
/**
* Returns the list of all users available to the login service.
- *
+ *
* @return list of all usernames
*/
@Override
@@ -684,12 +685,12 @@ public class ConfigUserService implements IUserService {
list = DeepCopier.copy(list);
Collections.sort(list);
return list;
- }
+ }
/**
* Returns the list of all users who are allowed to bypass the access
* restriction placed on the specified repository.
- *
+ *
* @param role
* the repository name
* @return list of all usernames that can bypass the access restriction
@@ -715,7 +716,7 @@ public class ConfigUserService implements IUserService {
/**
* Sets the list of all uses who are allowed to bypass the access
* restriction placed on the specified repository.
- *
+ *
* @param role
* the repository name
* @param usernames
@@ -754,7 +755,7 @@ public class ConfigUserService implements IUserService {
/**
* Renames a repository role.
- *
+ *
* @param oldRole
* @param newRole
* @return true if successful
@@ -790,7 +791,7 @@ public class ConfigUserService implements IUserService {
/**
* Removes a repository role from all users.
- *
+ *
* @param role
* @return true if successful
*/
@@ -820,7 +821,7 @@ public class ConfigUserService implements IUserService {
/**
* Writes the properties file.
- *
+ *
* @throws IOException
*/
private synchronized void write() throws IOException {
@@ -896,7 +897,7 @@ public class ConfigUserService implements IUserService {
}
config.setStringList(USER, model.username, REPOSITORY, permissions);
}
-
+
// user preferences
if (model.getPreferences() != null) {
List<String> starred = model.getPreferences().getStarredRepositories();
@@ -925,7 +926,7 @@ public class ConfigUserService implements IUserService {
roles.add(Constants.NO_ROLE);
}
config.setStringList(TEAM, model.name, ROLE, roles);
-
+
if (!model.canAdmin) {
// write team permission for non-admin teams
if (model.permissions == null) {
@@ -1015,7 +1016,7 @@ public class ConfigUserService implements IUserService {
Set<String> usernames = config.getSubsections(USER);
for (String username : usernames) {
UserModel user = new UserModel(username.toLowerCase());
- user.password = config.getString(USER, username, PASSWORD);
+ user.password = config.getString(USER, username, PASSWORD);
user.displayName = config.getString(USER, username, DISPLAYNAME);
user.emailAddress = config.getString(USER, username, EMAILADDRESS);
user.organizationalUnit = config.getString(USER, username, ORGANIZATIONALUNIT);
@@ -1024,7 +1025,7 @@ public class ConfigUserService implements IUserService {
user.stateProvince = config.getString(USER, username, STATEPROVINCE);
user.countryCode = config.getString(USER, username, COUNTRYCODE);
user.cookie = config.getString(USER, username, COOKIE);
- user.getPreferences().locale = config.getString(USER, username, LOCALE);
+ user.getPreferences().locale = config.getString(USER, username, LOCALE);
if (StringUtils.isEmpty(user.cookie) && !StringUtils.isEmpty(user.password)) {
user.cookie = StringUtils.getSHA1(user.username + user.password);
}
@@ -1071,7 +1072,7 @@ public class ConfigUserService implements IUserService {
team.canAdmin = roles.contains(Constants.ADMIN_ROLE);
team.canFork = roles.contains(Constants.FORK_ROLE);
team.canCreate = roles.contains(Constants.CREATE_ROLE);
-
+
if (!team.canAdmin) {
// non-admin team, read permissions
team.addRepositoryPermissions(Arrays.asList(config.getStringList(TEAM, teamname,
diff --git a/src/main/java/com/gitblit/Constants.java b/src/main/java/com/gitblit/Constants.java
index b36321e3..1451ccf1 100644
--- a/src/main/java/com/gitblit/Constants.java
+++ b/src/main/java/com/gitblit/Constants.java
@@ -26,9 +26,9 @@ import java.util.jar.Manifest;
/**
* Constant values used by Gitblit.
- *
+ *
* @author James Moger
- *
+ *
*/
public class Constants {
@@ -37,19 +37,19 @@ public class Constants {
public static final String FULL_NAME = "Gitblit - a pure Java Git solution";
public static final String ADMIN_ROLE = "#admin";
-
+
public static final String FORK_ROLE = "#fork";
-
+
public static final String CREATE_ROLE = "#create";
public static final String NOT_FEDERATED_ROLE = "#notfederated";
-
+
public static final String NO_ROLE = "#none";
-
+
public static final String EXTERNAL_ACCOUNT = "#externalAccount";
public static final String PROPERTIES_FILE = "gitblit.properties";
-
+
public static final String DEFAULT_USER_REPOSITORY_PREFIX = "~";
public static final String GIT_PATH = "/git/";
@@ -61,11 +61,11 @@ public class Constants {
public static final String FEDERATION_PATH = "/federation/";
public static final String RPC_PATH = "/rpc/";
-
+
public static final String PAGES = "/pages/";
-
+
public static final String SPARKLESHARE_INVITE_PATH = "/sparkleshare/";
-
+
public static final String BRANCH_GRAPH_PATH = "/graph/";
public static final String BORDER = "***********************************************************";
@@ -73,41 +73,41 @@ public class Constants {
public static final String FEDERATION_USER = "$gitblit";
public static final String PROPOSAL_EXT = ".json";
-
+
public static final String ENCODING = "UTF-8";
-
+
public static final int LEN_SHORTLOG = 78;
-
+
public static final int LEN_SHORTLOG_REFS = 60;
-
+
public static final String DEFAULT_BRANCH = "default";
-
+
public static final String CONFIG_GITBLIT = "gitblit";
-
+
public static final String CONFIG_CUSTOM_FIELDS = "customFields";
-
+
public static final String ISO8601 = "yyyy-MM-dd'T'HH:mm:ssZ";
-
+
public static final String baseFolder = "baseFolder";
-
+
public static final String baseFolder$ = "${" + baseFolder + "}";
-
+
public static final String contextFolder$ = "${contextFolder}";
-
+
public static final String HEAD = "HEAD";
public static final String R_GITBLIT = "refs/gitblit/";
-
+
public static final String R_HEADS = "refs/heads/";
-
+
public static final String R_NOTES = "refs/notes/";
-
+
public static final String R_CHANGES = "refs/changes/";
-
+
public static final String R_PULL= "refs/pull/";
public static final String R_TAGS = "refs/tags/";
-
+
public static final String R_REMOTES = "refs/remotes/";
public static String getVersion() {
@@ -121,11 +121,11 @@ public class Constants {
public static String getGitBlitVersion() {
return NAME + " v" + getVersion();
}
-
+
public static String getBuildDate() {
return getManifestValue("build-date", "PENDING");
}
-
+
private static String getManifestValue(String attrib, String defaultValue) {
Class<?> clazz = Constants.class;
String className = clazz.getSimpleName() + ".class";
@@ -144,13 +144,13 @@ public class Constants {
}
return defaultValue;
}
-
+
/**
* Enumeration representing the four access restriction levels.
*/
public static enum AccessRestrictionType {
NONE, PUSH, CLONE, VIEW;
-
+
private static final AccessRestrictionType [] AUTH_TYPES = { PUSH, CLONE, VIEW };
public static AccessRestrictionType fromName(String name) {
@@ -161,7 +161,7 @@ public class Constants {
}
return NONE;
}
-
+
public static List<AccessRestrictionType> choices(boolean allowAnonymousPush) {
if (allowAnonymousPush) {
return Arrays.asList(values());
@@ -177,10 +177,11 @@ public class Constants {
return this.ordinal() >= type.ordinal();
}
+ @Override
public String toString() {
return name();
}
-
+
public boolean isValidPermission(AccessPermission permission) {
switch (this) {
case VIEW:
@@ -193,7 +194,7 @@ public class Constants {
return permission.atLeast(AccessPermission.CLONE);
case PUSH:
// PUSH restriction
- // only PUSH or greater access permissions are valid
+ // only PUSH or greater access permissions are valid
return permission.atLeast(AccessPermission.PUSH);
case NONE:
// NO access restriction
@@ -203,14 +204,14 @@ public class Constants {
return false;
}
}
-
+
/**
* Enumeration representing the types of authorization control for an
* access restricted resource.
*/
public static enum AuthorizationControl {
AUTHENTICATED, NAMED;
-
+
public static AuthorizationControl fromName(String name) {
for (AuthorizationControl type : values()) {
if (type.name().equalsIgnoreCase(name)) {
@@ -219,7 +220,8 @@ public class Constants {
}
return NAMED;
}
-
+
+ @Override
public String toString() {
return name();
}
@@ -241,6 +243,7 @@ public class Constants {
return REPOSITORIES;
}
+ @Override
public String toString() {
return name();
}
@@ -261,6 +264,7 @@ public class Constants {
return PULL_REPOSITORIES;
}
+ @Override
public String toString() {
return name();
}
@@ -337,11 +341,11 @@ public class Constants {
// Order is important here. anything above LIST_SETTINGS requires
// administrator privileges and web.allowRpcManagement.
CLEAR_REPOSITORY_CACHE, GET_PROTOCOL, LIST_REPOSITORIES, LIST_BRANCHES, GET_USER, LIST_SETTINGS,
- CREATE_REPOSITORY, EDIT_REPOSITORY, DELETE_REPOSITORY,
- LIST_USERS, CREATE_USER, EDIT_USER, DELETE_USER,
+ CREATE_REPOSITORY, EDIT_REPOSITORY, DELETE_REPOSITORY,
+ LIST_USERS, CREATE_USER, EDIT_USER, DELETE_USER,
LIST_TEAMS, CREATE_TEAM, EDIT_TEAM, DELETE_TEAM,
- LIST_REPOSITORY_MEMBERS, SET_REPOSITORY_MEMBERS, LIST_REPOSITORY_TEAMS, SET_REPOSITORY_TEAMS,
- LIST_REPOSITORY_MEMBER_PERMISSIONS, SET_REPOSITORY_MEMBER_PERMISSIONS, LIST_REPOSITORY_TEAM_PERMISSIONS, SET_REPOSITORY_TEAM_PERMISSIONS,
+ LIST_REPOSITORY_MEMBERS, SET_REPOSITORY_MEMBERS, LIST_REPOSITORY_TEAMS, SET_REPOSITORY_TEAMS,
+ LIST_REPOSITORY_MEMBER_PERMISSIONS, SET_REPOSITORY_MEMBER_PERMISSIONS, LIST_REPOSITORY_TEAM_PERMISSIONS, SET_REPOSITORY_TEAM_PERMISSIONS,
LIST_FEDERATION_REGISTRATIONS, LIST_FEDERATION_RESULTS, LIST_FEDERATION_PROPOSALS, LIST_FEDERATION_SETS,
EDIT_SETTINGS, LIST_STATUS;
@@ -352,7 +356,7 @@ public class Constants {
}
}
return null;
- }
+ }
public boolean exceeds(RpcRequest type) {
return this.ordinal() > type.ordinal();
@@ -369,7 +373,7 @@ public class Constants {
*/
public static enum SearchType {
AUTHOR, COMMITTER, COMMIT;
-
+
public static SearchType forName(String name) {
for (SearchType type : values()) {
if (type.name().equalsIgnoreCase(name)) {
@@ -378,13 +382,13 @@ public class Constants {
}
return COMMIT;
}
-
+
@Override
public String toString() {
return name().toLowerCase();
}
}
-
+
/**
* The types of objects that can be indexed and queried.
*/
@@ -400,19 +404,19 @@ public class Constants {
return null;
}
}
-
+
/**
- * The access permissions available for a repository.
+ * The access permissions available for a repository.
*/
public static enum AccessPermission {
NONE("N"), EXCLUDE("X"), VIEW("V"), CLONE("R"), PUSH("RW"), CREATE("RWC"), DELETE("RWD"), REWIND("RW+"), OWNER("RW+");
-
+
public static final AccessPermission [] NEWPERMISSIONS = { EXCLUDE, VIEW, CLONE, PUSH, CREATE, DELETE, REWIND };
-
+
public static AccessPermission LEGACY = REWIND;
-
+
public final String code;
-
+
private AccessPermission(String code) {
this.code = code;
}
@@ -428,16 +432,16 @@ public class Constants {
public boolean exceeds(AccessPermission perm) {
return ordinal() > perm.ordinal();
}
-
+
public String asRole(String repository) {
return code + ":" + repository;
}
-
+
@Override
public String toString() {
return code;
}
-
+
public static AccessPermission permissionFromRole(String role) {
String [] fields = role.split(":", 2);
if (fields.length == 1) {
@@ -448,7 +452,7 @@ public class Constants {
return AccessPermission.fromCode(fields[0]);
}
}
-
+
public static String repositoryFromRole(String role) {
String [] fields = role.split(":", 2);
if (fields.length == 1) {
@@ -459,7 +463,7 @@ public class Constants {
return fields[1];
}
}
-
+
public static AccessPermission fromCode(String code) {
for (AccessPermission perm : values()) {
if (perm.code.equalsIgnoreCase(code)) {
@@ -469,18 +473,18 @@ public class Constants {
return AccessPermission.NONE;
}
}
-
+
public static enum RegistrantType {
REPOSITORY, USER, TEAM;
}
-
+
public static enum PermissionType {
MISSING, ANONYMOUS, EXPLICIT, TEAM, REGEX, OWNER, ADMINISTRATOR;
}
-
+
public static enum GCStatus {
READY, COLLECTING;
-
+
public boolean exceeds(GCStatus s) {
return ordinal() > s.ordinal();
}
@@ -488,23 +492,23 @@ public class Constants {
public static enum AuthenticationType {
CREDENTIALS, COOKIE, CERTIFICATE, CONTAINER;
-
+
public boolean isStandard() {
return ordinal() <= COOKIE.ordinal();
}
}
-
+
public static enum AccountType {
LOCAL, EXTERNAL, LDAP, REDMINE, SALESFORCE, WINDOWS, PAM, HTPASSWD;
-
+
public boolean isLocal() {
return this == LOCAL;
}
}
-
+
public static enum CommitMessageRenderer {
PLAIN, MARKDOWN;
-
+
public static CommitMessageRenderer fromName(String name) {
for (CommitMessageRenderer renderer : values()) {
if (renderer.name().equalsIgnoreCase(name)) {
diff --git a/src/main/java/com/gitblit/DownloadZipFilter.java b/src/main/java/com/gitblit/DownloadZipFilter.java
index 90a76493..fb57af53 100644
--- a/src/main/java/com/gitblit/DownloadZipFilter.java
+++ b/src/main/java/com/gitblit/DownloadZipFilter.java
@@ -23,15 +23,15 @@ import com.gitblit.models.UserModel;
* The DownloadZipFilter is an AccessRestrictionFilter which ensures that zip
* requests for view-restricted repositories have proper authentication
* credentials and are authorized.
- *
+ *
* @author James Moger
- *
+ *
*/
public class DownloadZipFilter extends AccessRestrictionFilter {
/**
* Extract the repository name from the url.
- *
+ *
* @param url
* @return repository name
*/
@@ -47,7 +47,7 @@ public class DownloadZipFilter extends AccessRestrictionFilter {
/**
* Analyze the url and returns the action of the request.
- *
+ *
* @param url
* @return action of the request
*/
@@ -58,7 +58,7 @@ public class DownloadZipFilter extends AccessRestrictionFilter {
/**
* Determine if a non-existing repository can be created using this filter.
- *
+ *
* @return true if the filter allows repository creation
*/
@Override
@@ -68,7 +68,7 @@ public class DownloadZipFilter extends AccessRestrictionFilter {
/**
* Determine if the action may be executed on the repository.
- *
+ *
* @param repository
* @param action
* @return true if the action may be performed
@@ -80,7 +80,7 @@ public class DownloadZipFilter extends AccessRestrictionFilter {
/**
* Determine if the repository requires authentication.
- *
+ *
* @param repository
* @param action
* @return true if authentication required
@@ -93,7 +93,7 @@ public class DownloadZipFilter extends AccessRestrictionFilter {
/**
* Determine if the user can access the repository and perform the specified
* action.
- *
+ *
* @param repository
* @param user
* @param action
diff --git a/src/main/java/com/gitblit/DownloadZipServlet.java b/src/main/java/com/gitblit/DownloadZipServlet.java
index 7cdc54b8..c8da267d 100644
--- a/src/main/java/com/gitblit/DownloadZipServlet.java
+++ b/src/main/java/com/gitblit/DownloadZipServlet.java
@@ -37,25 +37,25 @@ import com.gitblit.utils.StringUtils;
/**
* Streams out a zip file from the specified repository for any tree path at any
* revision.
- *
+ *
* @author James Moger
- *
+ *
*/
public class DownloadZipServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private transient Logger logger = LoggerFactory.getLogger(DownloadZipServlet.class);
-
+
public static enum Format {
zip(".zip"), tar(".tar"), gz(".tar.gz"), xz(".tar.xz"), bzip2(".tar.bzip2");
-
+
public final String extension;
-
+
Format(String ext) {
this.extension = ext;
}
-
+
public static Format fromName(String name) {
for (Format format : values()) {
if (format.name().equalsIgnoreCase(name)) {
@@ -72,7 +72,7 @@ public class DownloadZipServlet extends HttpServlet {
/**
* Returns an url to this servlet for the specified parameters.
- *
+ *
* @param baseURL
* @param repository
* @param objectId
@@ -92,7 +92,7 @@ public class DownloadZipServlet extends HttpServlet {
/**
* Creates a zip stream from the repository of the requested data.
- *
+ *
* @param request
* @param response
* @throws javax.servlet.ServletException
@@ -106,7 +106,7 @@ public class DownloadZipServlet extends HttpServlet {
response.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
}
-
+
Format format = Format.zip;
String repository = request.getParameter("r");
String basePath = request.getParameter("p");
@@ -115,7 +115,7 @@ public class DownloadZipServlet extends HttpServlet {
if (!StringUtils.isEmpty(f)) {
format = Format.fromName(f);
}
-
+
try {
String name = repository;
if (name.indexOf('/') > -1) {
@@ -129,7 +129,7 @@ public class DownloadZipServlet extends HttpServlet {
if (!StringUtils.isEmpty(objectId)) {
name += "-" + objectId;
}
-
+
Repository r = GitBlit.self().getRepository(repository);
if (r == null) {
if (GitBlit.self().isCollectingGarbage(repository)) {
@@ -174,14 +174,14 @@ public class DownloadZipServlet extends HttpServlet {
CompressionUtils.bzip2(r, basePath, objectId, response.getOutputStream());
break;
}
-
+
response.flushBuffer();
} catch (IOException t) {
String message = t.getMessage() == null ? "" : t.getMessage().toLowerCase();
if (message.contains("reset") || message.contains("broken pipe")) {
logger.error("Client aborted zip download: " + message);
} else {
- logger.error("Failed to write attachment to client", t);
+ logger.error("Failed to write attachment to client", t);
}
} catch (Throwable t) {
logger.error("Failed to write attachment to client", t);
diff --git a/src/main/java/com/gitblit/EnforceAuthenticationFilter.java b/src/main/java/com/gitblit/EnforceAuthenticationFilter.java
index 2a17996e..ae91c322 100644
--- a/src/main/java/com/gitblit/EnforceAuthenticationFilter.java
+++ b/src/main/java/com/gitblit/EnforceAuthenticationFilter.java
@@ -41,10 +41,10 @@ import com.gitblit.models.UserModel;
*
*/
public class EnforceAuthenticationFilter implements Filter {
-
+
protected transient Logger logger = LoggerFactory.getLogger(getClass());
- /*
+ /*
* @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
*/
@Override
@@ -52,27 +52,27 @@ public class EnforceAuthenticationFilter implements Filter {
// nothing to be done
} //init
-
- /*
+
+ /*
* This does the actual filtering: is the user authenticated? If not, enforce HTTP authentication (401)
- *
+ *
* @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
*/
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
-
+
/*
* Determine whether to enforce the BASIC authentication:
*/
@SuppressWarnings("static-access")
Boolean mustForceAuth = GitBlit.self().getBoolean(Keys.web.authenticateViewPages, false)
&& GitBlit.self().getBoolean(Keys.web.enforceHttpBasicAuthentication, false);
-
+
HttpServletRequest HttpRequest = (HttpServletRequest)request;
- HttpServletResponse HttpResponse = (HttpServletResponse)response;
+ HttpServletResponse HttpResponse = (HttpServletResponse)response;
UserModel user = GitBlit.self().authenticate(HttpRequest);
-
+
if (mustForceAuth && (user == null)) {
// not authenticated, enforce now:
logger.debug(MessageFormat.format("EnforceAuthFilter: user not authenticated for URL {0}!", request.toString()));
@@ -85,12 +85,12 @@ public class EnforceAuthenticationFilter implements Filter {
} else {
// user is authenticated, or don't care, continue handling
chain.doFilter( request, response );
-
+
} // authenticated
} // doFilter
-
- /*
+
+ /*
* @see javax.servlet.Filter#destroy()
*/
@Override
diff --git a/src/main/java/com/gitblit/FederationClient.java b/src/main/java/com/gitblit/FederationClient.java
index d34aadbd..6b2161c6 100644
--- a/src/main/java/com/gitblit/FederationClient.java
+++ b/src/main/java/com/gitblit/FederationClient.java
@@ -29,9 +29,9 @@ import com.gitblit.utils.StringUtils;
/**
* Command-line client to pull federated Gitblit repositories.
- *
+ *
* @author James Moger
- *
+ *
*/
public class FederationClient {
@@ -75,7 +75,7 @@ public class FederationClient {
System.out.println("No Federation Registrations! Nothing to do.");
System.exit(0);
}
-
+
// command-line specified repositories folder
if (!StringUtils.isEmpty(params.repositoriesFolder)) {
settings.overrideSetting(Keys.git.repositoriesFolder, new File(
diff --git a/src/main/java/com/gitblit/FederationPullExecutor.java b/src/main/java/com/gitblit/FederationPullExecutor.java
index 25cd32a5..831c7a5e 100644
--- a/src/main/java/com/gitblit/FederationPullExecutor.java
+++ b/src/main/java/com/gitblit/FederationPullExecutor.java
@@ -74,7 +74,7 @@ public class FederationPullExecutor implements Runnable {
/**
* Constructor for specifying a single federation registration. This
* constructor is used to schedule the next pull execution.
- *
+ *
* @param registration
*/
private FederationPullExecutor(FederationModel registration) {
@@ -85,7 +85,7 @@ public class FederationPullExecutor implements Runnable {
* Constructor to specify a group of federation registrations. This is
* normally used at startup to pull and then schedule the next update based
* on each registrations frequency setting.
- *
+ *
* @param registrations
* @param isDaemon
* if true, registrations are rescheduled in perpetuity. if
@@ -137,7 +137,7 @@ public class FederationPullExecutor implements Runnable {
/**
* Mirrors a repository and, optionally, the server's users, and/or
* configuration settings from a origin Gitblit instance.
- *
+ *
* @param registration
* @throws Exception
*/
@@ -189,12 +189,12 @@ public class FederationPullExecutor implements Runnable {
repositoryName.indexOf(DOT_GIT_EXT));
}
}
-
+
// confirm that the origin of any pre-existing repository matches
// the clone url
String fetchHead = null;
Repository existingRepository = GitBlit.self().getRepository(repositoryName);
-
+
if (existingRepository == null && GitBlit.self().isCollectingGarbage(repositoryName)) {
logger.warn(MessageFormat.format("Skipping local repository {0}, busy collecting garbage", repositoryName));
continue;
@@ -253,13 +253,13 @@ public class FederationPullExecutor implements Runnable {
String branch = org.eclipse.jgit.lib.Constants.R_HEADS
+ ref.displayName.substring(ref.displayName.indexOf('/') + 1);
String hash = ref.getReferencedObjectId().getName();
-
+
JGitUtils.setBranchRef(r, branch, hash);
logger.info(MessageFormat.format(" resetting {0} of {1} to {2}", branch,
repository.name, hash));
}
}
-
+
String newHead;
if (StringUtils.isEmpty(repository.HEAD)) {
newHead = newFetchHead;
@@ -298,7 +298,7 @@ public class FederationPullExecutor implements Runnable {
federationSets.addAll(repository.federationSets);
}
repository.federationSets = new ArrayList<String>(federationSets);
-
+
// merge indexed branches
Set<String> indexedBranches = new HashSet<String>();
if (rm.indexedBranches != null) {
@@ -487,7 +487,7 @@ public class FederationPullExecutor implements Runnable {
/**
* Sends a status acknowledgment to the origin Gitblit instance. This
* includes the results of the federated pull.
- *
+ *
* @param registration
* @throws Exception
*/
@@ -507,7 +507,7 @@ public class FederationPullExecutor implements Runnable {
/**
* Schedules the next check of the federated Gitblit instance.
- *
+ *
* @param registration
*/
private void schedule(FederationModel registration) {
diff --git a/src/main/java/com/gitblit/FederationServlet.java b/src/main/java/com/gitblit/FederationServlet.java
index e7720508..5db96450 100644
--- a/src/main/java/com/gitblit/FederationServlet.java
+++ b/src/main/java/com/gitblit/FederationServlet.java
@@ -40,9 +40,9 @@ import com.gitblit.utils.TimeUtils;
/**
* Handles federation requests.
- *
+ *
* @author James Moger
- *
+ *
*/
public class FederationServlet extends JsonServlet {
@@ -54,7 +54,7 @@ public class FederationServlet extends JsonServlet {
/**
* Processes a federation request.
- *
+ *
* @param request
* @param response
* @throws javax.servlet.ServletException
@@ -231,7 +231,7 @@ public class FederationServlet extends JsonServlet {
return;
}
Map<String, String> scripts = new HashMap<String, String>();
-
+
Set<String> names = new HashSet<String>();
names.addAll(GitBlit.getStrings(Keys.groovy.preReceiveScripts));
names.addAll(GitBlit.getStrings(Keys.groovy.postReceiveScripts));
diff --git a/src/main/java/com/gitblit/FileSettings.java b/src/main/java/com/gitblit/FileSettings.java
index 3a42cad0..12739d20 100644
--- a/src/main/java/com/gitblit/FileSettings.java
+++ b/src/main/java/com/gitblit/FileSettings.java
@@ -26,9 +26,9 @@ import com.gitblit.utils.FileUtils;
/**
* Dynamically loads and reloads a properties file by keeping track of the last
* modification date.
- *
+ *
* @author James Moger
- *
+ *
*/
public class FileSettings extends IStoredSettings {
@@ -37,7 +37,7 @@ public class FileSettings extends IStoredSettings {
private final Properties properties = new Properties();
private volatile long lastModified;
-
+
private volatile boolean forceReload;
public FileSettings(String file) {
@@ -83,6 +83,7 @@ public class FileSettings extends IStoredSettings {
/**
* Updates the specified settings in the settings file.
*/
+ @Override
public synchronized boolean saveSettings(Map<String, String> settings) {
String content = FileUtils.readContent(propertiesFile, "\n");
for (Map.Entry<String, String> setting:settings.entrySet()) {
@@ -98,11 +99,11 @@ public class FileSettings extends IStoredSettings {
}
FileUtils.writeContent(propertiesFile, content);
// manually set the forceReload flag because not all JVMs support real
- // millisecond resolution of lastModified. (issue-55)
+ // millisecond resolution of lastModified. (issue-55)
forceReload = true;
return true;
}
-
+
private String regExEscape(String input) {
return input.replace(".", "\\.").replace("$", "\\$").replace("{", "\\{");
}
diff --git a/src/main/java/com/gitblit/GCExecutor.java b/src/main/java/com/gitblit/GCExecutor.java
index 0a0c8ad5..681065be 100644
--- a/src/main/java/com/gitblit/GCExecutor.java
+++ b/src/main/java/com/gitblit/GCExecutor.java
@@ -36,15 +36,15 @@ import com.gitblit.utils.FileUtils;
/**
* The GC executor handles periodic garbage collection in repositories.
- *
+ *
* @author James Moger
- *
+ *
*/
public class GCExecutor implements Runnable {
public static enum GCStatus {
READY, COLLECTING;
-
+
public boolean exceeds(GCStatus s) {
return ordinal() > s.ordinal();
}
@@ -52,11 +52,11 @@ public class GCExecutor implements Runnable {
private final Logger logger = LoggerFactory.getLogger(GCExecutor.class);
private final IStoredSettings settings;
-
+
private AtomicBoolean running = new AtomicBoolean(false);
-
+
private AtomicBoolean forceClose = new AtomicBoolean(false);
-
+
private final Map<String, GCStatus> gcCache = new ConcurrentHashMap<String, GCStatus>();
public GCExecutor(IStoredSettings settings) {
@@ -65,24 +65,24 @@ public class GCExecutor implements Runnable {
/**
* Indicates if the GC executor is ready to process repositories.
- *
+ *
* @return true if the GC executor is ready to process repositories
*/
public boolean isReady() {
return settings.getBoolean(Keys.git.enableGarbageCollection, false);
}
-
+
public boolean isRunning() {
return running.get();
}
-
+
public boolean lock(String repositoryName) {
return setGCStatus(repositoryName, GCStatus.COLLECTING);
}
/**
* Tries to set a GCStatus for the specified repository.
- *
+ *
* @param repositoryName
* @return true if the status has been set
*/
@@ -100,7 +100,7 @@ public class GCExecutor implements Runnable {
/**
* Returns true if Gitblit is actively collecting garbage in this repository.
- *
+ *
* @param repositoryName
* @return true if actively collecting garbage
*/
@@ -111,13 +111,13 @@ public class GCExecutor implements Runnable {
/**
* Resets the GC status to ready.
- *
+ *
* @param repositoryName
*/
public void releaseLock(String repositoryName) {
gcCache.put(repositoryName.toLowerCase(), GCStatus.READY);
}
-
+
public void close() {
forceClose.set(true);
}
@@ -127,8 +127,8 @@ public class GCExecutor implements Runnable {
if (!isReady()) {
return;
}
-
- running.set(true);
+
+ running.set(true);
Date now = new Date();
for (String repositoryName : GitBlit.self().getRepositoryList()) {
@@ -149,7 +149,7 @@ public class GCExecutor implements Runnable {
logger.warn(MessageFormat.format("GCExecutor is missing repository {0}?!?", repositoryName));
continue;
}
-
+
if (!isRepositoryIdle(repository)) {
logger.debug(MessageFormat.format("GCExecutor is skipping {0} because it is not idle", repositoryName));
continue;
@@ -162,13 +162,13 @@ public class GCExecutor implements Runnable {
logger.warn(MessageFormat.format("Can not acquire GC lock for {0}, skipping", repositoryName));
continue;
}
-
+
logger.debug(MessageFormat.format("GCExecutor locked idle repository {0}", repositoryName));
-
+
Git git = new Git(repository);
GarbageCollectCommand gc = git.gc();
Properties stats = gc.getStatistics();
-
+
// determine if this is a scheduled GC
Calendar cal = Calendar.getInstance();
cal.setTime(model.lastGC);
@@ -190,10 +190,10 @@ public class GCExecutor implements Runnable {
if (hasGarbage && (hasEnoughGarbage || shouldCollectGarbage)) {
long looseKB = sizeOfLooseObjects/1024L;
logger.info(MessageFormat.format("Collecting {1} KB of loose objects from {0}", repositoryName, looseKB));
-
+
// do the deed
gc.call();
-
+
garbageCollected = true;
}
} catch (Exception e) {
@@ -206,19 +206,19 @@ public class GCExecutor implements Runnable {
model.lastGC = new Date();
GitBlit.self().updateConfiguration(repository, model);
}
-
+
repository.close();
}
-
- // reset the GC lock
+
+ // reset the GC lock
releaseLock(repositoryName);
logger.debug(MessageFormat.format("GCExecutor released GC lock for {0}", repositoryName));
}
}
-
+
running.set(false);
}
-
+
private boolean isRepositoryIdle(Repository repository) {
try {
// Read the use count.
diff --git a/src/main/java/com/gitblit/GitBlit.java b/src/main/java/com/gitblit/GitBlit.java
index c5304b4f..cb37b504 100644
--- a/src/main/java/com/gitblit/GitBlit.java
+++ b/src/main/java/com/gitblit/GitBlit.java
@@ -145,28 +145,28 @@ import com.google.gson.reflect.TypeToken;
* the web ui and the servlets. This class is either directly instantiated by
* the GitBlitServer class (Gitblit GO) or is reflectively instantiated from the
* definition in the web.xml file (Gitblit WAR).
- *
+ *
* This class is the central logic processor for Gitblit. All settings, user
* object, and repository object operations pass through this class.
- *
+ *
* Repository Resolution. There are two pathways for finding repositories. One
* pathway, for web ui display and repository authentication & authorization, is
* within this class. The other pathway is through the standard GitServlet.
- *
+ *
* @author James Moger
- *
+ *
*/
public class GitBlit implements ServletContextListener {
private static GitBlit gitblit;
-
+
private final Logger logger = LoggerFactory.getLogger(GitBlit.class);
private final ScheduledExecutorService scheduledExecutor = Executors.newScheduledThreadPool(5);
private final List<FederationModel> federationRegistrations = Collections
.synchronizedList(new ArrayList<FederationModel>());
-
+
private final ObjectCache<Collection<GitClientApplication>> clientApplications = new ObjectCache<Collection<GitClientApplication>>();
private final Map<String, FederationModel> federationPullResults = new ConcurrentHashMap<String, FederationModel>();
@@ -174,19 +174,19 @@ public class GitBlit implements ServletContextListener {
private final ObjectCache<Long> repositorySizeCache = new ObjectCache<Long>();
private final ObjectCache<List<Metric>> repositoryMetricsCache = new ObjectCache<List<Metric>>();
-
+
private final Map<String, RepositoryModel> repositoryListCache = new ConcurrentHashMap<String, RepositoryModel>();
-
+
private final Map<String, ProjectModel> projectCache = new ConcurrentHashMap<String, ProjectModel>();
-
+
private final AtomicReference<String> repositoryListSettingsChecksum = new AtomicReference<String>("");
-
+
private final ObjectCache<String> projectMarkdownCache = new ObjectCache<String>();
-
+
private final ObjectCache<String> projectRepositoriesMarkdownCache = new ObjectCache<String>();
private ServletContext servletContext;
-
+
private File baseFolder;
private File repositoriesFolder;
@@ -200,15 +200,15 @@ public class GitBlit implements ServletContextListener {
private ServerStatus serverStatus;
private MailExecutor mailExecutor;
-
+
private LuceneExecutor luceneExecutor;
-
+
private GCExecutor gcExecutor;
-
+
private TimeZone timezone;
-
+
private FileBasedConfig projectConfigs;
-
+
private FanoutService fanoutService;
private GitDaemon gitDaemon;
@@ -227,7 +227,7 @@ public class GitBlit implements ServletContextListener {
/**
* Returns the Gitblit singleton.
- *
+ *
* @return gitblit singleton
*/
public static GitBlit self() {
@@ -236,19 +236,19 @@ public class GitBlit implements ServletContextListener {
}
return gitblit;
}
-
+
/**
* Returns the boot date of the Gitblit server.
- *
+ *
* @return the boot date of Gitblit
*/
public static Date getBootDate() {
return self().serverStatus.bootDate;
}
-
+
/**
* Returns the most recent change date of any repository served by Gitblit.
- *
+ *
* @return a date
*/
public static Date getLastActivityDate() {
@@ -266,17 +266,17 @@ public class GitBlit implements ServletContextListener {
/**
* Determine if this is the GO variant of Gitblit.
- *
+ *
* @return true if this is the GO variant of Gitblit.
*/
public static boolean isGO() {
return self().settings instanceof FileSettings;
}
-
+
/**
* Determine if this Gitblit instance is actively serving git repositories
* or if it is merely a repository viewer.
- *
+ *
* @return true if Gitblit is serving repositories
*/
public static boolean isServingRepositories() {
@@ -286,7 +286,7 @@ public class GitBlit implements ServletContextListener {
/**
* Determine if this Gitblit instance is actively serving git repositories
* or if it is merely a repository viewer.
- *
+ *
* @return true if Gitblit is serving repositories
*/
public static boolean isSendingMail() {
@@ -295,7 +295,7 @@ public class GitBlit implements ServletContextListener {
/**
* Returns the preferred timezone for the Gitblit instance.
- *
+ *
* @return a timezone
*/
public static TimeZone getTimezone() {
@@ -309,31 +309,31 @@ public class GitBlit implements ServletContextListener {
}
return self().timezone;
}
-
+
/**
* Returns the active settings.
- *
+ *
* @return the active settings
*/
public static IStoredSettings getSettings() {
return self().settings;
}
-
+
/**
* Returns the user-defined blob encodings.
- *
+ *
* @return an array of encodings, may be empty
*/
public static String [] getEncodings() {
return getStrings(Keys.web.blobEncodings).toArray(new String[0]);
}
-
+
/**
* Returns the boolean value for the specified key. If the key does not
* exist or the value for the key can not be interpreted as a boolean, the
* defaultValue is returned.
- *
+ *
* @see IStoredSettings.getBoolean(String, boolean)
* @param key
* @param defaultValue
@@ -347,7 +347,7 @@ public class GitBlit implements ServletContextListener {
* Returns the integer value for the specified key. If the key does not
* exist or the value for the key can not be interpreted as an integer, the
* defaultValue is returned.
- *
+ *
* @see IStoredSettings.getInteger(String key, int defaultValue)
* @param key
* @param defaultValue
@@ -361,7 +361,7 @@ public class GitBlit implements ServletContextListener {
* Returns the integer list for the specified key. If the key does not
* exist or the value for the key can not be interpreted as an integer, an
* empty list is returned.
- *
+ *
* @see IStoredSettings.getIntegers(String key)
* @param key
* @return key value or defaultValue
@@ -369,12 +369,12 @@ public class GitBlit implements ServletContextListener {
public static List<Integer> getIntegers(String key) {
return self().settings.getIntegers(key);
}
-
+
/**
* Returns the value in bytes for the specified key. If the key does not
* exist or the value for the key can not be interpreted as an integer, the
* defaultValue is returned.
- *
+ *
* @see IStoredSettings.getFilesize(String key, int defaultValue)
* @param key
* @param defaultValue
@@ -388,7 +388,7 @@ public class GitBlit implements ServletContextListener {
* Returns the value in bytes for the specified key. If the key does not
* exist or the value for the key can not be interpreted as a long, the
* defaultValue is returned.
- *
+ *
* @see IStoredSettings.getFilesize(String key, long defaultValue)
* @param key
* @param defaultValue
@@ -402,7 +402,7 @@ public class GitBlit implements ServletContextListener {
* Returns the char value for the specified key. If the key does not exist
* or the value for the key can not be interpreted as a character, the
* defaultValue is returned.
- *
+ *
* @see IStoredSettings.getChar(String key, char defaultValue)
* @param key
* @param defaultValue
@@ -416,7 +416,7 @@ public class GitBlit implements ServletContextListener {
* Returns the string value for the specified key. If the key does not exist
* or the value for the key can not be interpreted as a string, the
* defaultValue is returned.
- *
+ *
* @see IStoredSettings.getString(String key, String defaultValue)
* @param key
* @param defaultValue
@@ -428,7 +428,7 @@ public class GitBlit implements ServletContextListener {
/**
* Returns a list of space-separated strings from the specified key.
- *
+ *
* @see IStoredSettings.getStrings(String key)
* @param n
* @return list of strings
@@ -439,7 +439,7 @@ public class GitBlit implements ServletContextListener {
/**
* Returns a map of space-separated key-value pairs from the specified key.
- *
+ *
* @see IStoredSettings.getStrings(String key)
* @param n
* @return map of string, string
@@ -451,7 +451,7 @@ public class GitBlit implements ServletContextListener {
/**
* Returns the list of keys whose name starts with the specified prefix. If
* the prefix is null or empty, all key names are returned.
- *
+ *
* @see IStoredSettings.getAllKeys(String key)
* @param startingWith
* @return list of keys
@@ -463,7 +463,7 @@ public class GitBlit implements ServletContextListener {
/**
* Is Gitblit running in debug mode?
- *
+ *
* @return true if Gitblit is running in debug mode
*/
public static boolean isDebugMode() {
@@ -472,7 +472,7 @@ public class GitBlit implements ServletContextListener {
/**
* Returns the file object for the specified configuration key.
- *
+ *
* @return the file
*/
public static File getFileOrFolder(String key, String defaultFileOrFolder) {
@@ -486,7 +486,7 @@ public class GitBlit implements ServletContextListener {
* file or folder retrievals are (at least initially) funneled through this
* method so it is the correct point to globally override/alter filesystem
* access based on environment or some other indicator.
- *
+ *
* @return the file
*/
public static File getFileOrFolder(String fileOrFolder) {
@@ -497,7 +497,7 @@ public class GitBlit implements ServletContextListener {
/**
* Returns the path of the repositories folder. This method checks to see if
* Gitblit is running on a cloud service and may return an adjusted path.
- *
+ *
* @return the repositories folder path
*/
public static File getRepositoriesFolder() {
@@ -507,7 +507,7 @@ public class GitBlit implements ServletContextListener {
/**
* Returns the path of the proposals folder. This method checks to see if
* Gitblit is running on a cloud service and may return an adjusted path.
- *
+ *
* @return the proposals folder path
*/
public static File getProposalsFolder() {
@@ -517,16 +517,16 @@ public class GitBlit implements ServletContextListener {
/**
* Returns the path of the Groovy folder. This method checks to see if
* Gitblit is running on a cloud service and may return an adjusted path.
- *
+ *
* @return the Groovy scripts folder path
*/
public static File getGroovyScriptsFolder() {
return getFileOrFolder(Keys.groovy.scriptsFolder, "${baseFolder}/groovy");
}
-
+
/**
* Updates the list of server settings.
- *
+ *
* @param settings
* @return true if the update succeeded
*/
@@ -540,10 +540,10 @@ public class GitBlit implements ServletContextListener {
serverStatus.heapFree = Runtime.getRuntime().freeMemory();
return serverStatus;
}
-
+
/**
* Returns a list of repository URLs and the user access permission.
- *
+ *
* @param request
* @param user
* @param repository
@@ -589,13 +589,13 @@ public class GitBlit implements ServletContextListener {
}
return list;
}
-
+
protected String getRepositoryUrl(HttpServletRequest request, String username, RepositoryModel repository) {
StringBuilder sb = new StringBuilder();
sb.append(HttpUtils.getGitblitURL(request));
sb.append(Constants.GIT_PATH);
sb.append(repository.name);
-
+
// inject username into repository url if authentication is required
if (repository.accessRestriction.exceeds(AccessRestrictionType.NONE)
&& !StringUtils.isEmpty(username)) {
@@ -603,7 +603,7 @@ public class GitBlit implements ServletContextListener {
}
return sb.toString();
}
-
+
protected String getGitDaemonUrl(HttpServletRequest request, UserModel user, RepositoryModel repository) {
if (gitDaemon != null) {
String bindInterface = settings.getString(Keys.git.daemonBindInterface, "localhost");
@@ -620,7 +620,7 @@ public class GitBlit implements ServletContextListener {
}
return null;
}
-
+
protected AccessPermission getGitDaemonAccessPermission(UserModel user, RepositoryModel repository) {
if (gitDaemon != null && user.canClone(repository)) {
AccessPermission gitDaemonPermission = user.getRepositoryPermission(repository).permission;
@@ -643,7 +643,7 @@ public class GitBlit implements ServletContextListener {
/**
* Returns the list of custom client applications to be used for the
* repository url panel;
- *
+ *
* @return a collection of client applications
*/
public Collection<GitClientApplication> getClientApplications() {
@@ -662,13 +662,13 @@ public class GitBlit implements ServletContextListener {
if (clients != null) {
clientApplications.updateObject("user", lastModified, clients);
return clients;
- }
+ }
} catch (IOException e) {
logger.error("Failed to deserialize " + userDefs.getAbsolutePath(), e);
}
}
}
-
+
// no user definitions, use system definitions
if (!clientApplications.hasCurrent("system", new Date(0))) {
try {
@@ -682,10 +682,10 @@ public class GitBlit implements ServletContextListener {
logger.error("Failed to deserialize clientapps.json resource!", e);
}
}
-
+
return clientApplications.getObject("system");
}
-
+
private Collection<GitClientApplication> readClientApplications(InputStream is) {
try {
Type type = new TypeToken<Collection<GitClientApplication>>() {
@@ -705,7 +705,7 @@ public class GitBlit implements ServletContextListener {
/**
* Set the user service. The user service authenticates all users and is
* responsible for managing user permissions.
- *
+ *
* @param userService
*/
public void setUserService(IUserService userService) {
@@ -713,14 +713,14 @@ public class GitBlit implements ServletContextListener {
this.userService = userService;
this.userService.setup(settings);
}
-
+
public boolean supportsAddUser() {
return supportsCredentialChanges(new UserModel(""));
}
-
+
/**
* Returns true if the user's credentials can be changed.
- *
+ *
* @param user
* @return true if the user service supports credential changes
*/
@@ -738,7 +738,7 @@ public class GitBlit implements ServletContextListener {
/**
* Returns true if the user's display name can be changed.
- *
+ *
* @param user
* @return true if the user service supports display name changes
*/
@@ -748,7 +748,7 @@ public class GitBlit implements ServletContextListener {
/**
* Returns true if the user's email address can be changed.
- *
+ *
* @param user
* @return true if the user service supports email address changes
*/
@@ -758,7 +758,7 @@ public class GitBlit implements ServletContextListener {
/**
* Returns true if the user's team memberships can be changed.
- *
+ *
* @param user
* @return true if the user service supports team membership changes
*/
@@ -768,7 +768,7 @@ public class GitBlit implements ServletContextListener {
/**
* Returns true if the username represents an internal account
- *
+ *
* @param username
* @return true if the specified username represents an internal account
*/
@@ -780,7 +780,7 @@ public class GitBlit implements ServletContextListener {
/**
* Authenticate a user based on a username and password.
- *
+ *
* @see IUserService.authenticate(String, char[])
* @param username
* @param password
@@ -817,7 +817,7 @@ public class GitBlit implements ServletContextListener {
/**
* Authenticate a user based on their cookie.
- *
+ *
* @param cookies
* @return a user object or null
*/
@@ -840,22 +840,22 @@ public class GitBlit implements ServletContextListener {
/**
* Authenticate a user based on HTTP request parameters.
- *
+ *
* Authentication by X509Certificate is tried first and then by cookie.
- *
+ *
* @param httpRequest
* @return a user object or null
*/
public UserModel authenticate(HttpServletRequest httpRequest) {
return authenticate(httpRequest, false);
}
-
+
/**
* Authenticate a user based on HTTP request parameters.
- *
+ *
* Authentication by X509Certificate, servlet container principal, cookie,
* and BASIC header.
- *
+ *
* @param httpRequest
* @param requiresCertificate
* @return a user object or null
@@ -879,12 +879,12 @@ public class GitBlit implements ServletContextListener {
model.username, metadata.serialNumber, httpRequest.getRemoteAddr()));
}
}
-
+
if (requiresCertificate) {
// caller requires client certificate authentication (e.g. git servlet)
return null;
}
-
+
// try to authenticate by servlet container principal
Principal principal = httpRequest.getUserPrincipal();
if (principal != null) {
@@ -915,7 +915,7 @@ public class GitBlit implements ServletContextListener {
}
}
}
-
+
// try to authenticate by cookie
if (allowCookieAuthentication()) {
UserModel user = authenticate(httpRequest.getCookies());
@@ -926,7 +926,7 @@ public class GitBlit implements ServletContextListener {
return user;
}
}
-
+
// try to authenticate by BASIC
final String authorization = httpRequest.getHeader("Authorization");
if (authorization != null && authorization.startsWith("Basic")) {
@@ -947,14 +947,14 @@ public class GitBlit implements ServletContextListener {
user.username, httpRequest.getRemoteAddr()));
return user;
} else {
- logger.warn(MessageFormat.format("Failed login attempt for {0}, invalid credentials from {1}",
+ logger.warn(MessageFormat.format("Failed login attempt for {0}, invalid credentials from {1}",
username, httpRequest.getRemoteAddr()));
}
}
}
return null;
}
-
+
protected void flagWicketSession(AuthenticationType authenticationType) {
RequestCycle requestCycle = RequestCycle.get();
if (requestCycle != null) {
@@ -977,7 +977,7 @@ public class GitBlit implements ServletContextListener {
/**
* Sets a cookie for the specified user.
- *
+ *
* @param response
* @param user
*/
@@ -1009,10 +1009,10 @@ public class GitBlit implements ServletContextListener {
response.addCookie(userCookie);
}
}
-
+
/**
* Logout a user.
- *
+ *
* @param user
*/
public void logout(UserModel user) {
@@ -1024,27 +1024,27 @@ public class GitBlit implements ServletContextListener {
/**
* Encode the username for user in an url.
- *
+ *
* @param name
* @return the encoded name
*/
protected String encodeUsername(String name) {
- return name.replace("@", "%40").replace(" ", "%20").replace("\\", "%5C");
+ return name.replace("@", "%40").replace(" ", "%20").replace("\\", "%5C");
}
/**
* Decode a username from an encoded url.
- *
+ *
* @param name
* @return the decoded name
*/
protected String decodeUsername(String name) {
return name.replace("%40", "@").replace("%20", " ").replace("%5C", "\\");
}
-
+
/**
* Returns the list of all users available to the login service.
- *
+ *
* @see IUserService.getAllUsernames()
* @return list of all usernames
*/
@@ -1055,7 +1055,7 @@ public class GitBlit implements ServletContextListener {
/**
* Returns the list of all users available to the login service.
- *
+ *
* @see IUserService.getAllUsernames()
* @return list of all usernames
*/
@@ -1066,7 +1066,7 @@ public class GitBlit implements ServletContextListener {
/**
* Delete the user object with the specified username
- *
+ *
* @see IUserService.deleteUser(String)
* @param username
* @return true if successful
@@ -1078,7 +1078,7 @@ public class GitBlit implements ServletContextListener {
String usernameDecoded = decodeUsername(username);
return userService.deleteUser(usernameDecoded);
}
-
+
protected UserModel getFederationUser() {
// the federation user is an administrator
UserModel federationUser = new UserModel(Constants.FEDERATION_USER);
@@ -1088,7 +1088,7 @@ public class GitBlit implements ServletContextListener {
/**
* Retrieve the user object for the specified username.
- *
+ *
* @see IUserService.getUserModel(String)
* @param username
* @return a user object or null
@@ -1098,14 +1098,14 @@ public class GitBlit implements ServletContextListener {
return null;
}
String usernameDecoded = decodeUsername(username);
- UserModel user = userService.getUserModel(usernameDecoded);
+ UserModel user = userService.getUserModel(usernameDecoded);
return user;
}
-
+
/**
* Returns the effective list of permissions for this user, taking into account
* team memberships, ownerships.
- *
+ *
* @param user
* @return the effective list of permissions for the user
*/
@@ -1140,7 +1140,7 @@ public class GitBlit implements ServletContextListener {
set.add(rp);
}
}
-
+
List<RegistrantAccessPermission> list = new ArrayList<RegistrantAccessPermission>(set);
Collections.sort(list);
return list;
@@ -1150,7 +1150,7 @@ public class GitBlit implements ServletContextListener {
* Returns the list of users and their access permissions for the specified
* repository including permission source information such as the team or
* regular expression which sets the permission.
- *
+ *
* @param repository
* @return a list of RegistrantAccessPermissions
*/
@@ -1173,10 +1173,10 @@ public class GitBlit implements ServletContextListener {
}
return list;
}
-
+
/**
* Sets the access permissions to the specified repository for the specified users.
- *
+ *
* @param repository
* @param permissions
* @return true if the user models have been updated
@@ -1193,11 +1193,11 @@ public class GitBlit implements ServletContextListener {
}
return userService.updateUserModels(users);
}
-
+
/**
* Returns the list of all users who have an explicit access permission
* for the specified repository.
- *
+ *
* @see IUserService.getUsernamesForRepositoryRole(String)
* @param repository
* @return list of all usernames that have an access permission for the repository
@@ -1209,7 +1209,7 @@ public class GitBlit implements ServletContextListener {
/**
* Sets the list of all uses who are allowed to bypass the access
* restriction placed on the specified repository.
- *
+ *
* @see IUserService.setUsernamesForRepositoryRole(String, List<String>)
* @param repository
* @param usernames
@@ -1225,7 +1225,7 @@ public class GitBlit implements ServletContextListener {
/**
* Adds/updates a complete user object keyed by username. This method allows
* for renaming a user.
- *
+ *
* @see IUserService.updateUserModel(String, UserModel)
* @param username
* @param user
@@ -1240,7 +1240,7 @@ public class GitBlit implements ServletContextListener {
"Failed to rename ''{0}'' because ''{1}'' already exists.", username,
user.username));
}
-
+
// rename repositories and owner fields for all repositories
for (RepositoryModel model : getRepositoryModels(user)) {
if (model.isUsersPersonalRepository(username)) {
@@ -1265,7 +1265,7 @@ public class GitBlit implements ServletContextListener {
/**
* Returns the list of available teams that a user or repository may be
* assigned to.
- *
+ *
* @return the list of teams
*/
public List<String> getAllTeamnames() {
@@ -1276,7 +1276,7 @@ public class GitBlit implements ServletContextListener {
/**
* Returns the list of available teams that a user or repository may be
* assigned to.
- *
+ *
* @return the list of teams
*/
public List<TeamModel> getAllTeams() {
@@ -1286,19 +1286,19 @@ public class GitBlit implements ServletContextListener {
/**
* Returns the TeamModel object for the specified name.
- *
+ *
* @param teamname
* @return a TeamModel object or null
*/
public TeamModel getTeamModel(String teamname) {
return userService.getTeamModel(teamname);
}
-
+
/**
* Returns the list of teams and their access permissions for the specified
* repository including the source of the permission such as the admin flag
* or a regular expression.
- *
+ *
* @param repository
* @return a list of RegistrantAccessPermissions
*/
@@ -1313,10 +1313,10 @@ public class GitBlit implements ServletContextListener {
Collections.sort(list);
return list;
}
-
+
/**
* Sets the access permissions to the specified repository for the specified teams.
- *
+ *
* @param repository
* @param permissions
* @return true if the team models have been updated
@@ -1333,11 +1333,11 @@ public class GitBlit implements ServletContextListener {
}
return userService.updateTeamModels(teams);
}
-
+
/**
* Returns the list of all teams who have an explicit access permission for
* the specified repository.
- *
+ *
* @see IUserService.getTeamnamesForRepositoryRole(String)
* @param repository
* @return list of all teamnames with explicit access permissions to the repository
@@ -1349,7 +1349,7 @@ public class GitBlit implements ServletContextListener {
/**
* Sets the list of all uses who are allowed to bypass the access
* restriction placed on the specified repository.
- *
+ *
* @see IUserService.setTeamnamesForRepositoryRole(String, List<String>)
* @param repository
* @param teamnames
@@ -1364,7 +1364,7 @@ public class GitBlit implements ServletContextListener {
/**
* Updates the TeamModel object for the specified name.
- *
+ *
* @param teamname
* @param team
* @param isCreate
@@ -1385,7 +1385,7 @@ public class GitBlit implements ServletContextListener {
/**
* Delete the team object with the specified teamname
- *
+ *
* @see IUserService.deleteTeam(String)
* @param teamname
* @return true if successful
@@ -1393,17 +1393,17 @@ public class GitBlit implements ServletContextListener {
public boolean deleteTeam(String teamname) {
return userService.deleteTeam(teamname);
}
-
+
/**
* Adds the repository to the list of cached repositories if Gitblit is
* configured to cache the repository list.
- *
+ *
* @param model
*/
private void addToCachedRepositoryList(RepositoryModel model) {
if (settings.getBoolean(Keys.git.cacheRepositoryList, true)) {
repositoryListCache.put(model.name.toLowerCase(), model);
-
+
// update the fork origin repository with this repository clone
if (!StringUtils.isEmpty(model.originRepository)) {
if (repositoryListCache.containsKey(model.originRepository)) {
@@ -1413,10 +1413,10 @@ public class GitBlit implements ServletContextListener {
}
}
}
-
+
/**
* Removes the repository from the list of cached repositories.
- *
+ *
* @param name
* @return the model being removed
*/
@@ -1429,23 +1429,23 @@ public class GitBlit implements ServletContextListener {
/**
* Clears all the cached metadata for the specified repository.
- *
+ *
* @param repositoryName
*/
private void clearRepositoryMetadataCache(String repositoryName) {
repositorySizeCache.remove(repositoryName);
repositoryMetricsCache.remove(repositoryName);
}
-
+
/**
* Resets the repository list cache.
- *
+ *
*/
public void resetRepositoryListCache() {
logger.info("Repository cache manually reset");
repositoryListCache.clear();
}
-
+
/**
* Calculate the checksum of settings that affect the repository list cache.
* @return a checksum
@@ -1460,11 +1460,11 @@ public class GitBlit implements ServletContextListener {
String checksum = StringUtils.getSHA1(ns.toString());
return checksum;
}
-
+
/**
* Compare the last repository list setting checksum to the current checksum.
* If different then clear the cache so that it may be rebuilt.
- *
+ *
* @return true if the cached repository list is valid since the last check
*/
private boolean isValidRepositoryList() {
@@ -1481,14 +1481,14 @@ public class GitBlit implements ServletContextListener {
/**
* Returns the list of all repositories available to Gitblit. This method
* does not consider user access permissions.
- *
+ *
* @return list of all repositories
*/
public List<String> getRepositoryList() {
if (repositoryListCache.size() == 0 || !isValidRepositoryList()) {
// we are not caching OR we have not yet cached OR the cached list is invalid
long startTime = System.currentTimeMillis();
- List<String> repositories = JGitUtils.getRepositoryList(repositoriesFolder,
+ List<String> repositories = JGitUtils.getRepositoryList(repositoriesFolder,
settings.getBoolean(Keys.git.onlyAccessBareRepositories, false),
settings.getBoolean(Keys.git.searchRepositoriesSubfolders, true),
settings.getInteger(Keys.git.searchRecursionDepth, -1),
@@ -1505,11 +1505,11 @@ public class GitBlit implements ServletContextListener {
// optionally (re)calculate repository sizes
msg = "{0} repositories identified with calculated folder sizes in {1} msecs";
}
-
+
for (String repository : repositories) {
getRepositoryModel(repository);
}
-
+
// rebuild fork networks
for (RepositoryModel model : repositoryListCache.values()) {
if (!StringUtils.isEmpty(model.originRepository)) {
@@ -1519,12 +1519,12 @@ public class GitBlit implements ServletContextListener {
}
}
}
-
+
long duration = System.currentTimeMillis() - startTime;
logger.info(MessageFormat.format(msg, repositoryListCache.size(), duration));
}
}
-
+
// return sorted copy of cached list
List<String> list = new ArrayList<String>();
for (RepositoryModel model : repositoryListCache.values()) {
@@ -1536,7 +1536,7 @@ public class GitBlit implements ServletContextListener {
/**
* Returns the JGit repository for the specified name.
- *
+ *
* @param repositoryName
* @return repository or null
*/
@@ -1546,7 +1546,7 @@ public class GitBlit implements ServletContextListener {
/**
* Returns the JGit repository for the specified name.
- *
+ *
* @param repositoryName
* @param logError
* @return repository or null
@@ -1555,7 +1555,7 @@ public class GitBlit implements ServletContextListener {
// Decode url-encoded repository name (issue-278)
// http://stackoverflow.com/questions/17183110
repositoryName = repositoryName.replace("%7E", "~").replace("%7e", "~");
-
+
if (isCollectingGarbage(repositoryName)) {
logger.warn(MessageFormat.format("Rejecting request for {0}, busy collecting garbage!", repositoryName));
return null;
@@ -1564,7 +1564,7 @@ public class GitBlit implements ServletContextListener {
File dir = FileKey.resolve(new File(repositoriesFolder, repositoryName), FS.DETECTED);
if (dir == null)
return null;
-
+
Repository r = null;
try {
FileKey key = FileKey.exact(dir, FS.DETECTED);
@@ -1580,7 +1580,7 @@ public class GitBlit implements ServletContextListener {
/**
* Returns the list of repository models that are accessible to the user.
- *
+ *
* @param user
* @return list of repository models accessible to user
*/
@@ -1611,7 +1611,7 @@ public class GitBlit implements ServletContextListener {
/**
* Returns a repository model if the repository exists and the user may
* access the repository.
- *
+ *
* @param user
* @param repositoryName
* @return repository model or null
@@ -1633,7 +1633,7 @@ public class GitBlit implements ServletContextListener {
/**
* Returns the repository model for the specified repository. This method
* does not consider user access permissions.
- *
+ *
* @param repositoryName
* @return repository model or null
*/
@@ -1650,7 +1650,7 @@ public class GitBlit implements ServletContextListener {
addToCachedRepositoryList(model);
return DeepCopier.copy(model);
}
-
+
// cached model
RepositoryModel model = repositoryListCache.get(repositoryName.toLowerCase());
@@ -1669,7 +1669,7 @@ public class GitBlit implements ServletContextListener {
logger.error(MessageFormat.format("Repository \"{0}\" is missing! Removing from cache.", repositoryName));
return null;
}
-
+
FileBasedConfig config = (FileBasedConfig) getRepositoryConfig(r);
if (config.isOutdated()) {
// reload model
@@ -1678,7 +1678,7 @@ public class GitBlit implements ServletContextListener {
removeFromCachedRepositoryList(model.name);
addToCachedRepositoryList(model);
} else {
- // update a few repository parameters
+ // update a few repository parameters
if (!model.hasCommits) {
// update hasCommits, assume a repository only gains commits :)
model.hasCommits = JGitUtils.hasCommits(r);
@@ -1687,14 +1687,14 @@ public class GitBlit implements ServletContextListener {
updateLastChangeFields(r, model);
}
r.close();
-
+
// return a copy of the cached model
return DeepCopier.copy(model);
}
-
+
/**
* Returns the star count of the repository.
- *
+ *
* @param repository
* @return the star count
*/
@@ -1707,7 +1707,7 @@ public class GitBlit implements ServletContextListener {
}
return count;
}
-
+
private void reloadProjectMarkdown(ProjectModel project) {
// project markdown
File pmkd = new File(getRepositoriesFolder(), (project.isRoot ? "" : project.name) + "/project.mkd");
@@ -1719,7 +1719,7 @@ public class GitBlit implements ServletContextListener {
}
project.projectMarkdown = projectMarkdownCache.getObject(project.name);
}
-
+
// project repositories markdown
File rmkd = new File(getRepositoriesFolder(), (project.isRoot ? "" : project.name) + "/repositories.mkd");
if (rmkd.exists()) {
@@ -1731,17 +1731,17 @@ public class GitBlit implements ServletContextListener {
project.repositoriesMarkdown = projectRepositoriesMarkdownCache.getObject(project.name);
}
}
-
-
+
+
/**
* Returns the map of project config. This map is cached and reloaded if
* the underlying projects.conf file changes.
- *
+ *
* @return project config map
*/
private Map<String, ProjectModel> getProjectConfigs() {
if (projectCache.isEmpty() || projectConfigs.isOutdated()) {
-
+
try {
projectConfigs.load();
} catch (Exception e) {
@@ -1765,9 +1765,9 @@ public class GitBlit implements ServletContextListener {
}
project.title = projectConfigs.getString("project", name, "title");
project.description = projectConfigs.getString("project", name, "description");
-
+
reloadProjectMarkdown(project);
-
+
configs.put(name.toLowerCase(), project);
}
projectCache.clear();
@@ -1775,10 +1775,10 @@ public class GitBlit implements ServletContextListener {
}
return projectCache;
}
-
+
/**
* Returns a list of project models for the user.
- *
+ *
* @param user
* @param includeUsers
* @return list of projects that are accessible to the user
@@ -1790,9 +1790,9 @@ public class GitBlit implements ServletContextListener {
Map<String, ProjectModel> map = new TreeMap<String, ProjectModel>();
// root project
map.put("", configs.get(""));
-
+
for (RepositoryModel model : getRepositoryModels(user)) {
- String rootPath = StringUtils.getRootPath(model.name).toLowerCase();
+ String rootPath = StringUtils.getRootPath(model.name).toLowerCase();
if (!map.containsKey(rootPath)) {
ProjectModel project;
if (configs.containsKey(rootPath)) {
@@ -1806,7 +1806,7 @@ public class GitBlit implements ServletContextListener {
}
map.get(rootPath).addRepository(model);
}
-
+
// sort projects, root project first
List<ProjectModel> projects;
if (includeUsers) {
@@ -1829,10 +1829,10 @@ public class GitBlit implements ServletContextListener {
}
return projects;
}
-
+
/**
* Returns the project model for the specified user.
- *
+ *
* @param name
* @param user
* @return a project model, or null if it does not exist
@@ -1845,10 +1845,10 @@ public class GitBlit implements ServletContextListener {
}
return null;
}
-
+
/**
* Returns a project model for the Gitblit/system user.
- *
+ *
* @param name a project name
* @return a project model or null if the project does not exist
*/
@@ -1888,16 +1888,16 @@ public class GitBlit implements ServletContextListener {
// no repositories == no project
return null;
}
-
+
reloadProjectMarkdown(project);
return project;
}
-
+
/**
* Returns the list of project models that are referenced by the supplied
* repository model list. This is an alternative method exists to ensure
* Gitblit does not call getRepositoryModels(UserModel) twice in a request.
- *
+ *
* @param repositoryModels
* @param includeUsers
* @return a list of project models
@@ -1935,7 +1935,7 @@ public class GitBlit implements ServletContextListener {
}
return new ArrayList<ProjectModel>(projects.values());
}
-
+
/**
* Workaround JGit. I need to access the raw config object directly in order
* to see if the config is dirty so that I can reload a repository model.
@@ -1943,7 +1943,7 @@ public class GitBlit implements ServletContextListener {
* config. If the config changes are made within Gitblit this is fine as
* the returned config will still be flagged as dirty. BUT... if the config
* is manipulated outside Gitblit then it fails to recognize this as dirty.
- *
+ *
* @param r
* @return a config
*/
@@ -1958,10 +1958,10 @@ public class GitBlit implements ServletContextListener {
}
return r.getConfig();
}
-
+
/**
* Create a repository model from the configuration and repository data.
- *
+ *
* @param repositoryName
* @return a repositoryModel or null if the repository does not exist
*/
@@ -1984,10 +1984,10 @@ public class GitBlit implements ServletContextListener {
model.name = repositoryName;
}
model.projectPath = StringUtils.getFirstPathElement(repositoryName);
-
+
StoredConfig config = r.getConfig();
boolean hasOrigin = !StringUtils.isEmpty(config.getString("remote", "origin", "url"));
-
+
if (config != null) {
// Initialize description from description file
if (getConfig(config,"description", null) == null) {
@@ -2046,7 +2046,7 @@ public class GitBlit implements ServletContextListener {
Constants.CONFIG_GITBLIT, null, "indexBranch")));
model.metricAuthorExclusions = new ArrayList<String>(Arrays.asList(config.getStringList(
Constants.CONFIG_GITBLIT, null, "metricAuthorExclusions")));
-
+
// Custom defined properties
model.customFields = new LinkedHashMap<String, String>();
for (String aProperty : config.getNames(Constants.CONFIG_GITBLIT, Constants.CONFIG_CUSTOM_FIELDS)) {
@@ -2059,7 +2059,7 @@ public class GitBlit implements ServletContextListener {
model.hasCommits = JGitUtils.hasCommits(r);
updateLastChangeFields(r, model);
r.close();
-
+
if (StringUtils.isEmpty(model.originRepository) && model.origin != null && model.origin.startsWith("file://")) {
// repository was cloned locally... perhaps as a fork
try {
@@ -2070,7 +2070,7 @@ public class GitBlit implements ServletContextListener {
File repoFolder = new File(getRepositoriesFolder(), originRepo);
if (repoFolder.exists()) {
model.originRepository = originRepo.toLowerCase();
-
+
// persist the fork origin
updateConfiguration(r, model);
}
@@ -2081,20 +2081,20 @@ public class GitBlit implements ServletContextListener {
}
return model;
}
-
+
/**
* Determines if this server has the requested repository.
- *
+ *
* @param n
* @return true if the repository exists
*/
public boolean hasRepository(String repositoryName) {
return hasRepository(repositoryName, false);
}
-
+
/**
* Determines if this server has the requested repository.
- *
+ *
* @param n
* @param caseInsensitive
* @return true if the repository exists
@@ -2104,7 +2104,7 @@ public class GitBlit implements ServletContextListener {
// if we are caching use the cache to determine availability
// otherwise we end up adding a phantom repository to the cache
return repositoryListCache.containsKey(repositoryName.toLowerCase());
- }
+ }
Repository r = getRepository(repositoryName, false);
if (r == null) {
return false;
@@ -2112,11 +2112,11 @@ public class GitBlit implements ServletContextListener {
r.close();
return true;
}
-
+
/**
* Determines if the specified user has a fork of the specified origin
* repository.
- *
+ *
* @param username
* @param origin
* @return true the if the user has a fork
@@ -2124,11 +2124,11 @@ public class GitBlit implements ServletContextListener {
public boolean hasFork(String username, String origin) {
return getFork(username, origin) != null;
}
-
+
/**
* Gets the name of a user's fork of the specified origin
* repository.
- *
+ *
* @param username
* @param origin
* @return the name of the user's fork, null otherwise
@@ -2150,7 +2150,7 @@ public class GitBlit implements ServletContextListener {
}
}
}
-
+
if (originModel.originRepository != null) {
roots.add(originModel.originRepository);
originModel = repositoryListCache.get(originModel.originRepository);
@@ -2159,7 +2159,7 @@ public class GitBlit implements ServletContextListener {
originModel = null;
}
}
-
+
for (String repository : repositoryListCache.keySet()) {
if (repository.startsWith(userPath)) {
RepositoryModel model = repositoryListCache.get(repository);
@@ -2190,11 +2190,11 @@ public class GitBlit implements ServletContextListener {
// user does not have a fork
return null;
}
-
+
/**
* Returns the fork network for a repository by traversing up the fork graph
* to discover the root and then down through all children of the root node.
- *
+ *
* @param repository
* @return a ForkModel
*/
@@ -2217,7 +2217,7 @@ public class GitBlit implements ServletContextListener {
return root;
}
}
-
+
private ForkModel getForkModelFromCache(String repository) {
RepositoryModel model = repositoryListCache.get(repository.toLowerCase());
if (model == null) {
@@ -2234,7 +2234,7 @@ public class GitBlit implements ServletContextListener {
}
return fork;
}
-
+
private ForkModel getForkModel(String repository) {
RepositoryModel model = getRepositoryModel(repository.toLowerCase());
if (model == null) {
@@ -2257,7 +2257,7 @@ public class GitBlit implements ServletContextListener {
* repository. Gitblit caches the repository sizes to reduce the performance
* penalty of recursive calculation. The cache is updated if the repository
* has been changed since the last calculation.
- *
+ *
* @param model
* @return size in bytes of the repository
*/
@@ -2284,7 +2284,7 @@ public class GitBlit implements ServletContextListener {
/**
* Ensure that a cached repository is completely closed and its resources
* are properly released.
- *
+ *
* @param repositoryName
*/
private void closeRepository(String repositoryName) {
@@ -2319,7 +2319,7 @@ public class GitBlit implements ServletContextListener {
repository.close();
}
}
-
+
// close any open index writer/searcher in the Lucene executor
luceneExecutor.close(repositoryName);
}
@@ -2329,7 +2329,7 @@ public class GitBlit implements ServletContextListener {
* This method builds a metrics cache. The cache is updated if the
* repository is updated. A new copy of the metrics list is returned on each
* call so that modifications to the list are non-destructive.
- *
+ *
* @param model
* @param repository
* @return a new array list of metrics
@@ -2346,7 +2346,7 @@ public class GitBlit implements ServletContextListener {
/**
* Returns the gitblit string value for the specified key. If key is not
* set, returns defaultValue.
- *
+ *
* @param config
* @param field
* @param defaultValue
@@ -2363,7 +2363,7 @@ public class GitBlit implements ServletContextListener {
/**
* Returns the gitblit boolean value for the specified key. If key is not
* set, returns defaultValue.
- *
+ *
* @param config
* @param field
* @param defaultValue
@@ -2372,11 +2372,11 @@ public class GitBlit implements ServletContextListener {
private boolean getConfig(StoredConfig config, String field, boolean defaultValue) {
return config.getBoolean(Constants.CONFIG_GITBLIT, field, defaultValue);
}
-
+
/**
* Returns the gitblit string value for the specified key. If key is not
* set, returns defaultValue.
- *
+ *
* @param config
* @param field
* @param defaultValue
@@ -2398,11 +2398,11 @@ public class GitBlit implements ServletContextListener {
* Creates/updates the repository model keyed by reopsitoryName. Saves all
* repository settings in .git/config. This method allows for renaming
* repositories and will update user access permissions accordingly.
- *
+ *
* All repositories created by this method are bare and automatically have
* .git appended to their names, which is the standard convention for bare
* repositories.
- *
+ *
* @param repositoryName
* @param repository
* @param isCreate
@@ -2473,7 +2473,7 @@ public class GitBlit implements ServletContextListener {
"Failed to rename repository permissions ''{0}'' to ''{1}''.",
repositoryName, repository.name));
}
-
+
// rename fork origins in their configs
if (!ArrayUtils.isEmpty(repository.forks)) {
for (String fork : repository.forks) {
@@ -2491,7 +2491,7 @@ public class GitBlit implements ServletContextListener {
rf.close();
}
}
-
+
// update this repository's origin's fork list
if (!StringUtils.isEmpty(repository.originRepository)) {
RepositoryModel origin = repositoryListCache.get(repository.originRepository);
@@ -2526,7 +2526,7 @@ public class GitBlit implements ServletContextListener {
// only update symbolic head if it changes
String currentRef = JGitUtils.getHEADRef(r);
if (!StringUtils.isEmpty(repository.HEAD) && !repository.HEAD.equals(currentRef)) {
- logger.info(MessageFormat.format("Relinking {0} HEAD from {1} to {2}",
+ logger.info(MessageFormat.format("Relinking {0} HEAD from {1} to {2}",
repository.name, currentRef, repository.HEAD));
if (JGitUtils.setHEADtoRef(r, repository.HEAD)) {
// clear the cache
@@ -2549,10 +2549,10 @@ public class GitBlit implements ServletContextListener {
// model will actually be replaced on next load because config is stale
addToCachedRepositoryList(repository);
}
-
+
/**
* Updates the Gitblit configuration for the specified repository.
- *
+ *
* @param r
* the Git repository
* @param repository
@@ -2610,14 +2610,14 @@ public class GitBlit implements ServletContextListener {
config.setString(Constants.CONFIG_GITBLIT, null, "commitMessageRenderer",
repository.commitMessageRenderer.name());
}
-
+
updateList(config, "federationSets", repository.federationSets);
updateList(config, "preReceiveScript", repository.preReceiveScripts);
updateList(config, "postReceiveScript", repository.postReceiveScripts);
updateList(config, "mailingList", repository.mailingLists);
updateList(config, "indexBranch", repository.indexedBranches);
updateList(config, "metricAuthorExclusions", repository.metricAuthorExclusions);
-
+
// User Defined Properties
if (repository.customFields != null) {
if (repository.customFields.size() == 0) {
@@ -2639,7 +2639,7 @@ public class GitBlit implements ServletContextListener {
logger.error("Failed to save repository config!", e);
}
}
-
+
private void updateList(StoredConfig config, String field, List<String> list) {
// a null list is skipped, not cleared
// this is for RPC administration where an older manager might be used
@@ -2656,7 +2656,7 @@ public class GitBlit implements ServletContextListener {
/**
* Deletes the repository from the file system and removes the repository
* permission from all repository users.
- *
+ *
* @param model
* @return true if successful
*/
@@ -2667,7 +2667,7 @@ public class GitBlit implements ServletContextListener {
/**
* Deletes the repository from the file system and removes the repository
* permission from all repository users.
- *
+ *
* @param repositoryName
* @return true if successful
*/
@@ -2676,7 +2676,7 @@ public class GitBlit implements ServletContextListener {
closeRepository(repositoryName);
// clear the repository cache
clearRepositoryMetadataCache(repositoryName);
-
+
RepositoryModel model = removeFromCachedRepositoryList(repositoryName);
if (model != null && !ArrayUtils.isEmpty(model.forks)) {
resetRepositoryListCache();
@@ -2699,9 +2699,9 @@ public class GitBlit implements ServletContextListener {
/**
* Returns an html version of the commit message with any global or
* repository-specific regular expression substitution applied.
- *
+ *
* This method uses the preferred renderer to transform the commit message.
- *
+ *
* @param repository
* @param text
* @return html version of the commit message
@@ -2720,16 +2720,16 @@ public class GitBlit implements ServletContextListener {
// noop
break;
}
-
+
return processPlainCommitMessage(repository.name, text);
}
-
+
/**
* Returns an html version of the commit message with any global or
* repository-specific regular expression substitution applied.
- *
+ *
* This method assumes the commit message is plain text.
- *
+ *
* @param repositoryName
* @param text
* @return html version of the commit message
@@ -2738,13 +2738,13 @@ public class GitBlit implements ServletContextListener {
String html = StringUtils.escapeForHtml(text, false);
html = processCommitMessageRegex(repositoryName, html);
return StringUtils.breakLinesForHtml(html);
-
+
}
-
+
/**
* Apply globally or per-repository specified regex substitutions to the
* commit message.
- *
+ *
* @param repositoryName
* @param text
* @return the processed commit message
@@ -2785,7 +2785,7 @@ public class GitBlit implements ServletContextListener {
/**
* Returns Gitblit's scheduled executor service for scheduling tasks.
- *
+ *
* @return scheduledExecutor
*/
public ScheduledExecutorService executor() {
@@ -2833,7 +2833,7 @@ public class GitBlit implements ServletContextListener {
/**
* Returns the list of federated gitblit instances that this instance will
* try to pull.
- *
+ *
* @return list of registered gitblit instances
*/
public List<FederationModel> getFederationRegistrations() {
@@ -2845,7 +2845,7 @@ public class GitBlit implements ServletContextListener {
/**
* Retrieve the specified federation registration.
- *
+ *
* @param name
* the name of the registration
* @return a federation registration
@@ -2869,7 +2869,7 @@ public class GitBlit implements ServletContextListener {
/**
* Returns the list of federation sets.
- *
+ *
* @return list of federation sets
*/
public List<FederationSet> getFederationSets(String gitblitUrl) {
@@ -2892,7 +2892,7 @@ public class GitBlit implements ServletContextListener {
/**
* Returns the list of possible federation tokens for this Gitblit instance.
- *
+ *
* @return list of federation tokens
*/
public List<String> getFederationTokens() {
@@ -2910,7 +2910,7 @@ public class GitBlit implements ServletContextListener {
/**
* Returns the specified federation token for this Gitblit instance.
- *
+ *
* @param type
* @return a federation token
*/
@@ -2920,7 +2920,7 @@ public class GitBlit implements ServletContextListener {
/**
* Returns the specified federation token for this Gitblit instance.
- *
+ *
* @param value
* @return a federation token
*/
@@ -2932,7 +2932,7 @@ public class GitBlit implements ServletContextListener {
/**
* Compares the provided token with this Gitblit instance's tokens and
* determines if the requested permission may be granted to the token.
- *
+ *
* @param req
* @param token
* @return true if the request can be executed
@@ -2958,7 +2958,7 @@ public class GitBlit implements ServletContextListener {
/**
* Acknowledge and cache the status of a remote Gitblit instance.
- *
+ *
* @param identification
* the identification of the pulling Gitblit instance
* @param registration
@@ -2978,7 +2978,7 @@ public class GitBlit implements ServletContextListener {
/**
* Returns the list of registration results.
- *
+ *
* @return the list of registration results
*/
public List<FederationModel> getFederationResultRegistrations() {
@@ -2988,7 +2988,7 @@ public class GitBlit implements ServletContextListener {
/**
* Submit a federation proposal. The proposal is cached locally and the
* Gitblit administrator(s) are notified via email.
- *
+ *
* @param proposal
* the proposal
* @param gitblitUrl
@@ -3020,7 +3020,7 @@ public class GitBlit implements ServletContextListener {
/**
* Returns the list of pending federation proposals
- *
+ *
* @return list of federation proposals
*/
public List<FederationProposal> getPendingFederationProposals() {
@@ -3046,7 +3046,7 @@ public class GitBlit implements ServletContextListener {
/**
* Get repositories for the specified token.
- *
+ *
* @param gitblitUrl
* the base url of this gitblit instance
* @param token
@@ -3105,7 +3105,7 @@ public class GitBlit implements ServletContextListener {
/**
* Creates a proposal from the token.
- *
+ *
* @param gitblitUrl
* the url of this Gitblit instance
* @param token
@@ -3127,7 +3127,7 @@ public class GitBlit implements ServletContextListener {
/**
* Returns the proposal identified by the supplied token.
- *
+ *
* @param token
* @return the specified proposal or null
*/
@@ -3143,7 +3143,7 @@ public class GitBlit implements ServletContextListener {
/**
* Deletes a pending federation proposal.
- *
+ *
* @param a
* proposal
* @return true if the proposal was deleted
@@ -3157,7 +3157,7 @@ public class GitBlit implements ServletContextListener {
/**
* Returns the list of all Groovy push hook scripts. Script files must have
* .groovy extension
- *
+ *
* @return list of available hook scripts
*/
public List<String> getAllScripts() {
@@ -3181,7 +3181,7 @@ public class GitBlit implements ServletContextListener {
/**
* Returns the list of pre-receive scripts the repository inherited from the
* global settings and team affiliations.
- *
+ *
* @param repository
* if null only the globally specified scripts are returned
* @return a list of scripts
@@ -3213,7 +3213,7 @@ public class GitBlit implements ServletContextListener {
* Returns the list of all available Groovy pre-receive push hook scripts
* that are not already inherited by the repository. Script files must have
* .groovy extension
- *
+ *
* @param repository
* optional parameter
* @return list of available hook scripts
@@ -3234,7 +3234,7 @@ public class GitBlit implements ServletContextListener {
/**
* Returns the list of post-receive scripts the repository inherited from
* the global settings and team affiliations.
- *
+ *
* @param repository
* if null only the globally specified scripts are returned
* @return a list of scripts
@@ -3265,7 +3265,7 @@ public class GitBlit implements ServletContextListener {
* Returns the list of unused Groovy post-receive push hook scripts that are
* not already inherited by the repository. Script files must have .groovy
* extension
- *
+ *
* @param repository
* optional parameter
* @return list of available hook scripts
@@ -3282,24 +3282,24 @@ public class GitBlit implements ServletContextListener {
}
return scripts;
}
-
+
/**
* Search the specified repositories using the Lucene query.
- *
+ *
* @param query
* @param page
* @param pageSize
* @param repositories
* @return
*/
- public List<SearchResult> search(String query, int page, int pageSize, List<String> repositories) {
+ public List<SearchResult> search(String query, int page, int pageSize, List<String> repositories) {
List<SearchResult> srs = luceneExecutor.search(query, page, pageSize, repositories);
return srs;
}
/**
* Notify the administrators by email.
- *
+ *
* @param subject
* @param message
*/
@@ -3310,7 +3310,7 @@ public class GitBlit implements ServletContextListener {
/**
* Notify users by email of something.
- *
+ *
* @param subject
* @param message
* @param toAddresses
@@ -3321,7 +3321,7 @@ public class GitBlit implements ServletContextListener {
/**
* Notify users by email of something.
- *
+ *
* @param subject
* @param message
* @param toAddresses
@@ -3335,16 +3335,16 @@ public class GitBlit implements ServletContextListener {
Message mail = mailExecutor.createMessage(toAddresses);
if (mail != null) {
mail.setSubject(subject);
-
- MimeBodyPart messagePart = new MimeBodyPart();
+
+ MimeBodyPart messagePart = new MimeBodyPart();
messagePart.setText(message, "utf-8");
messagePart.setHeader("Content-Type", "text/plain; charset=\"utf-8\"");
messagePart.setHeader("Content-Transfer-Encoding", "quoted-printable");
-
+
MimeMultipart multiPart = new MimeMultipart();
multiPart.addBodyPart(messagePart);
mail.setContent(multiPart);
-
+
mailExecutor.queue(mail);
}
} catch (MessagingException e) {
@@ -3354,7 +3354,7 @@ public class GitBlit implements ServletContextListener {
/**
* Notify users by email of something.
- *
+ *
* @param subject
* @param message
* @param toAddresses
@@ -3365,7 +3365,7 @@ public class GitBlit implements ServletContextListener {
/**
* Notify users by email of something.
- *
+ *
* @param subject
* @param message
* @param toAddresses
@@ -3379,12 +3379,12 @@ public class GitBlit implements ServletContextListener {
Message mail = mailExecutor.createMessage(toAddresses);
if (mail != null) {
mail.setSubject(subject);
-
- MimeBodyPart messagePart = new MimeBodyPart();
+
+ MimeBodyPart messagePart = new MimeBodyPart();
messagePart.setText(message, "utf-8");
messagePart.setHeader("Content-Type", "text/html; charset=\"utf-8\"");
messagePart.setHeader("Content-Transfer-Encoding", "quoted-printable");
-
+
MimeMultipart multiPart = new MimeMultipart();
multiPart.addBodyPart(messagePart);
mail.setContent(multiPart);
@@ -3398,7 +3398,7 @@ public class GitBlit implements ServletContextListener {
/**
* Returns the descriptions/comments of the Gitblit config settings.
- *
+ *
* @return SettingsModel
*/
public ServerSettings getSettingsModel() {
@@ -3411,7 +3411,7 @@ public class GitBlit implements ServletContextListener {
setting.name = key;
settingsModel.add(setting);
}
- setting.currentValue = settings.getString(key, "");
+ setting.currentValue = settings.getString(key, "");
}
settingsModel.pushScripts = getAllScripts();
return settingsModel;
@@ -3421,7 +3421,7 @@ public class GitBlit implements ServletContextListener {
* Parse the properties file and aggregate all the comments by the setting
* key. A setting model tracks the current value, the default value, the
* description of the setting and and directives about the setting.
- *
+ *
* @return Map<String, SettingModel>
*/
private ServerSettings loadSettingModels() {
@@ -3490,7 +3490,7 @@ public class GitBlit implements ServletContextListener {
* Configure the Gitblit singleton with the specified settings source. This
* source may be file settings (Gitblit GO) or may be web.xml settings
* (Gitblit WAR).
- *
+ *
* @param settings
*/
public void configureContext(IStoredSettings settings, File folder, boolean startFederation) {
@@ -3507,7 +3507,7 @@ public class GitBlit implements ServletContextListener {
mailExecutor = new MailExecutor(settings);
luceneExecutor = new LuceneExecutor(settings, repositoriesFolder);
gcExecutor = new GCExecutor(settings);
-
+
// initialize utilities
String prefix = settings.getString(Keys.git.userRepositoryPrefix, "~");
ModelUtils.setUserRepoPrefix(prefix);
@@ -3520,7 +3520,7 @@ public class GitBlit implements ServletContextListener {
logger.info("Identifying available repositories...");
getRepositoryList();
}
-
+
logTimezone("JVM", TimeZone.getDefault());
logTimezone(Constants.NAME, getTimezone());
@@ -3538,12 +3538,12 @@ public class GitBlit implements ServletContextListener {
}
setUserService(loginService);
}
-
+
// load and cache the project metadata
projectConfigs = new FileBasedConfig(getFileOrFolder(Keys.web.projectsFile, "${baseFolder}/projects.conf"), FS.detect());
getProjectConfigs();
-
- configureMailExecutor();
+
+ configureMailExecutor();
configureLuceneIndexing();
configureGarbageCollector();
if (startFederation) {
@@ -3556,7 +3556,7 @@ public class GitBlit implements ServletContextListener {
ContainerUtils.CVE_2007_0450.test();
}
-
+
protected void configureMailExecutor() {
if (mailExecutor.isReady()) {
logger.info("Mail executor is scheduled to process the message queue every 2 minutes.");
@@ -3565,12 +3565,12 @@ public class GitBlit implements ServletContextListener {
logger.warn("Mail server is not properly configured. Mail services disabled.");
}
}
-
+
protected void configureLuceneIndexing() {
scheduledExecutor.scheduleAtFixedRate(luceneExecutor, 1, 2, TimeUnit.MINUTES);
logger.info("Lucene executor is scheduled to process indexed branches every 2 minutes.");
}
-
+
protected void configureGarbageCollector() {
// schedule gc engine
if (gcExecutor.isReady()) {
@@ -3590,13 +3590,13 @@ public class GitBlit implements ServletContextListener {
delay = (int) ((cd.getTime() - now.getTime())/TimeUtils.MIN);
String when = delay + " mins";
if (delay > 60) {
- when = MessageFormat.format("{0,number,0.0} hours", ((float)delay)/60f);
+ when = MessageFormat.format("{0,number,0.0} hours", (delay)/60f);
}
logger.info(MessageFormat.format("Next scheculed GC scan is in {0}", when));
scheduledExecutor.scheduleAtFixedRate(gcExecutor, delay, 60*24, TimeUnit.MINUTES);
}
}
-
+
protected void configureJGit() {
// Configure JGit
WindowCacheConfig cfg = new WindowCacheConfig();
@@ -3620,7 +3620,7 @@ public class GitBlit implements ServletContextListener {
logger.error("Failed to configure JGit parameters!", e);
}
}
-
+
protected void configureFanout() {
// startup Fanout PubSub service
if (settings.getInteger(Keys.fanout.port, 0) > 0) {
@@ -3648,7 +3648,7 @@ public class GitBlit implements ServletContextListener {
fanoutService.start();
}
}
-
+
protected void configureGitDaemon() {
int port = settings.getInteger(Keys.git.daemonPort, 0);
String bindInterface = settings.getString(Keys.git.daemonBindInterface, "localhost");
@@ -3662,7 +3662,7 @@ public class GitBlit implements ServletContextListener {
}
}
}
-
+
protected void configureCommitCache() {
int daysToCache = settings.getInteger(Keys.web.activityCacheDays, 14);
if (daysToCache <= 0) {
@@ -3698,11 +3698,11 @@ public class GitBlit implements ServletContextListener {
daysToCache, commitCount, repoCount, TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start)));
}
}
-
+
protected final Logger getLogger() {
return logger;
}
-
+
protected final ScheduledExecutorService getScheduledExecutor() {
return scheduledExecutor;
}
@@ -3710,7 +3710,7 @@ public class GitBlit implements ServletContextListener {
protected final LuceneExecutor getLuceneExecutor() {
return luceneExecutor;
}
-
+
private void logTimezone(String type, TimeZone zone) {
SimpleDateFormat df = new SimpleDateFormat("z Z");
df.setTimeZone(zone);
@@ -3721,7 +3721,7 @@ public class GitBlit implements ServletContextListener {
/**
* Configure Gitblit from the web.xml, if no configuration has already been
* specified.
- *
+ *
* @see ServletContextListener.contextInitialize(ServletContextEvent)
*/
@Override
@@ -3734,7 +3734,7 @@ public class GitBlit implements ServletContextListener {
String contextRealPath = context.getRealPath("/");
File contextFolder = (contextRealPath != null) ? new File(contextRealPath) : null;
String openShift = System.getenv("OPENSHIFT_DATA_DIR");
-
+
if (!StringUtils.isEmpty(openShift)) {
// Gitblit is running in OpenShift/JBoss
File base = new File(openShift);
@@ -3743,7 +3743,7 @@ public class GitBlit implements ServletContextListener {
// gitblit.properties setting overrides
File overrideFile = new File(base, "gitblit.properties");
webxmlSettings.applyOverrides(overrideFile);
-
+
// Copy the included scripts to the configured groovy folder
String path = webxmlSettings.getString(Keys.groovy.scriptsFolder, "groovy");
File localScripts = com.gitblit.utils.FileUtils.resolveParameter(Constants.baseFolder$, base, path);
@@ -3759,15 +3759,15 @@ public class GitBlit implements ServletContextListener {
}
}
}
-
+
// configure context using the web.xml
configureContext(webxmlSettings, base, true);
} else {
// Gitblit is running in a standard servlet container
logger.info("WAR contextFolder is " + ((contextFolder != null) ? contextFolder.getAbsolutePath() : "<empty>"));
-
+
String path = webxmlSettings.getString(Constants.baseFolder, Constants.contextFolder$ + "/WEB-INF/data");
-
+
if (path.contains(Constants.contextFolder$) && contextFolder == null) {
// warn about null contextFolder (issue-199)
logger.error("");
@@ -3777,7 +3777,7 @@ public class GitBlit implements ServletContextListener {
logger.error(MessageFormat.format("OR configure your servlet container to specify a \"{0}\" parameter in the context configuration!!", Constants.baseFolder));
logger.error("");
}
-
+
File base = com.gitblit.utils.FileUtils.resolveParameter(Constants.contextFolder$, contextFolder, path);
base.mkdirs();
@@ -3788,15 +3788,15 @@ public class GitBlit implements ServletContextListener {
}
// delegate all config to baseFolder/gitblit.properties file
- FileSettings settings = new FileSettings(localSettings.getAbsolutePath());
+ FileSettings settings = new FileSettings(localSettings.getAbsolutePath());
configureContext(settings, base, true);
}
}
-
+
settingsModel = loadSettingModels();
serverStatus.servletContainer = servletContext.getServerInfo();
}
-
+
protected void extractResources(ServletContext context, String path, File toDir) {
for (String resource : context.getResourcePaths(path)) {
// extract the resource to the directory if it does not exist
@@ -3861,18 +3861,18 @@ public class GitBlit implements ServletContextListener {
gitDaemon.stop();
}
}
-
+
/**
- *
+ *
* @return true if we are running the gc executor
*/
public boolean isCollectingGarbage() {
return gcExecutor.isRunning();
}
-
+
/**
* Returns true if Gitblit is actively collecting garbage in this repository.
- *
+ *
* @param repositoryName
* @return true if actively collecting garbage
*/
@@ -3883,8 +3883,8 @@ public class GitBlit implements ServletContextListener {
/**
* Creates a personal fork of the specified repository. The clone is view
* restricted by default and the owner of the source repository is given
- * access to the clone.
- *
+ * access to the clone.
+ *
* @param repository
* @param user
* @return the repository model of the fork, if successful
@@ -3944,7 +3944,7 @@ public class GitBlit implements ServletContextListener {
}
cloneTeams.add(cloneTeam);
}
- userService.updateTeamModels(cloneTeams);
+ userService.updateTeamModels(cloneTeams);
// add this clone to the cached model
addToCachedRepositoryList(cloneModel);
@@ -3954,7 +3954,7 @@ public class GitBlit implements ServletContextListener {
/**
* Allow to understand if GitBlit supports and is configured to allow
* cookie-based authentication.
- *
+ *
* @return status of Cookie authentication enablement.
*/
public boolean allowCookieAuthentication() {
diff --git a/src/main/java/com/gitblit/GitBlitException.java b/src/main/java/com/gitblit/GitBlitException.java
index 7ab0f99d..6cf06bcd 100644
--- a/src/main/java/com/gitblit/GitBlitException.java
+++ b/src/main/java/com/gitblit/GitBlitException.java
@@ -19,9 +19,9 @@ import java.io.IOException;
/**
* GitBlitException is a marginally useful class. :)
- *
+ *
* @author James Moger
- *
+ *
*/
public class GitBlitException extends IOException {
diff --git a/src/main/java/com/gitblit/GitBlitServer.java b/src/main/java/com/gitblit/GitBlitServer.java
index ce059959..ace1f2f0 100644
--- a/src/main/java/com/gitblit/GitBlitServer.java
+++ b/src/main/java/com/gitblit/GitBlitServer.java
@@ -75,9 +75,9 @@ import com.unboundid.ldif.LDIFReader;
* simplify command line parameter processing. This class also automatically
* generates a self-signed certificate for localhost, if the keystore does not
* already exist.
- *
+ *
* @author James Moger
- *
+ *
*/
public class GitBlitServer {
@@ -85,7 +85,7 @@ public class GitBlitServer {
public static void main(String... args) {
GitBlitServer server = new GitBlitServer();
-
+
// filter out the baseFolder parameter
List<String> filtered = new ArrayList<String>();
String folder = "data";
@@ -103,7 +103,7 @@ public class GitBlitServer {
filtered.add(arg);
}
}
-
+
Params.baseFolder = folder;
Params params = new Params();
JCommander jc = new JCommander(params);
@@ -125,7 +125,7 @@ public class GitBlitServer {
/**
* Display the command line usage of Gitblit GO.
- *
+ *
* @param jc
* @param t
*/
@@ -172,7 +172,7 @@ public class GitBlitServer {
FileSettings settings = params.FILESETTINGS;
if (!StringUtils.isEmpty(params.settingsfile)) {
if (new File(params.settingsfile).exists()) {
- settings = new FileSettings(params.settingsfile);
+ settings = new FileSettings(params.settingsfile);
}
}
logger = LoggerFactory.getLogger(GitBlitServer.class);
@@ -198,7 +198,7 @@ public class GitBlitServer {
String osname = System.getProperty("os.name");
String osversion = System.getProperty("os.version");
logger.info("Running on " + osname + " (" + osversion + ")");
-
+
List<Connector> connectors = new ArrayList<Connector>();
// conditionally configure the http connector
@@ -236,7 +236,7 @@ public class GitBlitServer {
NewCertificateConfig certificateConfig = NewCertificateConfig.KEY.parse(config);
certificateConfig.update(metadata);
}
-
+
metadata.notAfter = new Date(System.currentTimeMillis() + 10*TimeUtils.ONEYEAR);
X509Utils.prepareX509Infrastructure(metadata, baseFolder, new X509Log() {
@Override
@@ -260,7 +260,7 @@ public class GitBlitServer {
}
});
- if (serverKeyStore.exists()) {
+ if (serverKeyStore.exists()) {
Connector secureConnector = createSSLConnector(params.alias, serverKeyStore, serverTrustStore, params.storePassword,
caRevocationList, params.useNIO, params.securePort, settings.getInteger(Keys.server.threadPoolSize, 50), params.requireClientCertificates);
String bindInterface = settings.getString(Keys.server.httpsBindInterface, null);
@@ -297,7 +297,7 @@ public class GitBlitServer {
// tempDir is where the embedded Gitblit web application is expanded and
// where Jetty creates any necessary temporary files
- File tempDir = com.gitblit.utils.FileUtils.resolveParameter(Constants.baseFolder$, baseFolder, params.temp);
+ File tempDir = com.gitblit.utils.FileUtils.resolveParameter(Constants.baseFolder$, baseFolder, params.temp);
if (tempDir.exists()) {
try {
FileUtils.delete(tempDir, FileUtils.RECURSIVE | FileUtils.RETRY);
@@ -343,7 +343,7 @@ public class GitBlitServer {
settings.overrideSetting(Keys.realm.userService, params.userService);
settings.overrideSetting(Keys.git.repositoriesFolder, params.repositoriesFolder);
settings.overrideSetting(Keys.git.daemonPort, params.gitPort);
-
+
// Start up an in-memory LDAP server, if configured
try {
if (StringUtils.isEmpty(params.ldapLdifFile) == false) {
@@ -354,21 +354,21 @@ public class GitBlitServer {
String rootDN = firstLine.substring(4);
String bindUserName = settings.getString(Keys.realm.ldap.username, "");
String bindPassword = settings.getString(Keys.realm.ldap.password, "");
-
+
// Get the port
int port = ldapUrl.getPort();
if (port == -1)
port = 389;
-
+
InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig(rootDN);
config.addAdditionalBindCredentials(bindUserName, bindPassword);
config.setListenerConfigs(InMemoryListenerConfig.createLDAPConfig("default", port));
config.setSchema(null);
-
+
InMemoryDirectoryServer ds = new InMemoryDirectoryServer(config);
ds.importFromLDIF(true, new LDIFReader(ldifFile));
ds.startListening();
-
+
logger.info("LDAP Server started at ldap://localhost:" + port);
}
}
@@ -400,14 +400,14 @@ public class GitBlitServer {
System.exit(100);
}
}
-
+
protected GitBlit getGitBlitInstance() {
return GitBlit.self();
}
/**
* Creates an http connector.
- *
+ *
* @param useNIO
* @param port
* @param threadPoolSize
@@ -439,10 +439,10 @@ public class GitBlitServer {
/**
* Creates an https connector.
- *
+ *
* SSL renegotiation will be enabled if the JVM is 1.6.0_22 or later.
* oracle.com/technetwork/java/javase/documentation/tlsreadme2-176330.html
- *
+ *
* @param certAlias
* @param keyStore
* @param clientTrustStore
@@ -455,7 +455,7 @@ public class GitBlitServer {
* @return an https connector
*/
private Connector createSSLConnector(String certAlias, File keyStore, File clientTrustStore,
- String storePassword, File caRevocationList, boolean useNIO, int port, int threadPoolSize,
+ String storePassword, File caRevocationList, boolean useNIO, int port, int threadPoolSize,
boolean requireClientCertificates) {
GitblitSslContextFactory factory = new GitblitSslContextFactory(certAlias,
keyStore, clientTrustStore, storePassword, caRevocationList);
@@ -486,10 +486,10 @@ public class GitBlitServer {
return connector;
}
-
+
/**
* Creates an ajp connector.
- *
+ *
* @param port
* @return an ajp connector
*/
@@ -505,7 +505,7 @@ public class GitBlitServer {
/**
* Tests to see if the operating system is Windows.
- *
+ *
* @return true if this is a windows machine
*/
private boolean isWindows() {
@@ -516,9 +516,9 @@ public class GitBlitServer {
* The ShutdownMonitorThread opens a socket on a specified port and waits
* for an incoming connection. When that connection is accepted a shutdown
* message is issued to the running Jetty server.
- *
+ *
* @author James Moger
- *
+ *
*/
private static class ShutdownMonitorThread extends Thread {
@@ -634,7 +634,7 @@ public class GitBlitServer {
*/
@Parameter(names = { "--settings" }, description = "Path to alternative settings")
public String settingsfile;
-
+
@Parameter(names = { "--ldapLdifFile" }, description = "Path to LDIF file. This will cause an in-memory LDAP server to be started according to gitblit settings")
public String ldapLdifFile;
diff --git a/src/main/java/com/gitblit/GitFilter.java b/src/main/java/com/gitblit/GitFilter.java
index baa7ff0f..5e18f5fd 100644
--- a/src/main/java/com/gitblit/GitFilter.java
+++ b/src/main/java/com/gitblit/GitFilter.java
@@ -27,9 +27,9 @@ import com.gitblit.utils.StringUtils;
* The GitFilter is an AccessRestrictionFilter which ensures that Git client
* requests for push, clone, or view restricted repositories are authenticated
* and authorized.
- *
+ *
* @author James Moger
- *
+ *
*/
public class GitFilter extends AccessRestrictionFilter {
@@ -42,7 +42,7 @@ public class GitFilter extends AccessRestrictionFilter {
/**
* Extract the repository name from the url.
- *
+ *
* @param cloneUrl
* @return repository name
*/
@@ -59,7 +59,7 @@ public class GitFilter extends AccessRestrictionFilter {
/**
* Extract the repository name from the url.
- *
+ *
* @param url
* @return repository name
*/
@@ -71,7 +71,7 @@ public class GitFilter extends AccessRestrictionFilter {
/**
* Analyze the url and returns the action of the request. Return values are
* either "/git-receive-pack" or "/git-upload-pack".
- *
+ *
* @param serverUrl
* @return action of the request
*/
@@ -92,20 +92,20 @@ public class GitFilter extends AccessRestrictionFilter {
}
return null;
}
-
+
/**
* Determine if a non-existing repository can be created using this filter.
- *
+ *
* @return true if the server allows repository creation on-push
*/
@Override
protected boolean isCreationAllowed() {
return GitBlit.getBoolean(Keys.git.allowCreateOnPush, true);
}
-
+
/**
* Determine if the repository can receive pushes.
- *
+ *
* @param repository
* @param action
* @return true if the action may be performed
@@ -124,7 +124,7 @@ public class GitFilter extends AccessRestrictionFilter {
/**
* Determine if the repository requires authentication.
- *
+ *
* @param repository
* @param action
* @return true if authentication required
@@ -133,7 +133,7 @@ public class GitFilter extends AccessRestrictionFilter {
protected boolean requiresAuthentication(RepositoryModel repository, String action) {
if (gitUploadPack.equals(action)) {
// send to client
- return repository.accessRestriction.atLeast(AccessRestrictionType.CLONE);
+ return repository.accessRestriction.atLeast(AccessRestrictionType.CLONE);
} else if (gitReceivePack.equals(action)) {
// receive from client
return repository.accessRestriction.atLeast(AccessRestrictionType.PUSH);
@@ -144,7 +144,7 @@ public class GitFilter extends AccessRestrictionFilter {
/**
* Determine if the user can access the repository and perform the specified
* action.
- *
+ *
* @param repository
* @param user
* @param action
@@ -155,7 +155,7 @@ public class GitFilter extends AccessRestrictionFilter {
if (!GitBlit.getBoolean(Keys.git.enableGitServlet, true)) {
// Git Servlet disabled
return false;
- }
+ }
if (action.equals(gitReceivePack)) {
// Push request
if (user.canPush(repository)) {
@@ -179,11 +179,11 @@ public class GitFilter extends AccessRestrictionFilter {
}
return true;
}
-
+
/**
* An authenticated user with the CREATE role can create a repository on
* push.
- *
+ *
* @param user
* @param repository
* @param action
@@ -203,7 +203,7 @@ public class GitFilter extends AccessRestrictionFilter {
if (repository.contains("/../")) {
logger.error(MessageFormat.format("Illegal relative path in repository name! {0}", repository));
return null;
- }
+ }
// confirm valid characters in repository name
Character c = StringUtils.findInvalidCharacter(repository);
@@ -239,7 +239,7 @@ public class GitFilter extends AccessRestrictionFilter {
logger.warn(MessageFormat.format("{0} is not permitted to create repository {1} ON-PUSH!", user.username, repository));
}
}
-
+
// repository could not be created or action was not a push
return null;
}
diff --git a/src/main/java/com/gitblit/GitblitSslContextFactory.java b/src/main/java/com/gitblit/GitblitSslContextFactory.java
index f025c452..2a4735e6 100644
--- a/src/main/java/com/gitblit/GitblitSslContextFactory.java
+++ b/src/main/java/com/gitblit/GitblitSslContextFactory.java
@@ -32,7 +32,7 @@ import com.gitblit.utils.StringUtils;
/**
* Special SSL context factory that configures Gitblit GO and replaces the
* primary trustmanager with a GitblitTrustManager.
- *
+ *
* @author James Moger
*/
public class GitblitSslContextFactory extends SslContextFactory {
@@ -40,11 +40,11 @@ public class GitblitSslContextFactory extends SslContextFactory {
private static final Logger logger = LoggerFactory.getLogger(GitblitSslContextFactory.class);
private final File caRevocationList;
-
+
public GitblitSslContextFactory(String certAlias, File keyStore, File clientTrustStore,
String storePassword, File caRevocationList) {
super(keyStore.getAbsolutePath());
-
+
this.caRevocationList = caRevocationList;
// disable renegotiation unless this is a patched JVM
@@ -65,8 +65,8 @@ public class GitblitSslContextFactory extends SslContextFactory {
logger.info(" allowing SSL renegotiation on Java " + v);
setAllowRenegotiate(allowRenegotiation);
}
-
-
+
+
if (!StringUtils.isEmpty(certAlias)) {
logger.info(" certificate alias = " + certAlias);
setCertAlias(certAlias);
@@ -74,7 +74,7 @@ public class GitblitSslContextFactory extends SslContextFactory {
setKeyStorePassword(storePassword);
setTrustStore(clientTrustStore.getAbsolutePath());
setTrustStorePassword(storePassword);
-
+
logger.info(" keyStorePath = " + keyStore.getAbsolutePath());
logger.info(" trustStorePath = " + clientTrustStore.getAbsolutePath());
logger.info(" crlPath = " + caRevocationList.getAbsolutePath());
diff --git a/src/main/java/com/gitblit/GitblitTrustManager.java b/src/main/java/com/gitblit/GitblitTrustManager.java
index 4127caf4..728a9b10 100644
--- a/src/main/java/com/gitblit/GitblitTrustManager.java
+++ b/src/main/java/com/gitblit/GitblitTrustManager.java
@@ -32,20 +32,20 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * GitblitTrustManager is a wrapper trust manager that hot-reloads a local file
+ * GitblitTrustManager is a wrapper trust manager that hot-reloads a local file
* CRL and enforces client certificate revocations. The GitblitTrustManager
* also implements fuzzy revocation enforcement in case of issuer mismatch BUT
* serial number match. These rejecions are specially noted in the log.
- *
+ *
* @author James Moger
*/
public class GitblitTrustManager implements X509TrustManager {
-
+
private static final Logger logger = LoggerFactory.getLogger(GitblitTrustManager.class);
-
+
private final X509TrustManager delegate;
private final File caRevocationList;
-
+
private final AtomicLong lastModified = new AtomicLong(0);
private volatile X509CRL crl;
@@ -77,7 +77,7 @@ public class GitblitTrustManager implements X509TrustManager {
public X509Certificate[] getAcceptedIssuers() {
return delegate.getAcceptedIssuers();
}
-
+
protected boolean isRevoked(X509Certificate cert) {
if (!caRevocationList.exists()) {
return false;
@@ -88,7 +88,7 @@ public class GitblitTrustManager implements X509TrustManager {
// exact cert is revoked
return true;
}
-
+
X509CRLEntry entry = crl.getRevokedCertificate(cert.getSerialNumber());
if (entry != null) {
logger.warn("Certificate issuer does not match CRL issuer, but serial number has been revoked!");
@@ -96,10 +96,10 @@ public class GitblitTrustManager implements X509TrustManager {
logger.warn(" crl issuer = " + crl.getIssuerX500Principal());
return true;
}
-
+
return false;
}
-
+
protected synchronized void read() {
if (lastModified.get() == caRevocationList.lastModified()) {
return;
diff --git a/src/main/java/com/gitblit/HtpasswdUserService.java b/src/main/java/com/gitblit/HtpasswdUserService.java
index 62198f4a..881f843a 100644
--- a/src/main/java/com/gitblit/HtpasswdUserService.java
+++ b/src/main/java/com/gitblit/HtpasswdUserService.java
@@ -40,7 +40,7 @@ import com.gitblit.utils.StringUtils;
/**
* Implementation of a user service using an Apache htpasswd file for authentication.
- *
+ *
* This user service implement custom authentication using entries in a file created
* by the 'htpasswd' program of an Apache web server. All possible output
* options of the 'htpasswd' program version 2.2 are supported:
@@ -48,7 +48,7 @@ import com.gitblit.utils.StringUtils;
* glibc crypt() (not on Windows and NetWare),
* Apache MD5 (apr1),
* unsalted SHA-1.
- *
+ *
* Configuration options:
* realm.htpasswd.backingUserService - Specify the backing user service that is used
* to keep the user data other than the password.
@@ -59,7 +59,7 @@ import com.gitblit.utils.StringUtils;
* realm.htpasswd.overrideLocalAuthentication - Specify if local accounts are overwritten
* when authentication matches for an
* external account.
- *
+ *
* @author Florian Zschocke
*
*/
@@ -110,12 +110,12 @@ public class HtpasswdUserService extends GitblitUserService
/**
* Setup the user service.
- *
+ *
* The HtpasswdUserService extends the GitblitUserService and is thus
* backed by the available user services provided by the GitblitUserService.
* In addition the setup tries to read and parse the htpasswd file to be used
* for authentication.
- *
+ *
* @param settings
* @since 0.7.0
*/
@@ -238,9 +238,9 @@ public class HtpasswdUserService extends GitblitUserService
/**
* Determine if the account is to be treated as a local account.
- *
+ *
* This influences authentication. A local account will be authenticated
- * by the backing user service while an external account will be handled
+ * by the backing user service while an external account will be handled
* by this user service.
* <br/>
* The decision also depends on the setting of the key
@@ -254,7 +254,8 @@ public class HtpasswdUserService extends GitblitUserService
* If the key is set to false, then it is determined if the account is local
* according to the logic of the GitblitUserService.
*/
- protected boolean isLocalAccount(String username)
+ @Override
+ protected boolean isLocalAccount(String username)
{
if ( settings.getBoolean(KEY_OVERRIDE_LOCALAUTH, DEFAULT_OVERRIDE_LOCALAUTH) ) {
read();
@@ -270,7 +271,8 @@ public class HtpasswdUserService extends GitblitUserService
*
* @return AccountType.HTPASSWD
*/
- protected AccountType getAccountType()
+ @Override
+ protected AccountType getAccountType()
{
return AccountType.HTPASSWD;
}
diff --git a/src/main/java/com/gitblit/IStoredSettings.java b/src/main/java/com/gitblit/IStoredSettings.java
index acb9fc60..33c36ac5 100644
--- a/src/main/java/com/gitblit/IStoredSettings.java
+++ b/src/main/java/com/gitblit/IStoredSettings.java
@@ -28,9 +28,9 @@ import com.gitblit.utils.StringUtils;
/**
* Base class for stored settings implementations.
- *
+ *
* @author James Moger
- *
+ *
*/
public abstract class IStoredSettings {
@@ -53,7 +53,7 @@ public abstract class IStoredSettings {
/**
* Returns the list of keys whose name starts with the specified prefix. If
* the prefix is null or empty, all key names are returned.
- *
+ *
* @param startingWith
* @return list of keys
*/
@@ -78,7 +78,7 @@ public abstract class IStoredSettings {
* Returns the boolean value for the specified key. If the key does not
* exist or the value for the key can not be interpreted as a boolean, the
* defaultValue is returned.
- *
+ *
* @param key
* @param defaultValue
* @return key value or defaultValue
@@ -98,7 +98,7 @@ public abstract class IStoredSettings {
* Returns the integer value for the specified key. If the key does not
* exist or the value for the key can not be interpreted as an integer, the
* defaultValue is returned.
- *
+ *
* @param key
* @param defaultValue
* @return key value or defaultValue
@@ -123,7 +123,7 @@ public abstract class IStoredSettings {
* Returns the long value for the specified key. If the key does not
* exist or the value for the key can not be interpreted as an long, the
* defaultValue is returned.
- *
+ *
* @param key
* @param defaultValue
* @return key value or defaultValue
@@ -143,7 +143,7 @@ public abstract class IStoredSettings {
}
return defaultValue;
}
-
+
/**
* Returns an int filesize from a string value such as 50m or 50mb
* @param name
@@ -158,7 +158,7 @@ public abstract class IStoredSettings {
}
return com.gitblit.utils.FileUtils.convertSizeToInt(val, defaultValue);
}
-
+
/**
* Returns an long filesize from a string value such as 50m or 50mb
* @param n
@@ -178,7 +178,7 @@ public abstract class IStoredSettings {
* Returns the char value for the specified key. If the key does not exist
* or the value for the key can not be interpreted as a char, the
* defaultValue is returned.
- *
+ *
* @param key
* @param defaultValue
* @return key value or defaultValue
@@ -198,7 +198,7 @@ public abstract class IStoredSettings {
* Returns the string value for the specified key. If the key does not exist
* or the value for the key can not be interpreted as a string, the
* defaultValue is returned.
- *
+ *
* @param key
* @param defaultValue
* @return key value or defaultValue
@@ -213,11 +213,11 @@ public abstract class IStoredSettings {
}
return defaultValue;
}
-
+
/**
* Returns the string value for the specified key. If the key does not
* exist an exception is thrown.
- *
+ *
* @param key
* @return key value
*/
@@ -228,13 +228,13 @@ public abstract class IStoredSettings {
if (value != null) {
return value.trim();
}
- }
+ }
throw new RuntimeException("Property (" + name + ") does not exist");
}
/**
* Returns a list of space-separated strings from the specified key.
- *
+ *
* @param name
* @return list of strings
*/
@@ -245,7 +245,7 @@ public abstract class IStoredSettings {
/**
* Returns a list of strings from the specified key using the specified
* string separator.
- *
+ *
* @param name
* @param separator
* @return list of strings
@@ -259,10 +259,10 @@ public abstract class IStoredSettings {
}
return strings;
}
-
+
/**
* Returns a list of space-separated integers from the specified key.
- *
+ *
* @param name
* @return list of strings
*/
@@ -273,7 +273,7 @@ public abstract class IStoredSettings {
/**
* Returns a list of integers from the specified key using the specified
* string separator.
- *
+ *
* @param name
* @param separator
* @return list of integers
@@ -294,10 +294,10 @@ public abstract class IStoredSettings {
}
return ints;
}
-
+
/**
* Returns a map of strings from the specified key.
- *
+ *
* @param name
* @return map of string, string
*/
@@ -306,7 +306,7 @@ public abstract class IStoredSettings {
for (String string : getStrings(name)) {
String[] kvp = string.split("=", 2);
String key = kvp[0];
- String value = kvp[1];
+ String value = kvp[1];
map.put(key, value);
}
return map;
@@ -314,7 +314,7 @@ public abstract class IStoredSettings {
/**
* Override the specified key with the specified value.
- *
+ *
* @param key
* @param value
*/
@@ -324,7 +324,7 @@ public abstract class IStoredSettings {
/**
* Override the specified key with the specified value.
- *
+ *
* @param key
* @param value
*/
@@ -335,7 +335,7 @@ public abstract class IStoredSettings {
/**
* Updates the values for the specified keys and persists the entire
* configuration file.
- *
+ *
* @param map
* of key, value pairs
* @return true if successful
diff --git a/src/main/java/com/gitblit/IUserService.java b/src/main/java/com/gitblit/IUserService.java
index a57b0da6..628c1650 100644
--- a/src/main/java/com/gitblit/IUserService.java
+++ b/src/main/java/com/gitblit/IUserService.java
@@ -24,9 +24,9 @@ import com.gitblit.models.UserModel;
/**
* Implementations of IUserService control all aspects of UserModel objects and
* user authentication.
- *
+ *
* @author James Moger
- *
+ *
*/
public interface IUserService {
@@ -34,7 +34,7 @@ public interface IUserService {
* Setup the user service. This method allows custom implementations to
* retrieve settings from gitblit.properties or the web.xml file without
* relying on the GitBlit static singleton.
- *
+ *
* @param settings
* @since 0.7.0
*/
@@ -42,46 +42,46 @@ public interface IUserService {
/**
* Does the user service support changes to credentials?
- *
+ *
* @return true or false
* @since 1.0.0
- */
+ */
boolean supportsCredentialChanges();
/**
* Does the user service support changes to user display name?
- *
+ *
* @return true or false
* @since 1.0.0
- */
+ */
boolean supportsDisplayNameChanges();
/**
* Does the user service support changes to user email address?
- *
+ *
* @return true or false
* @since 1.0.0
- */
+ */
boolean supportsEmailAddressChanges();
-
+
/**
* Does the user service support changes to team memberships?
- *
+ *
* @return true or false
* @since 1.0.0
- */
+ */
boolean supportsTeamMembershipChanges();
-
+
/**
* Does the user service support cookie authentication?
- *
+ *
* @return true or false
*/
boolean supportsCookies();
/**
* Returns the cookie value for the specified user.
- *
+ *
* @param model
* @return cookie value
*/
@@ -89,7 +89,7 @@ public interface IUserService {
/**
* Authenticate a user based on their cookie.
- *
+ *
* @param cookie
* @return a user object or null
*/
@@ -97,7 +97,7 @@ public interface IUserService {
/**
* Authenticate a user based on a username and password.
- *
+ *
* @param username
* @param password
* @return a user object or null
@@ -106,14 +106,14 @@ public interface IUserService {
/**
* Logout a user.
- *
+ *
* @param user
*/
void logout(UserModel user);
-
+
/**
* Retrieve the user object for the specified username.
- *
+ *
* @param username
* @return a user object or null
*/
@@ -121,7 +121,7 @@ public interface IUserService {
/**
* Updates/writes a complete user object.
- *
+ *
* @param model
* @return true if update is successful
*/
@@ -129,17 +129,17 @@ public interface IUserService {
/**
* Updates/writes all specified user objects.
- *
+ *
* @param models a list of user models
* @return true if update is successful
* @since 1.2.0
*/
boolean updateUserModels(Collection<UserModel> models);
-
+
/**
* Adds/updates a user object keyed by username. This method allows for
* renaming a user.
- *
+ *
* @param username
* the old username
* @param model
@@ -150,7 +150,7 @@ public interface IUserService {
/**
* Deletes the user object from the user service.
- *
+ *
* @param model
* @return true if successful
*/
@@ -158,7 +158,7 @@ public interface IUserService {
/**
* Delete the user object with the specified username
- *
+ *
* @param username
* @return true if successful
*/
@@ -166,14 +166,14 @@ public interface IUserService {
/**
* Returns the list of all users available to the login service.
- *
+ *
* @return list of all usernames
*/
List<String> getAllUsernames();
-
+
/**
* Returns the list of all users available to the login service.
- *
+ *
* @return list of all users
* @since 0.8.0
*/
@@ -181,35 +181,35 @@ public interface IUserService {
/**
* Returns the list of all teams available to the login service.
- *
+ *
* @return list of all teams
* @since 0.8.0
- */
+ */
List<String> getAllTeamNames();
-
+
/**
* Returns the list of all teams available to the login service.
- *
+ *
* @return list of all teams
* @since 0.8.0
- */
+ */
List<TeamModel> getAllTeams();
-
+
/**
* Returns the list of all users who are allowed to bypass the access
* restriction placed on the specified repository.
- *
+ *
* @param role
* the repository name
* @return list of all usernames that can bypass the access restriction
* @since 0.8.0
- */
+ */
List<String> getTeamnamesForRepositoryRole(String role);
/**
* Sets the list of all teams who are allowed to bypass the access
* restriction placed on the specified repository.
- *
+ *
* @param role
* the repository name
* @param teamnames
@@ -218,38 +218,38 @@ public interface IUserService {
*/
@Deprecated
boolean setTeamnamesForRepositoryRole(String role, List<String> teamnames);
-
+
/**
* Retrieve the team object for the specified team name.
- *
+ *
* @param teamname
* @return a team object or null
* @since 0.8.0
- */
+ */
TeamModel getTeamModel(String teamname);
/**
* Updates/writes a complete team object.
- *
+ *
* @param model
* @return true if update is successful
* @since 0.8.0
- */
+ */
boolean updateTeamModel(TeamModel model);
/**
* Updates/writes all specified team objects.
- *
+ *
* @param models a list of team models
* @return true if update is successful
* @since 1.2.0
- */
+ */
boolean updateTeamModels(Collection<TeamModel> models);
-
+
/**
* Updates/writes and replaces a complete team object keyed by teamname.
* This method allows for renaming a team.
- *
+ *
* @param teamname
* the old teamname
* @param model
@@ -261,7 +261,7 @@ public interface IUserService {
/**
* Deletes the team object from the user service.
- *
+ *
* @param model
* @return true if successful
* @since 0.8.0
@@ -270,17 +270,17 @@ public interface IUserService {
/**
* Delete the team object with the specified teamname
- *
+ *
* @param teamname
* @return true if successful
* @since 0.8.0
- */
+ */
boolean deleteTeam(String teamname);
/**
* Returns the list of all users who are allowed to bypass the access
* restriction placed on the specified repository.
- *
+ *
* @param role
* the repository name
* @return list of all usernames that can bypass the access restriction
@@ -291,7 +291,7 @@ public interface IUserService {
/**
* Sets the list of all uses who are allowed to bypass the access
* restriction placed on the specified repository.
- *
+ *
* @param role
* the repository name
* @param usernames
@@ -302,7 +302,7 @@ public interface IUserService {
/**
* Renames a repository role.
- *
+ *
* @param oldRole
* @param newRole
* @return true if successful
@@ -311,7 +311,7 @@ public interface IUserService {
/**
* Removes a repository role from all users.
- *
+ *
* @param role
* @return true if successful
*/
@@ -321,5 +321,6 @@ public interface IUserService {
* @See java.lang.Object.toString();
* @return string representation of the login service
*/
+ @Override
String toString();
}
diff --git a/src/main/java/com/gitblit/JsonServlet.java b/src/main/java/com/gitblit/JsonServlet.java
index 3ee4a272..286b1390 100644
--- a/src/main/java/com/gitblit/JsonServlet.java
+++ b/src/main/java/com/gitblit/JsonServlet.java
@@ -33,20 +33,20 @@ import com.gitblit.utils.StringUtils;
/**
* Servlet class for interpreting json requests.
- *
+ *
* @author James Moger
- *
+ *
*/
public abstract class JsonServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected final int forbiddenCode = HttpServletResponse.SC_FORBIDDEN;
-
+
protected final int notAllowedCode = HttpServletResponse.SC_METHOD_NOT_ALLOWED;
protected final int failureCode = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
-
+
protected final Logger logger;
public JsonServlet() {
@@ -56,7 +56,7 @@ public abstract class JsonServlet extends HttpServlet {
/**
* Processes an gson request.
- *
+ *
* @param request
* @param response
* @throws javax.servlet.ServletException
diff --git a/src/main/java/com/gitblit/Launcher.java b/src/main/java/com/gitblit/Launcher.java
index ed465f03..68a9dbf9 100644
--- a/src/main/java/com/gitblit/Launcher.java
+++ b/src/main/java/com/gitblit/Launcher.java
@@ -33,9 +33,9 @@ import java.util.List;
* folders and then calls the application main. Using this technique we do not
* have to specify a classpath and we can dynamically add jars to the
* distribution.
- *
+ *
* @author James Moger
- *
+ *
*/
public class Launcher {
@@ -120,7 +120,7 @@ public class Launcher {
/**
* Adds a file to the classpath
- *
+ *
* @param f
* the file to be added
* @throws IOException
diff --git a/src/main/java/com/gitblit/LdapUserService.java b/src/main/java/com/gitblit/LdapUserService.java
index b65f9bb7..db38c528 100644
--- a/src/main/java/com/gitblit/LdapUserService.java
+++ b/src/main/java/com/gitblit/LdapUserService.java
@@ -49,7 +49,7 @@ import com.unboundid.util.ssl.TrustAllTrustManager;
/**
* Implementation of an LDAP user service.
- *
+ *
* @author John Crygier
*/
public class LdapUserService extends GitblitUserService {
@@ -58,7 +58,7 @@ public class LdapUserService extends GitblitUserService {
private IStoredSettings settings;
private AtomicLong lastLdapUserSync = new AtomicLong(0L);
-
+
public LdapUserService() {
super();
}
@@ -74,19 +74,19 @@ public class LdapUserService extends GitblitUserService {
throw new IllegalArgumentException(Keys.realm.ldap.ldapCachePeriod + " must have format '<long> <TimeUnit>' where <TimeUnit> is one of 'MILLISECONDS', 'SECONDS', 'MINUTES', 'HOURS', 'DAYS'");
}
}
-
+
@Override
public void setup(IStoredSettings settings) {
this.settings = settings;
String file = settings.getString(Keys.realm.ldap.backingUserService, "${baseFolder}/users.conf");
File realmFile = GitBlit.getFileOrFolder(file);
-
+
serviceImpl = createUserService(realmFile);
logger.info("LDAP User Service backed by " + serviceImpl.toString());
-
+
synchronizeLdapUsers();
}
-
+
protected synchronized void synchronizeLdapUsers() {
final boolean enabled = settings.getBoolean(Keys.realm.ldap.synchronizeUsers.enable, false);
if (enabled) {
@@ -150,7 +150,7 @@ public class LdapUserService extends GitblitUserService {
updateTeamModels(userTeams.values());
}
}
- lastLdapUserSync.set(System.currentTimeMillis());
+ lastLdapUserSync.set(System.currentTimeMillis());
} finally {
ldapConnection.close();
}
@@ -158,18 +158,18 @@ public class LdapUserService extends GitblitUserService {
}
}
}
-
+
private LDAPConnection getLdapConnection() {
try {
URI ldapUrl = new URI(settings.getRequiredString(Keys.realm.ldap.server));
String bindUserName = settings.getString(Keys.realm.ldap.username, "");
String bindPassword = settings.getString(Keys.realm.ldap.password, "");
int ldapPort = ldapUrl.getPort();
-
+
if (ldapUrl.getScheme().equalsIgnoreCase("ldaps")) { // SSL
if (ldapPort == -1) // Default Port
ldapPort = 636;
-
+
LDAPConnection conn;
SSLUtil sslUtil = new SSLUtil(new TrustAllTrustManager());
if (StringUtils.isEmpty(bindUserName) && StringUtils.isEmpty(bindPassword)) {
@@ -184,9 +184,9 @@ public class LdapUserService extends GitblitUserService {
LDAPConnection conn;
if (StringUtils.isEmpty(bindUserName) && StringUtils.isEmpty(bindPassword)) {
- conn = new LDAPConnection(ldapUrl.getHost(), ldapPort);
+ conn = new LDAPConnection(ldapUrl.getHost(), ldapPort);
} else {
- conn = new LDAPConnection(ldapUrl.getHost(), ldapPort, bindUserName, bindPassword);
+ conn = new LDAPConnection(ldapUrl.getHost(), ldapPort, bindUserName, bindPassword);
}
if (ldapUrl.getScheme().equalsIgnoreCase("ldap+tls")) {
@@ -208,10 +208,10 @@ public class LdapUserService extends GitblitUserService {
} catch (LDAPException e) {
logger.error("Error Connecting to LDAP", e);
}
-
+
return null;
}
-
+
/**
* Credentials are defined in the LDAP server and can not be manipulated
* from Gitblit.
@@ -223,7 +223,7 @@ public class LdapUserService extends GitblitUserService {
public boolean supportsCredentialChanges() {
return false;
}
-
+
/**
* If no displayName pattern is defined then Gitblit can manage the display name.
*
@@ -234,7 +234,7 @@ public class LdapUserService extends GitblitUserService {
public boolean supportsDisplayNameChanges() {
return StringUtils.isEmpty(settings.getString(Keys.realm.ldap.displayName, ""));
}
-
+
/**
* If no email pattern is defined then Gitblit can manage the email address.
*
@@ -246,19 +246,20 @@ public class LdapUserService extends GitblitUserService {
return StringUtils.isEmpty(settings.getString(Keys.realm.ldap.email, ""));
}
-
+
/**
* If the LDAP server will maintain team memberships then LdapUserService
* will not allow team membership changes. In this scenario all team
* changes must be made on the LDAP server by the LDAP administrator.
- *
+ *
* @return true or false
* @since 1.0.0
- */
+ */
+ @Override
public boolean supportsTeamMembershipChanges() {
return !settings.getBoolean(Keys.realm.ldap.maintainTeams, false);
}
-
+
@Override
protected AccountType getAccountType() {
return AccountType.LDAP;
@@ -270,9 +271,9 @@ public class LdapUserService extends GitblitUserService {
// local account, bypass LDAP authentication
return super.authenticate(username, password);
}
-
+
String simpleUsername = getSimpleUsername(username);
-
+
LDAPConnection ldapConnection = getLdapConnection();
if (ldapConnection != null) {
try {
@@ -313,7 +314,7 @@ public class LdapUserService extends GitblitUserService {
updateTeamModel(userTeam);
}
}
-
+
return user;
}
}
@@ -321,14 +322,14 @@ public class LdapUserService extends GitblitUserService {
ldapConnection.close();
}
}
- return null;
+ return null;
}
/**
* Set the admin attribute from team memberships retrieved from LDAP.
* If we are not storing teams in LDAP and/or we have not defined any
* administrator teams, then do not change the admin flag.
- *
+ *
* @param user
*/
private void setAdminAttribute(UserModel user) {
@@ -349,17 +350,17 @@ public class LdapUserService extends GitblitUserService {
}
}
}
-
+
private void setUserAttributes(UserModel user, SearchResultEntry userEntry) {
// Is this user an admin?
setAdminAttribute(user);
-
+
// Don't want visibility into the real password, make up a dummy
user.password = Constants.EXTERNAL_ACCOUNT;
user.accountType = getAccountType();
-
+
// Get full name Attribute
- String displayName = settings.getString(Keys.realm.ldap.displayName, "");
+ String displayName = settings.getString(Keys.realm.ldap.displayName, "");
if (!StringUtils.isEmpty(displayName)) {
// Replace embedded ${} with attributes
if (displayName.contains("${")) {
@@ -374,7 +375,7 @@ public class LdapUserService extends GitblitUserService {
}
}
}
-
+
// Get email address Attribute
String email = settings.getString(Keys.realm.ldap.email, "");
if (!StringUtils.isEmpty(email)) {
@@ -394,39 +395,39 @@ public class LdapUserService extends GitblitUserService {
private void getTeamsFromLdap(LDAPConnection ldapConnection, String simpleUsername, SearchResultEntry loggingInUser, UserModel user) {
String loggingInUserDN = loggingInUser.getDN();
-
+
user.teams.clear(); // Clear the users team memberships - we're going to get them from LDAP
String groupBase = settings.getString(Keys.realm.ldap.groupBase, "");
String groupMemberPattern = settings.getString(Keys.realm.ldap.groupMemberPattern, "(&(objectClass=group)(member=${dn}))");
-
+
groupMemberPattern = StringUtils.replace(groupMemberPattern, "${dn}", escapeLDAPSearchFilter(loggingInUserDN));
groupMemberPattern = StringUtils.replace(groupMemberPattern, "${username}", escapeLDAPSearchFilter(simpleUsername));
-
+
// Fill in attributes into groupMemberPattern
for (Attribute userAttribute : loggingInUser.getAttributes())
groupMemberPattern = StringUtils.replace(groupMemberPattern, "${" + userAttribute.getName() + "}", escapeLDAPSearchFilter(userAttribute.getValue()));
-
+
SearchResult teamMembershipResult = doSearch(ldapConnection, groupBase, groupMemberPattern);
if (teamMembershipResult != null && teamMembershipResult.getEntryCount() > 0) {
for (int i = 0; i < teamMembershipResult.getEntryCount(); i++) {
SearchResultEntry teamEntry = teamMembershipResult.getSearchEntries().get(i);
String teamName = teamEntry.getAttribute("cn").getValue();
-
+
TeamModel teamModel = getTeamModel(teamName);
if (teamModel == null)
teamModel = createTeamFromLdap(teamEntry);
-
+
user.teams.add(teamModel);
teamModel.addUser(user.getName());
}
}
}
-
+
private TeamModel createTeamFromLdap(SearchResultEntry teamEntry) {
TeamModel answer = new TeamModel(teamEntry.getAttributeValue("cn"));
// potentially retrieve other attributes here in the future
-
- return answer;
+
+ return answer;
}
private SearchResult doSearch(LDAPConnection ldapConnection, String base, String filter) {
@@ -434,11 +435,11 @@ public class LdapUserService extends GitblitUserService {
return ldapConnection.search(base, SearchScope.SUB, filter);
} catch (LDAPSearchException e) {
logger.error("Problem Searching LDAP", e);
-
+
return null;
}
}
-
+
private boolean isAuthenticated(LDAPConnection ldapConnection, String userDn, String password) {
try {
// Binding will stop any LDAP-Injection Attacks since the searched-for user needs to bind to that DN
@@ -461,10 +462,10 @@ public class LdapUserService extends GitblitUserService {
synchronizeLdapUsers();
return super.getAllUsers();
}
-
+
/**
* Returns a simple username without any domain prefixes.
- *
+ *
* @param username
* @return a simple username
*/
@@ -473,10 +474,10 @@ public class LdapUserService extends GitblitUserService {
if (lastSlash > -1) {
username = username.substring(lastSlash + 1);
}
-
+
return username;
}
-
+
// From: https://www.owasp.org/index.php/Preventing_LDAP_Injection_in_Java
public static final String escapeLDAPSearchFilter(String filter) {
StringBuilder sb = new StringBuilder();
@@ -495,8 +496,8 @@ public class LdapUserService extends GitblitUserService {
case ')':
sb.append("\\29");
break;
- case '\u0000':
- sb.append("\\00");
+ case '\u0000':
+ sb.append("\\00");
break;
default:
sb.append(curChar);
diff --git a/src/main/java/com/gitblit/LogoServlet.java b/src/main/java/com/gitblit/LogoServlet.java
index 823e464c..eb167e72 100644
--- a/src/main/java/com/gitblit/LogoServlet.java
+++ b/src/main/java/com/gitblit/LogoServlet.java
@@ -29,20 +29,20 @@ import javax.servlet.http.HttpServletResponse;
/**
* Handles requests for logo.png
- *
+ *
* @author James Moger
- *
+ *
*/
public class LogoServlet extends HttpServlet {
-
+
private static final long serialVersionUID = 1L;
-
+
private static final long lastModified = System.currentTimeMillis();
public LogoServlet() {
super();
}
-
+
@Override
protected long getLastModified(HttpServletRequest req) {
File file = GitBlit.getFileOrFolder(Keys.web.headerLogo, "${baseFolder}/logo.png");
@@ -52,7 +52,7 @@ public class LogoServlet extends HttpServlet {
return lastModified;
}
}
-
+
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
@@ -71,7 +71,7 @@ public class LogoServlet extends HttpServlet {
// default logo
response.setDateHeader("Last-Modified", lastModified);
is = getClass().getResourceAsStream("/logo.png");
- }
+ }
if (contentType == null) {
contentType = "image/png";
}
diff --git a/src/main/java/com/gitblit/LuceneExecutor.java b/src/main/java/com/gitblit/LuceneExecutor.java
index 376a763a..28523cef 100644
--- a/src/main/java/com/gitblit/LuceneExecutor.java
+++ b/src/main/java/com/gitblit/LuceneExecutor.java
@@ -95,13 +95,13 @@ import com.gitblit.utils.StringUtils;
/**
* The Lucene executor handles indexing and searching repositories.
- *
+ *
* @author James Moger
- *
+ *
*/
public class LuceneExecutor implements Runnable {
-
-
+
+
private static final int INDEX_VERSION = 5;
private static final String FIELD_OBJECT_TYPE = "type";
@@ -121,20 +121,20 @@ public class LuceneExecutor implements Runnable {
private static final String CONF_VERSION = "version";
private static final String CONF_ALIAS = "aliases";
private static final String CONF_BRANCH = "branches";
-
+
private static final Version LUCENE_VERSION = Version.LUCENE_35;
-
+
private final Logger logger = LoggerFactory.getLogger(LuceneExecutor.class);
-
+
private final IStoredSettings storedSettings;
private final File repositoriesFolder;
-
+
private final Map<String, IndexSearcher> searchers = new ConcurrentHashMap<String, IndexSearcher>();
private final Map<String, IndexWriter> writers = new ConcurrentHashMap<String, IndexWriter>();
-
+
private final String luceneIgnoreExtensions = "7z arc arj bin bmp dll doc docx exe gif gz jar jpg lib lzh odg odf odt pdf ppt png so swf xcf xls xlsx zip";
private Set<String> excludedExtensions;
-
+
public LuceneExecutor(IStoredSettings settings, File repositoriesFolder) {
this.storedSettings = settings;
this.repositoriesFolder = repositoriesFolder;
@@ -146,7 +146,7 @@ public class LuceneExecutor implements Runnable {
}
/**
- * Run is executed by the Gitblit executor service. Because this is called
+ * Run is executed by the Gitblit executor service. Because this is called
* by an executor service, calls will queue - i.e. there can never be
* concurrent execution of repository index updates.
*/
@@ -164,7 +164,7 @@ public class LuceneExecutor implements Runnable {
// busy collecting garbage, try again later
return;
}
-
+
for (String repositoryName: GitBlit.self().getRepositoryList()) {
RepositoryModel model = GitBlit.self().getRepositoryModel(repositoryName);
if (model.hasCommits && !ArrayUtils.isEmpty(model.indexedBranches)) {
@@ -175,7 +175,7 @@ public class LuceneExecutor implements Runnable {
}
continue;
}
- index(model, repository);
+ index(model, repository);
repository.close();
System.gc();
}
@@ -185,7 +185,7 @@ public class LuceneExecutor implements Runnable {
/**
* Synchronously indexes a repository. This may build a complete index of a
* repository or it may update an existing index.
- *
+ *
* @param name
* the name of the repository
* @param repository
@@ -225,10 +225,10 @@ public class LuceneExecutor implements Runnable {
logger.error(MessageFormat.format("Lucene indexing failure for {0}", model.name), t);
}
}
-
+
/**
* Close the writer/searcher objects for a repository.
- *
+ *
* @param repositoryName
*/
public synchronized void close(String repositoryName) {
@@ -240,7 +240,7 @@ public class LuceneExecutor implements Runnable {
} catch (Exception e) {
logger.error("Failed to close index searcher for " + repositoryName, e);
}
-
+
try {
IndexWriter writer = writers.remove(repositoryName);
if (writer != null) {
@@ -248,12 +248,12 @@ public class LuceneExecutor implements Runnable {
}
} catch (Exception e) {
logger.error("Failed to close index writer for " + repositoryName, e);
- }
+ }
}
/**
* Close all Lucene indexers.
- *
+ *
*/
public synchronized void close() {
// close all writers
@@ -277,10 +277,10 @@ public class LuceneExecutor implements Runnable {
searchers.clear();
}
-
+
/**
* Deletes the Lucene index for the specified repository.
- *
+ *
* @param repositoryName
* @return true, if successful
*/
@@ -306,10 +306,10 @@ public class LuceneExecutor implements Runnable {
throw new RuntimeException(e);
}
}
-
+
/**
* Returns the author for the commit, if this information is available.
- *
+ *
* @param commit
* @return an author or unknown
*/
@@ -320,14 +320,14 @@ public class LuceneExecutor implements Runnable {
if (StringUtils.isEmpty(name)) {
name = commit.getAuthorIdent().getEmailAddress();
}
- } catch (NullPointerException n) {
+ } catch (NullPointerException n) {
}
return name;
}
-
+
/**
* Returns the committer for the commit, if this information is available.
- *
+ *
* @param commit
* @return an committer or unknown
*/
@@ -338,11 +338,11 @@ public class LuceneExecutor implements Runnable {
if (StringUtils.isEmpty(name)) {
name = commit.getCommitterIdent().getEmailAddress();
}
- } catch (NullPointerException n) {
+ } catch (NullPointerException n) {
}
return name;
}
-
+
/**
* Get the tree associated with the given commit.
*
@@ -363,7 +363,7 @@ public class LuceneExecutor implements Runnable {
/**
* Construct a keyname from the branch.
- *
+ *
* @param branchName
* @return a keyname appropriate for the Git config file format
*/
@@ -373,7 +373,7 @@ public class LuceneExecutor implements Runnable {
/**
* Returns the Lucene configuration for the specified repository.
- *
+ *
* @param repository
* @return a config object
*/
@@ -387,7 +387,7 @@ public class LuceneExecutor implements Runnable {
* Reads the Lucene config file for the repository to check the index
* version. If the index version is different, then rebuild the repository
* index.
- *
+ *
* @param repository
* @return true of the on-disk index format is different than INDEX_VERSION
*/
@@ -407,13 +407,13 @@ public class LuceneExecutor implements Runnable {
/**
* This completely indexes the repository and will destroy any existing
* index.
- *
+ *
* @param repositoryName
* @param repository
* @return IndexResult
*/
public IndexResult reindex(RepositoryModel model, Repository repository) {
- IndexResult result = new IndexResult();
+ IndexResult result = new IndexResult();
if (!deleteIndex(model.name)) {
return result;
}
@@ -434,12 +434,12 @@ public class LuceneExecutor implements Runnable {
}
tags.get(tag.getReferencedObjectId().getName()).add(tag.displayName);
}
-
+
ObjectReader reader = repository.newObjectReader();
// get the local branches
List<RefModel> branches = JGitUtils.getLocalBranches(repository, true, -1);
-
+
// sort them by most recently updated
Collections.sort(branches, new Comparator<RefModel>() {
@Override
@@ -447,7 +447,7 @@ public class LuceneExecutor implements Runnable {
return ref2.getDate().compareTo(ref1.getDate());
}
});
-
+
// reorder default branch to first position
RefModel defaultBranch = null;
ObjectId defaultBranchId = JGitUtils.getDefaultBranch(repository);
@@ -459,7 +459,7 @@ public class LuceneExecutor implements Runnable {
}
branches.remove(defaultBranch);
branches.add(0, defaultBranch);
-
+
// walk through each branch
for (RefModel branch : branches) {
@@ -475,7 +475,7 @@ public class LuceneExecutor implements Runnable {
// normal explicit branch check
indexBranch = model.indexedBranches.contains(branch.getName());
}
-
+
// if this branch is not specifically indexed then skip
if (!indexBranch) {
continue;
@@ -493,22 +493,22 @@ public class LuceneExecutor implements Runnable {
// index the blob contents of the tree
TreeWalk treeWalk = new TreeWalk(repository);
treeWalk.addTree(tip.getTree());
- treeWalk.setRecursive(true);
-
+ treeWalk.setRecursive(true);
+
Map<String, ObjectId> paths = new TreeMap<String, ObjectId>();
while (treeWalk.next()) {
// ensure path is not in a submodule
if (treeWalk.getFileMode(0) != FileMode.GITLINK) {
paths.put(treeWalk.getPathString(), treeWalk.getObjectId(0));
}
- }
+ }
ByteArrayOutputStream os = new ByteArrayOutputStream();
byte[] tmp = new byte[32767];
RevWalk commitWalk = new RevWalk(reader);
commitWalk.markStart(tip);
-
+
RevCommit commit;
while ((paths.size() > 0) && (commit = commitWalk.next()) != null) {
TreeWalk diffWalk = new TreeWalk(reader);
@@ -532,17 +532,17 @@ public class LuceneExecutor implements Runnable {
if (!paths.containsKey(path)) {
continue;
}
-
+
// remove path from set
ObjectId blobId = paths.remove(path);
result.blobCount++;
-
+
// index the blob metadata
String blobAuthor = getAuthor(commit);
String blobCommitter = getCommitter(commit);
String blobDate = DateTools.timeToString(commit.getCommitTime() * 1000L,
Resolution.MINUTE);
-
+
Document doc = new Document();
doc.add(new Field(FIELD_OBJECT_TYPE, SearchObjectType.blob.name(), Store.YES, Index.NOT_ANALYZED_NO_NORMS));
doc.add(new Field(FIELD_BRANCH, branchName, Store.YES, Index.ANALYZED));
@@ -550,7 +550,7 @@ public class LuceneExecutor implements Runnable {
doc.add(new Field(FIELD_PATH, path, Store.YES, Index.ANALYZED));
doc.add(new Field(FIELD_DATE, blobDate, Store.YES, Index.NO));
doc.add(new Field(FIELD_AUTHOR, blobAuthor, Store.YES, Index.ANALYZED));
- doc.add(new Field(FIELD_COMMITTER, blobCommitter, Store.YES, Index.ANALYZED));
+ doc.add(new Field(FIELD_COMMITTER, blobCommitter, Store.YES, Index.ANALYZED));
// determine extension to compare to the extension
// blacklist
@@ -561,20 +561,20 @@ public class LuceneExecutor implements Runnable {
}
// index the blob content
- if (StringUtils.isEmpty(ext) || !excludedExtensions.contains(ext)) {
+ if (StringUtils.isEmpty(ext) || !excludedExtensions.contains(ext)) {
ObjectLoader ldr = repository.open(blobId, Constants.OBJ_BLOB);
- InputStream in = ldr.openStream();
+ InputStream in = ldr.openStream();
int n;
while ((n = in.read(tmp)) > 0) {
os.write(tmp, 0, n);
}
in.close();
byte[] content = os.toByteArray();
- String str = StringUtils.decodeString(content, encodings);
+ String str = StringUtils.decodeString(content, encodings);
doc.add(new Field(FIELD_CONTENT, str, Store.YES, Index.ANALYZED));
os.reset();
- }
-
+ }
+
// add the blob to the index
writer.addDocument(doc);
}
@@ -608,7 +608,7 @@ public class LuceneExecutor implements Runnable {
// finished
reader.release();
-
+
// commit all changes and reset the searcher
config.setInt(CONF_INDEX, null, CONF_VERSION, INDEX_VERSION);
config.save();
@@ -620,11 +620,11 @@ public class LuceneExecutor implements Runnable {
}
return result;
}
-
+
/**
* Incrementally update the index with the specified commit for the
* repository.
- *
+ *
* @param repositoryName
* @param repository
* @param branch
@@ -632,7 +632,7 @@ public class LuceneExecutor implements Runnable {
* @param commit
* @return true, if successful
*/
- private IndexResult index(String repositoryName, Repository repository,
+ private IndexResult index(String repositoryName, Repository repository,
String branch, RevCommit commit) {
IndexResult result = new IndexResult();
try {
@@ -681,7 +681,7 @@ public class LuceneExecutor implements Runnable {
}
}
writer.commit();
-
+
// get any annotated commit tags
List<String> commitTags = new ArrayList<String>();
for (RefModel ref : JGitUtils.getTags(repository, false, -1)) {
@@ -689,7 +689,7 @@ public class LuceneExecutor implements Runnable {
commitTags.add(ref.displayName);
}
}
-
+
// create and write the Lucene document
Document doc = createDocument(commit, commitTags);
doc.add(new Field(FIELD_BRANCH, branch, Store.YES, Index.ANALYZED));
@@ -703,7 +703,7 @@ public class LuceneExecutor implements Runnable {
/**
* Delete a blob from the specified branch of the repository index.
- *
+ *
* @param repositoryName
* @param branch
* @param path
@@ -713,7 +713,7 @@ public class LuceneExecutor implements Runnable {
public boolean deleteBlob(String repositoryName, String branch, String path) throws Exception {
String pattern = MessageFormat.format("{0}:'{'0} AND {1}:\"'{'1'}'\" AND {2}:\"'{'2'}'\"", FIELD_OBJECT_TYPE, FIELD_BRANCH, FIELD_PATH);
String q = MessageFormat.format(pattern, SearchObjectType.blob.name(), branch, path);
-
+
BooleanQuery query = new BooleanQuery();
StandardAnalyzer analyzer = new StandardAnalyzer(LUCENE_VERSION);
QueryParser qp = new QueryParser(LUCENE_VERSION, FIELD_SUMMARY, analyzer);
@@ -721,7 +721,7 @@ public class LuceneExecutor implements Runnable {
IndexWriter writer = getIndexWriter(repositoryName);
int numDocsBefore = writer.numDocs();
- writer.deleteDocuments(query);
+ writer.deleteDocuments(query);
writer.commit();
int numDocsAfter = writer.numDocs();
if (numDocsBefore == numDocsAfter) {
@@ -735,7 +735,7 @@ public class LuceneExecutor implements Runnable {
/**
* Updates a repository index incrementally from the last indexed commits.
- *
+ *
* @param model
* @param repository
* @return IndexResult
@@ -770,7 +770,7 @@ public class LuceneExecutor implements Runnable {
// get the local branches
List<RefModel> branches = JGitUtils.getLocalBranches(repository, true, -1);
-
+
// sort them by most recently updated
Collections.sort(branches, new Comparator<RefModel>() {
@Override
@@ -778,7 +778,7 @@ public class LuceneExecutor implements Runnable {
return ref2.getDate().compareTo(ref1.getDate());
}
});
-
+
// reorder default branch to first position
RefModel defaultBranch = null;
ObjectId defaultBranchId = JGitUtils.getDefaultBranch(repository);
@@ -790,7 +790,7 @@ public class LuceneExecutor implements Runnable {
}
branches.remove(defaultBranch);
branches.add(0, defaultBranch);
-
+
// walk through each branches
for (RefModel branch : branches) {
String branchName = branch.getName();
@@ -807,15 +807,15 @@ public class LuceneExecutor implements Runnable {
// normal explicit branch check
indexBranch = model.indexedBranches.contains(branch.getName());
}
-
+
// if this branch is not specifically indexed then skip
if (!indexBranch) {
continue;
}
-
+
// remove this branch from the deletedBranches set
deletedBranches.remove(branchName);
-
+
// determine last commit
String keyName = getBranchKey(branchName);
String lastCommit = config.getString(CONF_BRANCH, null, keyName);
@@ -832,10 +832,10 @@ public class LuceneExecutor implements Runnable {
if (revs.size() > 0) {
result.branchCount += 1;
}
-
- // reverse the list of commits so we start with the first commit
+
+ // reverse the list of commits so we start with the first commit
Collections.reverse(revs);
- for (RevCommit commit : revs) {
+ for (RevCommit commit : revs) {
// index a commit
result.add(index(model.name, repository, branchName, commit));
}
@@ -862,10 +862,10 @@ public class LuceneExecutor implements Runnable {
}
return result;
}
-
+
/**
* Creates a Lucene document for a commit
- *
+ *
* @param commit
* @param tags
* @return a Lucene document
@@ -889,13 +889,13 @@ public class LuceneExecutor implements Runnable {
/**
* Incrementally index an object for the repository.
- *
+ *
* @param repositoryName
* @param doc
* @return true, if successful
*/
private boolean index(String repositoryName, Document doc) {
- try {
+ try {
IndexWriter writer = getIndexWriter(repositoryName);
writer.addDocument(doc);
writer.commit();
@@ -913,7 +913,7 @@ public class LuceneExecutor implements Runnable {
result.totalHits = totalHits;
result.score = score;
result.date = DateTools.stringToDate(doc.get(FIELD_DATE));
- result.summary = doc.get(FIELD_SUMMARY);
+ result.summary = doc.get(FIELD_SUMMARY);
result.author = doc.get(FIELD_AUTHOR);
result.committer = doc.get(FIELD_COMMITTER);
result.type = SearchObjectType.fromName(doc.get(FIELD_OBJECT_TYPE));
@@ -935,7 +935,7 @@ public class LuceneExecutor implements Runnable {
/**
* Gets an index searcher for the repository.
- *
+ *
* @param repository
* @return
* @throws IOException
@@ -953,16 +953,16 @@ public class LuceneExecutor implements Runnable {
/**
* Gets an index writer for the repository. The index will be created if it
* does not already exist or if forceCreate is specified.
- *
+ *
* @param repository
* @return an IndexWriter
* @throws IOException
*/
private IndexWriter getIndexWriter(String repository) throws IOException {
- IndexWriter indexWriter = writers.get(repository);
+ IndexWriter indexWriter = writers.get(repository);
File repositoryFolder = FileKey.resolve(new File(repositoriesFolder, repository), FS.DETECTED);
File indexFolder = new File(repositoryFolder, LUCENE_DIR);
- Directory directory = FSDirectory.open(indexFolder);
+ Directory directory = FSDirectory.open(indexFolder);
if (indexWriter == null) {
if (!indexFolder.exists()) {
@@ -979,7 +979,7 @@ public class LuceneExecutor implements Runnable {
/**
* Searches the specified repositories for the given text or query
- *
+ *
* @param text
* if the text is null or empty, null is returned
* @param page
@@ -990,7 +990,7 @@ public class LuceneExecutor implements Runnable {
* a list of repositories to search. if no repositories are
* specified null is returned.
* @return a list of SearchResults in order from highest to the lowest score
- *
+ *
*/
public List<SearchResult> search(String text, int page, int pageSize, List<String> repositories) {
if (ArrayUtils.isEmpty(repositories)) {
@@ -998,10 +998,10 @@ public class LuceneExecutor implements Runnable {
}
return search(text, page, pageSize, repositories.toArray(new String[0]));
}
-
+
/**
* Searches the specified repositories for the given text or query
- *
+ *
* @param text
* if the text is null or empty, null is returned
* @param page
@@ -1012,7 +1012,7 @@ public class LuceneExecutor implements Runnable {
* a list of repositories to search. if no repositories are
* specified null is returned.
* @return a list of SearchResults in order from highest to the lowest score
- *
+ *
*/
public List<SearchResult> search(String text, int page, int pageSize, String... repositories) {
if (StringUtils.isEmpty(text)) {
@@ -1034,7 +1034,7 @@ public class LuceneExecutor implements Runnable {
qp = new QueryParser(LUCENE_VERSION, FIELD_CONTENT, analyzer);
qp.setAllowLeadingWildcard(true);
query.add(qp.parse(text), Occur.SHOULD);
-
+
IndexSearcher searcher;
if (repositories.length == 1) {
// single repository search
@@ -1050,7 +1050,7 @@ public class LuceneExecutor implements Runnable {
MultiSourceReader reader = new MultiSourceReader(rdrs);
searcher = new IndexSearcher(reader);
}
-
+
Query rewrittenQuery = searcher.rewrite(query);
logger.debug(rewrittenQuery.toString());
@@ -1072,7 +1072,7 @@ public class LuceneExecutor implements Runnable {
int index = reader.getSourceIndex(docId);
result.repository = repositories[index];
}
- String content = doc.get(FIELD_CONTENT);
+ String content = doc.get(FIELD_CONTENT);
result.fragment = getHighlightedFragment(analyzer, query, content, result);
results.add(result);
}
@@ -1081,9 +1081,9 @@ public class LuceneExecutor implements Runnable {
}
return new ArrayList<SearchResult>(results);
}
-
+
/**
- *
+ *
* @param analyzer
* @param query
* @param content
@@ -1096,18 +1096,18 @@ public class LuceneExecutor implements Runnable {
String content, SearchResult result) throws IOException, InvalidTokenOffsetsException {
if (content == null) {
content = "";
- }
+ }
int fragmentLength = SearchObjectType.commit == result.type ? 512 : 150;
QueryScorer scorer = new QueryScorer(query, "content");
- Fragmenter fragmenter = new SimpleSpanFragmenter(scorer, fragmentLength);
+ Fragmenter fragmenter = new SimpleSpanFragmenter(scorer, fragmentLength);
// use an artificial delimiter for the token
String termTag = "!!--[";
String termTagEnd = "]--!!";
SimpleHTMLFormatter formatter = new SimpleHTMLFormatter(termTag, termTagEnd);
- Highlighter highlighter = new Highlighter(formatter, scorer);
+ Highlighter highlighter = new Highlighter(formatter, scorer);
highlighter.setTextFragmenter(fragmenter);
String [] fragments = highlighter.getBestFragments(analyzer, "content", content, 3);
@@ -1122,14 +1122,14 @@ public class LuceneExecutor implements Runnable {
}
return "<pre class=\"text\">" + StringUtils.escapeForHtml(fragment, true) + "</pre>";
}
-
+
// make sure we have unique fragments
Set<String> uniqueFragments = new LinkedHashSet<String>();
for (String fragment : fragments) {
uniqueFragments.add(fragment);
}
fragments = uniqueFragments.toArray(new String[uniqueFragments.size()]);
-
+
StringBuilder sb = new StringBuilder();
for (int i = 0, len = fragments.length; i < len; i++) {
String fragment = fragments[i];
@@ -1140,7 +1140,7 @@ public class LuceneExecutor implements Runnable {
// determine position of the raw fragment in the content
int pos = content.indexOf(raw);
-
+
// restore complete first line of fragment
int c = pos;
while (c > 0) {
@@ -1153,11 +1153,11 @@ public class LuceneExecutor implements Runnable {
// inject leading chunk of first fragment line
fragment = content.substring(c + 1, pos) + fragment;
}
-
+
if (SearchObjectType.blob == result.type) {
// count lines as offset into the content for this fragment
int line = Math.max(1, StringUtils.countLines(content.substring(0, pos)));
-
+
// create fragment tag with line number and language
String lang = "";
String ext = StringUtils.getFileExtension(result.path).toLowerCase();
@@ -1166,9 +1166,9 @@ public class LuceneExecutor implements Runnable {
lang = " lang-" + ext;
}
tag = MessageFormat.format("<pre class=\"prettyprint linenums:{0,number,0}{1}\">", line, lang);
-
+
}
-
+
sb.append(tag);
// replace the artificial delimiter with html tags
@@ -1181,10 +1181,10 @@ public class LuceneExecutor implements Runnable {
}
}
return sb.toString();
- }
-
+ }
+
/**
- * Simple class to track the results of an index update.
+ * Simple class to track the results of an index update.
*/
private class IndexResult {
long startTime = System.currentTimeMillis();
@@ -1193,33 +1193,33 @@ public class LuceneExecutor implements Runnable {
int branchCount;
int commitCount;
int blobCount;
-
+
void add(IndexResult result) {
this.branchCount += result.branchCount;
this.commitCount += result.commitCount;
this.blobCount += result.blobCount;
}
-
+
void success() {
success = true;
endTime = System.currentTimeMillis();
}
-
+
float duration() {
return (endTime - startTime)/1000f;
}
}
-
+
/**
* Custom subclass of MultiReader to identify the source index for a given
* doc id. This would not be necessary of there was a public method to
* obtain this information.
- *
+ *
*/
private class MultiSourceReader extends MultiReader {
-
+
final Method method;
-
+
MultiSourceReader(IndexReader[] subReaders) {
super(subReaders);
Method m = null;
@@ -1231,7 +1231,7 @@ public class LuceneExecutor implements Runnable {
}
method = m;
}
-
+
int getSourceIndex(int docId) {
int index = -1;
try {
diff --git a/src/main/java/com/gitblit/MailExecutor.java b/src/main/java/com/gitblit/MailExecutor.java
index c4e776a9..b1ba3b69 100644
--- a/src/main/java/com/gitblit/MailExecutor.java
+++ b/src/main/java/com/gitblit/MailExecutor.java
@@ -41,9 +41,9 @@ import com.gitblit.utils.StringUtils;
/**
* The mail executor handles sending email messages asynchronously from queue.
- *
+ *
* @author James Moger
- *
+ *
*/
public class MailExecutor implements Runnable {
@@ -90,6 +90,7 @@ public class MailExecutor implements Runnable {
if (!StringUtils.isEmpty(mailUser) && !StringUtils.isEmpty(mailPassword)) {
// SMTP requires authentication
session = Session.getInstance(props, new Authenticator() {
+ @Override
protected PasswordAuthentication getPasswordAuthentication() {
PasswordAuthentication passwordAuthentication = new PasswordAuthentication(
mailUser, mailPassword);
@@ -104,7 +105,7 @@ public class MailExecutor implements Runnable {
/**
* Indicates if the mail executor can send emails.
- *
+ *
* @return true if the mail executor is ready to send emails
*/
public boolean isReady() {
@@ -114,7 +115,7 @@ public class MailExecutor implements Runnable {
/**
* Create a message.
- *
+ *
* @param toAddresses
* @return a message
*/
@@ -124,7 +125,7 @@ public class MailExecutor implements Runnable {
/**
* Create a message.
- *
+ *
* @param toAddresses
* @return a message
*/
@@ -143,7 +144,7 @@ public class MailExecutor implements Runnable {
for (String address : toAddresses) {
uniques.add(address.toLowerCase());
}
-
+
Pattern validEmail = Pattern
.compile("^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$");
List<InternetAddress> tos = new ArrayList<InternetAddress>();
@@ -157,7 +158,7 @@ public class MailExecutor implements Runnable {
} catch (Throwable t) {
}
}
- }
+ }
message.setRecipients(Message.RecipientType.BCC,
tos.toArray(new InternetAddress[tos.size()]));
message.setSentDate(new Date());
@@ -169,7 +170,7 @@ public class MailExecutor implements Runnable {
/**
* Returns the status of the mail queue.
- *
+ *
* @return true, if the queue is empty
*/
public boolean hasEmptyQueue() {
@@ -178,7 +179,7 @@ public class MailExecutor implements Runnable {
/**
* Queue's an email message to be sent.
- *
+ *
* @param message
* @return true if the message was queued
*/
@@ -213,13 +214,13 @@ public class MailExecutor implements Runnable {
failures.add(message);
}
}
-
+
// push the failures back onto the queue for the next cycle
queue.addAll(failures);
}
}
}
-
+
public void sendNow(Message message) throws Exception {
Transport.send(message);
}
diff --git a/src/main/java/com/gitblit/PAMUserService.java b/src/main/java/com/gitblit/PAMUserService.java
index 692b0f4a..2134023d 100644
--- a/src/main/java/com/gitblit/PAMUserService.java
+++ b/src/main/java/com/gitblit/PAMUserService.java
@@ -30,7 +30,7 @@ import com.gitblit.utils.StringUtils;
/**
* Implementation of a PAM user service for Linux/Unix/MacOSX.
- *
+ *
* @author James Moger
*/
public class PAMUserService extends GitblitUserService {
@@ -38,7 +38,7 @@ public class PAMUserService extends GitblitUserService {
private final Logger logger = LoggerFactory.getLogger(PAMUserService.class);
private IStoredSettings settings;
-
+
public PAMUserService() {
super();
}
@@ -52,7 +52,7 @@ public class PAMUserService extends GitblitUserService {
serviceImpl = createUserService(realmFile);
logger.info("PAM User Service backed by " + serviceImpl.toString());
-
+
// Try to identify the passwd database
String [] files = { "/etc/shadow", "/etc/master.passwd" };
File passwdFile = null;
@@ -69,7 +69,7 @@ public class PAMUserService extends GitblitUserService {
logger.error("PAM User Service can not read passwd database {}! PAM authentications may fail!", passwdFile);
}
}
-
+
@Override
public boolean supportsCredentialChanges() {
return false;
@@ -89,7 +89,7 @@ public class PAMUserService extends GitblitUserService {
public boolean supportsTeamMembershipChanges() {
return true;
}
-
+
@Override
protected AccountType getAccountType() {
return AccountType.PAM;
@@ -101,7 +101,7 @@ public class PAMUserService extends GitblitUserService {
// local account, bypass PAM authentication
return super.authenticate(username, password);
}
-
+
if (CLibrary.libc.getpwnam(username) == null) {
logger.warn("Can not get PAM passwd for " + username);
return null;
@@ -136,7 +136,7 @@ public class PAMUserService extends GitblitUserService {
// push the changes to the backing user service
super.updateUserModel(user);
-
+
return user;
}
}
diff --git a/src/main/java/com/gitblit/PagesFilter.java b/src/main/java/com/gitblit/PagesFilter.java
index 68ae31ef..e8deb5d2 100644
--- a/src/main/java/com/gitblit/PagesFilter.java
+++ b/src/main/java/com/gitblit/PagesFilter.java
@@ -24,22 +24,22 @@ import com.gitblit.models.UserModel;
/**
* The PagesFilter is an AccessRestrictionFilter which ensures the gh-pages
* requests for a view-restricted repository are authenticated and authorized.
- *
+ *
* @author James Moger
- *
+ *
*/
public class PagesFilter extends AccessRestrictionFilter {
/**
* Extract the repository name from the url.
- *
+ *
* @param url
* @return repository name
*/
@Override
- protected String extractRepositoryName(String url) {
+ protected String extractRepositoryName(String url) {
// get the repository name from the url by finding a known url suffix
- String repository = "";
+ String repository = "";
Repository r = null;
int offset = 0;
while (r == null) {
@@ -52,11 +52,11 @@ public class PagesFilter extends AccessRestrictionFilter {
r = GitBlit.self().getRepository(repository, false);
if (r == null) {
// try again
- offset = slash + 1;
+ offset = slash + 1;
} else {
// close the repo
r.close();
- }
+ }
if (repository.equals(url)) {
// either only repository in url or no repository found
break;
@@ -67,7 +67,7 @@ public class PagesFilter extends AccessRestrictionFilter {
/**
* Analyze the url and returns the action of the request.
- *
+ *
* @param cloneUrl
* @return action of the request
*/
@@ -78,7 +78,7 @@ public class PagesFilter extends AccessRestrictionFilter {
/**
* Determine if a non-existing repository can be created using this filter.
- *
+ *
* @return true if the filter allows repository creation
*/
@Override
@@ -88,7 +88,7 @@ public class PagesFilter extends AccessRestrictionFilter {
/**
* Determine if the action may be executed on the repository.
- *
+ *
* @param repository
* @param action
* @return true if the action may be performed
@@ -97,10 +97,10 @@ public class PagesFilter extends AccessRestrictionFilter {
protected boolean isActionAllowed(RepositoryModel repository, String action) {
return true;
}
-
+
/**
* Determine if the repository requires authentication.
- *
+ *
* @param repository
* @param action
* @return true if authentication required
@@ -113,14 +113,14 @@ public class PagesFilter extends AccessRestrictionFilter {
/**
* Determine if the user can access the repository and perform the specified
* action.
- *
+ *
* @param repository
* @param user
* @param action
* @return true if user may execute the action on the repository
*/
@Override
- protected boolean canAccess(RepositoryModel repository, UserModel user, String action) {
+ protected boolean canAccess(RepositoryModel repository, UserModel user, String action) {
return user.canView(repository);
}
}
diff --git a/src/main/java/com/gitblit/PagesServlet.java b/src/main/java/com/gitblit/PagesServlet.java
index fc71bc50..ce4239ce 100644
--- a/src/main/java/com/gitblit/PagesServlet.java
+++ b/src/main/java/com/gitblit/PagesServlet.java
@@ -41,9 +41,9 @@ import com.gitblit.utils.StringUtils;
/**
* Serves the content of a gh-pages branch.
- *
+ *
* @author James Moger
- *
+ *
*/
public class PagesServlet extends HttpServlet {
@@ -57,7 +57,7 @@ public class PagesServlet extends HttpServlet {
/**
* Returns an url to this servlet for the specified parameters.
- *
+ *
* @param baseURL
* @param repository
* @param path
@@ -73,7 +73,7 @@ public class PagesServlet extends HttpServlet {
/**
* Retrieves the specified resource from the gh-pages branch of the
* repository.
- *
+ *
* @param request
* @param response
* @throws javax.servlet.ServletException
diff --git a/src/main/java/com/gitblit/RedmineUserService.java b/src/main/java/com/gitblit/RedmineUserService.java
index d677e3e4..f1a6742f 100644
--- a/src/main/java/com/gitblit/RedmineUserService.java
+++ b/src/main/java/com/gitblit/RedmineUserService.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2012 gitblit.com.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package com.gitblit;
import java.io.File;
@@ -73,7 +88,7 @@ public class RedmineUserService extends GitblitUserService {
public boolean supportsTeamMembershipChanges() {
return false;
}
-
+
@Override
protected AccountType getAccountType() {
return AccountType.REDMINE;
@@ -101,12 +116,12 @@ public class RedmineUserService extends GitblitUserService {
return null;
}
}
-
+
if (StringUtils.isEmpty(jsonString)) {
logger.error("Received empty authentication response from Redmine");
return null;
}
-
+
RedmineCurrent current = null;
try {
current = new Gson().fromJson(jsonString, RedmineCurrent.class);
@@ -176,7 +191,7 @@ public class RedmineUserService extends GitblitUserService {
InputStreamReader reader = new InputStreamReader(http.getInputStream());
return IOUtils.toString(reader);
}
-
+
/**
* set json response. do NOT invoke from production code.
* @param json json
diff --git a/src/main/java/com/gitblit/RobotsTxtServlet.java b/src/main/java/com/gitblit/RobotsTxtServlet.java
index d66ebf43..dfc06b5d 100644
--- a/src/main/java/com/gitblit/RobotsTxtServlet.java
+++ b/src/main/java/com/gitblit/RobotsTxtServlet.java
@@ -27,9 +27,9 @@ import com.gitblit.utils.FileUtils;
/**
* Handles requests for robots.txt
- *
+ *
* @author James Moger
- *
+ *
*/
public class RobotsTxtServlet extends HttpServlet {
@@ -38,7 +38,7 @@ public class RobotsTxtServlet extends HttpServlet {
public RobotsTxtServlet() {
super();
}
-
+
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, java.io.IOException {
diff --git a/src/main/java/com/gitblit/RpcFilter.java b/src/main/java/com/gitblit/RpcFilter.java
index 1de9fcc4..4c9e12b1 100644
--- a/src/main/java/com/gitblit/RpcFilter.java
+++ b/src/main/java/com/gitblit/RpcFilter.java
@@ -30,23 +30,23 @@ import com.gitblit.models.UserModel;
/**
* The RpcFilter is a servlet filter that secures the RpcServlet.
- *
+ *
* The filter extracts the rpc request type from the url and determines if the
* requested action requires a Basic authentication prompt. If authentication is
* required and no credentials are stored in the "Authorization" header, then a
* basic authentication challenge is issued.
- *
+ *
* http://en.wikipedia.org/wiki/Basic_access_authentication
- *
+ *
* @author James Moger
- *
+ *
*/
public class RpcFilter extends AuthenticationFilter {
/**
* doFilter does the actual work of preprocessing the request to ensure that
* the user may proceed.
- *
+ *
* @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest,
* javax.servlet.ServletResponse, javax.servlet.FilterChain)
*/
diff --git a/src/main/java/com/gitblit/RpcServlet.java b/src/main/java/com/gitblit/RpcServlet.java
index 89df4731..8b48fbe5 100644
--- a/src/main/java/com/gitblit/RpcServlet.java
+++ b/src/main/java/com/gitblit/RpcServlet.java
@@ -44,9 +44,9 @@ import com.gitblit.utils.StringUtils;
/**
* Handles remote procedure calls.
- *
+ *
* @author James Moger
- *
+ *
*/
public class RpcServlet extends JsonServlet {
@@ -60,7 +60,7 @@ public class RpcServlet extends JsonServlet {
/**
* Processes an rpc request.
- *
+ *
* @param request
* @param response
* @throws javax.servlet.ServletException
diff --git a/src/main/java/com/gitblit/SalesforceUserService.java b/src/main/java/com/gitblit/SalesforceUserService.java
index aa0795ac..5979f631 100644
--- a/src/main/java/com/gitblit/SalesforceUserService.java
+++ b/src/main/java/com/gitblit/SalesforceUserService.java
@@ -16,14 +16,15 @@ import com.sforce.ws.ConnectionException;
import com.sforce.ws.ConnectorConfig;
public class SalesforceUserService extends GitblitUserService {
- public static final Logger logger = LoggerFactory
- .getLogger(SalesforceUserService.class);
+
+ public static final Logger logger = LoggerFactory.getLogger(SalesforceUserService.class);
private IStoredSettings settings;
-
+
+ @Override
protected AccountType getAccountType() {
return AccountType.SALESFORCE;
}
-
+
@Override
public void setup(IStoredSettings settings) {
this.settings = settings;
diff --git a/src/main/java/com/gitblit/SparkleShareInviteServlet.java b/src/main/java/com/gitblit/SparkleShareInviteServlet.java
index 14d281a3..11a58dd1 100644
--- a/src/main/java/com/gitblit/SparkleShareInviteServlet.java
+++ b/src/main/java/com/gitblit/SparkleShareInviteServlet.java
@@ -29,9 +29,9 @@ import com.gitblit.utils.StringUtils;
/**
* Handles requests for Sparkleshare Invites
- *
+ *
* @author James Moger
- *
+ *
*/
public class SparkleShareInviteServlet extends HttpServlet {
@@ -40,7 +40,7 @@ public class SparkleShareInviteServlet extends HttpServlet {
public SparkleShareInviteServlet() {
super();
}
-
+
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, java.io.IOException {
@@ -55,8 +55,8 @@ public class SparkleShareInviteServlet extends HttpServlet {
protected void processRequest(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException,
- java.io.IOException {
-
+ java.io.IOException {
+
// extract repo name from request
String repoUrl = request.getPathInfo().substring(1);
@@ -64,11 +64,11 @@ public class SparkleShareInviteServlet extends HttpServlet {
if (repoUrl.endsWith(".xml")) {
repoUrl = repoUrl.substring(0, repoUrl.length() - 4);
}
-
+
String servletPath = Constants.GIT_PATH;
-
+
int schemeIndex = repoUrl.indexOf("://") + 3;
- String host = repoUrl.substring(0, repoUrl.indexOf('/', schemeIndex));
+ String host = repoUrl.substring(0, repoUrl.indexOf('/', schemeIndex));
String path = repoUrl.substring(repoUrl.indexOf(servletPath) + servletPath.length());
String username = null;
int fetchIndex = repoUrl.indexOf('@');
@@ -85,7 +85,7 @@ public class SparkleShareInviteServlet extends HttpServlet {
user = UserModel.ANONYMOUS;
username = "";
}
-
+
// ensure that the requested repository exists
RepositoryModel model = GitBlit.self().getRepositoryModel(path);
if (model == null) {
@@ -93,8 +93,8 @@ public class SparkleShareInviteServlet extends HttpServlet {
response.getWriter().append(MessageFormat.format("Repository \"{0}\" not found!", path));
return;
}
-
- StringBuilder sb = new StringBuilder();
+
+ StringBuilder sb = new StringBuilder();
sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
sb.append("<sparkleshare><invite>\n");
sb.append(MessageFormat.format("<address>{0}</address>\n", host));
diff --git a/src/main/java/com/gitblit/SyndicationFilter.java b/src/main/java/com/gitblit/SyndicationFilter.java
index 61bf2258..2c232ad8 100644
--- a/src/main/java/com/gitblit/SyndicationFilter.java
+++ b/src/main/java/com/gitblit/SyndicationFilter.java
@@ -34,15 +34,15 @@ import com.gitblit.models.UserModel;
* The SyndicationFilter is an AuthenticationFilter which ensures that feed
* requests for projects or view-restricted repositories have proper authentication
* credentials and are authorized for the requested feed.
- *
+ *
* @author James Moger
- *
+ *
*/
public class SyndicationFilter extends AuthenticationFilter {
/**
* Extract the repository name from the url.
- *
+ *
* @param url
* @return repository name
*/
@@ -56,7 +56,7 @@ public class SyndicationFilter extends AuthenticationFilter {
/**
* doFilter does the actual work of preprocessing the request to ensure that
* the user may proceed.
- *
+ *
* @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest,
* javax.servlet.ServletResponse, javax.servlet.FilterChain)
*/
@@ -72,7 +72,7 @@ public class SyndicationFilter extends AuthenticationFilter {
ProjectModel project = GitBlit.self().getProjectModel(name);
RepositoryModel model = null;
-
+
if (project == null) {
// try loading a repository model
model = GitBlit.self().getRepositoryModel(name);
@@ -84,7 +84,7 @@ public class SyndicationFilter extends AuthenticationFilter {
return;
}
}
-
+
// Wrap the HttpServletRequest with the AccessRestrictionRequest which
// overrides the servlet container user principal methods.
// JGit requires either:
diff --git a/src/main/java/com/gitblit/SyndicationServlet.java b/src/main/java/com/gitblit/SyndicationServlet.java
index bdb3b571..6b3c01ca 100644
--- a/src/main/java/com/gitblit/SyndicationServlet.java
+++ b/src/main/java/com/gitblit/SyndicationServlet.java
@@ -43,11 +43,11 @@ import com.gitblit.utils.SyndicationUtils;
/**
* SyndicationServlet generates RSS 2.0 feeds and feed links.
- *
+ *
* Access to this servlet is protected by the SyndicationFilter.
- *
+ *
* @author James Moger
- *
+ *
*/
public class SyndicationServlet extends HttpServlet {
@@ -57,7 +57,7 @@ public class SyndicationServlet extends HttpServlet {
/**
* Create a feed link for the specified repository and branch/tag/commit id.
- *
+ *
* @param baseURL
* @param repository
* the repository name
@@ -95,7 +95,7 @@ public class SyndicationServlet extends HttpServlet {
/**
* Determines the appropriate title for a feed.
- *
+ *
* @param repository
* @param objectId
* @return title of the feed
@@ -116,7 +116,7 @@ public class SyndicationServlet extends HttpServlet {
/**
* Generates the feed content.
- *
+ *
* @param request
* @param response
* @throws javax.servlet.ServletException
@@ -162,12 +162,12 @@ public class SyndicationServlet extends HttpServlet {
}
response.setContentType("application/rss+xml; charset=UTF-8");
-
+
boolean isProjectFeed = false;
String feedName = null;
String feedTitle = null;
String feedDescription = null;
-
+
List<String> repositories = null;
if (repositoryName.indexOf('/') == -1 && !repositoryName.toLowerCase().endsWith(".git")) {
// try to find a project
@@ -179,14 +179,14 @@ public class SyndicationServlet extends HttpServlet {
if (project != null) {
isProjectFeed = true;
repositories = new ArrayList<String>(project.repositories);
-
+
// project feed
feedName = project.name;
feedTitle = project.title;
feedDescription = project.description;
}
}
-
+
if (repositories == null) {
// could not find project, assume this is a repository
repositories = Arrays.asList(repositoryName);
@@ -214,7 +214,7 @@ public class SyndicationServlet extends HttpServlet {
if (repository == null) {
if (model.isCollectingGarbage) {
logger.warn(MessageFormat.format("Temporarily excluding {0} from feed, busy collecting garbage", name));
- }
+ }
continue;
}
if (!isProjectFeed) {
@@ -223,7 +223,7 @@ public class SyndicationServlet extends HttpServlet {
feedTitle = model.name;
feedDescription = model.description;
}
-
+
List<RevCommit> commits;
if (StringUtils.isEmpty(searchString)) {
// standard log/history lookup
@@ -248,7 +248,7 @@ public class SyndicationServlet extends HttpServlet {
commit.getFullMessage());
entry.content = message;
entry.repository = model.name;
- entry.branch = objectId;
+ entry.branch = objectId;
entry.tags = new ArrayList<String>();
// add commit id and parent commit ids
@@ -263,18 +263,18 @@ public class SyndicationServlet extends HttpServlet {
for (RefModel ref : refs) {
entry.tags.add("ref:" + ref.getName());
}
- }
+ }
entries.add(entry);
}
}
-
+
// sort & truncate the feed
Collections.sort(entries);
if (entries.size() > length) {
// clip the list
entries = entries.subList(0, length);
}
-
+
String feedLink;
if (isProjectFeed) {
// project feed
diff --git a/src/main/java/com/gitblit/WebXmlSettings.java b/src/main/java/com/gitblit/WebXmlSettings.java
index 7c8120b7..7ae26975 100644
--- a/src/main/java/com/gitblit/WebXmlSettings.java
+++ b/src/main/java/com/gitblit/WebXmlSettings.java
@@ -31,9 +31,9 @@ import com.gitblit.utils.StringUtils;
/**
* Loads Gitblit settings from the context-parameter values of a web.xml file.
- *
+ *
* @author James Moger
- *
+ *
*/
public class WebXmlSettings extends IStoredSettings {
@@ -54,7 +54,7 @@ public class WebXmlSettings extends IStoredSettings {
public void applyOverrides(File overrideFile) {
this.overrideFile = overrideFile;
-
+
// apply any web-configured overrides
if (overrideFile.exists()) {
try {
diff --git a/src/main/java/com/gitblit/WindowsUserService.java b/src/main/java/com/gitblit/WindowsUserService.java
index 4830297e..a65f44e1 100644
--- a/src/main/java/com/gitblit/WindowsUserService.java
+++ b/src/main/java/com/gitblit/WindowsUserService.java
@@ -36,7 +36,7 @@ import com.sun.jna.platform.win32.Win32Exception;
/**
* Implementation of a Windows user service.
- *
+ *
* @author James Moger
*/
public class WindowsUserService extends GitblitUserService {
@@ -44,7 +44,7 @@ public class WindowsUserService extends GitblitUserService {
private final Logger logger = LoggerFactory.getLogger(WindowsUserService.class);
private IStoredSettings settings;
-
+
private IWindowsAuthProvider waffle;
public WindowsUserService() {
@@ -60,7 +60,7 @@ public class WindowsUserService extends GitblitUserService {
serviceImpl = createUserService(realmFile);
logger.info("Windows User Service backed by " + serviceImpl.toString());
-
+
waffle = new WindowsAuthProviderImpl();
IWindowsComputer computer = waffle.getCurrentComputer();
logger.info(" name = " + computer.getComputerName());
@@ -68,7 +68,7 @@ public class WindowsUserService extends GitblitUserService {
logger.info(" memberOf = " + computer.getMemberOf());
//logger.info(" groups = " + Arrays.asList(computer.getGroups()));
}
-
+
protected String describeJoinStatus(String value) {
if ("NetSetupUnknownStatus".equals(value)) {
return "unknown";
@@ -101,7 +101,7 @@ public class WindowsUserService extends GitblitUserService {
public boolean supportsTeamMembershipChanges() {
return true;
}
-
+
@Override
protected AccountType getAccountType() {
return AccountType.WINDOWS;
@@ -150,7 +150,7 @@ public class WindowsUserService extends GitblitUserService {
identity.dispose();
return null;
}
-
+
UserModel user = getUserModel(username);
if (user == null) // create user object for new authenticated user
user = new UserModel(username.toLowerCase());
@@ -174,12 +174,12 @@ public class WindowsUserService extends GitblitUserService {
for (IWindowsAccount group : identity.getGroups()) {
groupNames.add(group.getFqn());
}
-
+
if (groupNames.contains("BUILTIN\\Administrators")) {
// local administrator
user.canAdmin = true;
}
-
+
// TODO consider mapping Windows groups to teams
// push the changes to the backing user service
@@ -188,7 +188,7 @@ public class WindowsUserService extends GitblitUserService {
// cleanup resources
identity.dispose();
-
+
return user;
}
}
diff --git a/src/main/java/com/gitblit/authority/AuthorityWorker.java b/src/main/java/com/gitblit/authority/AuthorityWorker.java
index 262bbb53..37a0df65 100644
--- a/src/main/java/com/gitblit/authority/AuthorityWorker.java
+++ b/src/main/java/com/gitblit/authority/AuthorityWorker.java
@@ -35,6 +35,7 @@ public abstract class AuthorityWorker extends SwingWorker<Boolean, Void> {
return doRequest();
}
+ @Override
protected void done() {
parent.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
try {
diff --git a/src/main/java/com/gitblit/authority/CertificateStatusRenderer.java b/src/main/java/com/gitblit/authority/CertificateStatusRenderer.java
index 7a708ea4..36c562aa 100644
--- a/src/main/java/com/gitblit/authority/CertificateStatusRenderer.java
+++ b/src/main/java/com/gitblit/authority/CertificateStatusRenderer.java
@@ -26,9 +26,9 @@ import com.gitblit.client.Translation;
/**
* Displays a subscribed icon on the left of the repository name, if there is at
* least one subscribed branch.
- *
+ *
* @author James Moger
- *
+ *
*/
public class CertificateStatusRenderer extends DefaultTableCellRenderer {
@@ -49,6 +49,7 @@ public class CertificateStatusRenderer extends DefaultTableCellRenderer {
okIcon = new ImageIcon(getClass().getResource("/bullet_green.png"));
}
+ @Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
diff --git a/src/main/java/com/gitblit/authority/CertificatesTableModel.java b/src/main/java/com/gitblit/authority/CertificatesTableModel.java
index 333836dd..bd99b243 100644
--- a/src/main/java/com/gitblit/authority/CertificatesTableModel.java
+++ b/src/main/java/com/gitblit/authority/CertificatesTableModel.java
@@ -28,16 +28,16 @@ import com.gitblit.utils.X509Utils.RevocationReason;
/**
* Table model of a list of user certificate models.
- *
+ *
* @author James Moger
- *
+ *
*/
public class CertificatesTableModel extends AbstractTableModel {
private static final long serialVersionUID = 1L;
UserCertificateModel ucm;
-
+
enum Columns {
SerialNumber, Status, Reason, Issued, Expires;
@@ -80,11 +80,12 @@ public class CertificatesTableModel extends AbstractTableModel {
/**
* Returns <code>Object.class</code> regardless of <code>columnIndex</code>.
- *
+ *
* @param columnIndex
* the column being queried
* @return the Object.class
*/
+ @Override
public Class<?> getColumnClass(int columnIndex) {
Columns col = Columns.values()[columnIndex];
switch (col) {
@@ -127,7 +128,7 @@ public class CertificatesTableModel extends AbstractTableModel {
if (ucm.getStatus(cert).equals(CertificateStatus.revoked)) {
RevocationReason r = ucm.getRevocationReason(cert.getSerialNumber());
return Translation.get("gb." + r.name());
- }
+ }
}
return null;
}
@@ -135,7 +136,7 @@ public class CertificatesTableModel extends AbstractTableModel {
public X509Certificate get(int modelRow) {
return ucm.certs.get(modelRow);
}
-
+
public void setUserCertificateModel(UserCertificateModel ucm) {
this.ucm = ucm;
if (ucm == null) {
diff --git a/src/main/java/com/gitblit/authority/DefaultOidsPanel.java b/src/main/java/com/gitblit/authority/DefaultOidsPanel.java
index 12b919fa..d52b99f9 100644
--- a/src/main/java/com/gitblit/authority/DefaultOidsPanel.java
+++ b/src/main/java/com/gitblit/authority/DefaultOidsPanel.java
@@ -24,9 +24,9 @@ import com.gitblit.client.Translation;
import com.gitblit.utils.X509Utils.X509Metadata;
public class DefaultOidsPanel extends JPanel {
-
+
private static final long serialVersionUID = 1L;
-
+
private JTextField organizationalUnit;
private JTextField organization;
private JTextField locality;
@@ -35,13 +35,13 @@ public class DefaultOidsPanel extends JPanel {
public DefaultOidsPanel(X509Metadata metadata) {
super();
-
+
organizationalUnit = new JTextField(metadata.getOID("OU", ""), 20);
organization = new JTextField(metadata.getOID("O", ""), 20);
locality = new JTextField(metadata.getOID("L", ""), 20);
stateProvince = new JTextField(metadata.getOID("ST", ""), 20);
countryCode = new JTextField(metadata.getOID("C", ""), 20);
-
+
setLayout(new GridLayout(0, 1, Utils.MARGIN, Utils.MARGIN));
add(Utils.newFieldPanel(Translation.get("gb.organizationalUnit") + " (OU)", organizationalUnit));
add(Utils.newFieldPanel(Translation.get("gb.organization") + " (O)", organization));
@@ -49,7 +49,7 @@ public class DefaultOidsPanel extends JPanel {
add(Utils.newFieldPanel(Translation.get("gb.stateProvince") + " (ST)", stateProvince));
add(Utils.newFieldPanel(Translation.get("gb.countryCode") + " (C)", countryCode));
}
-
+
public void update(X509Metadata metadata) {
metadata.setOID("OU", organizationalUnit.getText());
metadata.setOID("O", organization.getText());
@@ -57,15 +57,15 @@ public class DefaultOidsPanel extends JPanel {
metadata.setOID("ST", stateProvince.getText());
metadata.setOID("C", countryCode.getText());
}
-
+
public String getOrganizationalUnit() {
return organizationalUnit.getText();
}
-
+
public String getOrganization() {
return organization.getText();
}
-
+
public String getLocality() {
return locality.getText();
}
diff --git a/src/main/java/com/gitblit/authority/GitblitAuthority.java b/src/main/java/com/gitblit/authority/GitblitAuthority.java
index bddb1cfc..37088ae8 100644
--- a/src/main/java/com/gitblit/authority/GitblitAuthority.java
+++ b/src/main/java/com/gitblit/authority/GitblitAuthority.java
@@ -105,32 +105,32 @@ import com.gitblit.utils.X509Utils.X509Metadata;
/**
* Simple GUI tool for administering Gitblit client certificates.
- *
+ *
* @author James Moger
*
*/
public class GitblitAuthority extends JFrame implements X509Log {
private static final long serialVersionUID = 1L;
-
+
private final UserCertificateTableModel tableModel;
private UserCertificatePanel userCertificatePanel;
-
+
private File folder;
-
+
private IStoredSettings gitblitSettings;
-
+
private IUserService userService;
-
+
private String caKeystorePassword;
private JTable table;
-
+
private int defaultDuration;
-
+
private TableRowSorter<UserCertificateTableModel> defaultSorter;
-
+
private MailExecutor mail;
private JButton certificateDefaultsButton;
@@ -154,6 +154,7 @@ public class GitblitAuthority extends JFrame implements X509Log {
}
final String baseFolder = folder;
EventQueue.invokeLater(new Runnable() {
+ @Override
public void run() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
@@ -172,7 +173,7 @@ public class GitblitAuthority extends JFrame implements X509Log {
tableModel = new UserCertificateTableModel();
defaultSorter = new TableRowSorter<UserCertificateTableModel>(tableModel);
}
-
+
public void initialize(String baseFolder) {
setIconImage(new ImageIcon(getClass().getResource("/gitblt-favicon.png")).getImage());
setTitle("Gitblit Certificate Authority v" + Constants.getVersion() + " (" + Constants.getBuildDate() + ")");
@@ -187,14 +188,14 @@ public class GitblitAuthority extends JFrame implements X509Log {
@Override
public void windowOpened(WindowEvent event) {
}
- });
+ });
File folder = new File(baseFolder).getAbsoluteFile();
load(folder);
-
+
setSizeAndPosition();
}
-
+
private void setSizeAndPosition() {
String sz = null;
String pos = null;
@@ -243,14 +244,14 @@ public class GitblitAuthority extends JFrame implements X509Log {
Utils.showException(GitblitAuthority.this, t);
}
}
-
+
private StoredConfig getConfig() throws IOException, ConfigInvalidException {
File configFile = new File(folder, X509Utils.CA_CONFIG);
FileBasedConfig config = new FileBasedConfig(configFile, FS.detect());
config.load();
return config;
}
-
+
private IUserService loadUsers(File folder) {
File file = new File(folder, "gitblit.properties");
if (!file.exists()) {
@@ -271,11 +272,11 @@ public class GitblitAuthority extends JFrame implements X509Log {
} else {
throw new RuntimeException("Unsupported user service: " + us);
}
-
+
service = new ConfigUserService(FileUtils.resolveParameter(Constants.baseFolder$, folder, us));
return service;
}
-
+
private void load(File folder) {
this.folder = folder;
this.userService = loadUsers(folder);
@@ -287,7 +288,7 @@ public class GitblitAuthority extends JFrame implements X509Log {
Map<String, UserCertificateModel> map = new HashMap<String, UserCertificateModel>();
for (String user : userService.getAllUsernames()) {
UserModel model = userService.getUserModel(user);
- UserCertificateModel ucm = new UserCertificateModel(model);
+ UserCertificateModel ucm = new UserCertificateModel(model);
map.put(user, ucm);
}
File certificatesConfigFile = new File(folder, X509Utils.CA_CONFIG);
@@ -296,8 +297,8 @@ public class GitblitAuthority extends JFrame implements X509Log {
try {
config.load();
// replace user certificate model with actual data
- List<UserCertificateModel> list = UserCertificateConfig.KEY.parse(config).list;
- for (UserCertificateModel ucm : list) {
+ List<UserCertificateModel> list = UserCertificateConfig.KEY.parse(config).list;
+ for (UserCertificateModel ucm : list) {
ucm.user = userService.getUserModel(ucm.user.username);
map.put(ucm.user.username, ucm);
}
@@ -307,15 +308,15 @@ public class GitblitAuthority extends JFrame implements X509Log {
e.printStackTrace();
}
}
-
+
tableModel.list = new ArrayList<UserCertificateModel>(map.values());
Collections.sort(tableModel.list);
tableModel.fireTableDataChanged();
Utils.packColumns(table, Utils.MARGIN);
-
+
File caKeystore = new File(folder, X509Utils.CA_KEY_STORE);
if (!caKeystore.exists()) {
-
+
if (!X509Utils.unlimitedStrength) {
// prompt to confirm user understands JCE Standard Strength encryption
int res = JOptionPane.showConfirmDialog(GitblitAuthority.this, Translation.get("gb.jceWarning"),
@@ -332,16 +333,16 @@ public class GitblitAuthority extends JFrame implements X509Log {
System.exit(1);
}
}
-
- // show certificate defaults dialog
+
+ // show certificate defaults dialog
certificateDefaultsButton.doClick();
-
+
// create "localhost" ssl certificate
prepareX509Infrastructure();
}
}
}
-
+
private boolean prepareX509Infrastructure() {
if (caKeystorePassword == null) {
JPasswordField pass = new JPasswordField(10);
@@ -364,7 +365,7 @@ public class GitblitAuthority extends JFrame implements X509Log {
X509Utils.prepareX509Infrastructure(metadata, folder, this);
return true;
}
-
+
private List<X509Certificate> findCerts(File folder, String username) {
List<X509Certificate> list = new ArrayList<X509Certificate>();
File userFolder = new File(folder, X509Utils.CERTS + File.separator + username);
@@ -379,7 +380,7 @@ public class GitblitAuthority extends JFrame implements X509Log {
});
try {
CertificateFactory factory = CertificateFactory.getInstance("X.509");
- for (File cert : certs) {
+ for (File cert : certs) {
BufferedInputStream is = new BufferedInputStream(new FileInputStream(cert));
X509Certificate x509 = (X509Certificate) factory.generateCertificate(is);
is.close();
@@ -390,16 +391,16 @@ public class GitblitAuthority extends JFrame implements X509Log {
}
return list;
}
-
- private Container getUI() {
+
+ private Container getUI() {
userCertificatePanel = new UserCertificatePanel(this) {
-
+
private static final long serialVersionUID = 1L;
@Override
public Insets getInsets() {
return Utils.INSETS;
}
-
+
@Override
public boolean isAllowEmail() {
return mail.isReady();
@@ -415,12 +416,12 @@ public class GitblitAuthority extends JFrame implements X509Log {
c.set(Calendar.MILLISECOND, 0);
return c.getTime();
}
-
+
@Override
public boolean saveUser(String username, UserCertificateModel ucm) {
return userService.updateUserModel(username, ucm.user);
}
-
+
@Override
public boolean newCertificate(UserCertificateModel ucm, X509Metadata metadata, boolean sendEmail) {
if (!prepareX509Infrastructure()) {
@@ -430,9 +431,9 @@ public class GitblitAuthority extends JFrame implements X509Log {
Date notAfter = metadata.notAfter;
setMetadataDefaults(metadata);
metadata.notAfter = notAfter;
-
+
// set user's specified OID values
- UserModel user = ucm.user;
+ UserModel user = ucm.user;
if (!StringUtils.isEmpty(user.organizationalUnit)) {
metadata.oids.put("OU", user.organizationalUnit);
}
@@ -456,21 +457,21 @@ public class GitblitAuthority extends JFrame implements X509Log {
if (ucm.expires == null || metadata.notAfter.before(ucm.expires)) {
ucm.expires = metadata.notAfter;
}
-
+
updateAuthorityConfig(ucm);
-
+
// refresh user
ucm.certs = null;
int selectedIndex = table.getSelectedRow();
tableModel.fireTableDataChanged();
table.getSelectionModel().setSelectionInterval(selectedIndex, selectedIndex);
-
+
if (sendEmail) {
sendEmail(user, metadata, zip);
}
return true;
}
-
+
@Override
public boolean revoke(UserCertificateModel ucm, X509Certificate cert, RevocationReason reason) {
if (!prepareX509Infrastructure()) {
@@ -497,20 +498,20 @@ public class GitblitAuthority extends JFrame implements X509Log {
} catch (Exception e) {
Utils.showException(GitblitAuthority.this, e);
}
-
+
// refresh user
ucm.certs = null;
int modelIndex = table.convertRowIndexToModel(table.getSelectedRow());
tableModel.fireTableDataChanged();
table.getSelectionModel().setSelectionInterval(modelIndex, modelIndex);
-
+
return true;
}
-
+
return false;
}
};
-
+
table = Utils.newTable(tableModel, Utils.DATE_FORMAT);
table.setRowSorter(defaultSorter);
table.setDefaultRenderer(CertificateStatus.class, new CertificateStatusRenderer());
@@ -533,9 +534,9 @@ public class GitblitAuthority extends JFrame implements X509Log {
userCertificatePanel.setUserCertificateModel(ucm);
}
});
-
+
JPanel usersPanel = new JPanel(new BorderLayout()) {
-
+
private static final long serialVersionUID = 1L;
@Override
@@ -546,10 +547,10 @@ public class GitblitAuthority extends JFrame implements X509Log {
usersPanel.add(new HeaderPanel(Translation.get("gb.users"), "users_16x16.png"), BorderLayout.NORTH);
usersPanel.add(new JScrollPane(table), BorderLayout.CENTER);
usersPanel.setMinimumSize(new Dimension(400, 10));
-
+
certificateDefaultsButton = new JButton(new ImageIcon(getClass().getResource("/settings_16x16.png")));
certificateDefaultsButton.setFocusable(false);
- certificateDefaultsButton.setToolTipText(Translation.get("gb.newCertificateDefaults"));
+ certificateDefaultsButton.setToolTipText(Translation.get("gb.newCertificateDefaults"));
certificateDefaultsButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
@@ -567,6 +568,7 @@ public class GitblitAuthority extends JFrame implements X509Log {
certificateConfig.update(metadata);
}
InputVerifier verifier = new InputVerifier() {
+ @Override
public boolean verify(JComponent comp) {
boolean returnValue;
JTextField textField = (JTextField) comp;
@@ -591,18 +593,18 @@ public class GitblitAuthority extends JFrame implements X509Log {
validityTF.setText("" + certificateConfig.duration);
JPanel validityPanel = Utils.newFieldPanel(Translation.get("gb.validity"),
validityTF, Translation.get("gb.duration.days").replace("{0}", "").trim());
-
+
JPanel p1 = new JPanel(new GridLayout(0, 1, 5, 2));
p1.add(siteNamePanel);
p1.add(validityPanel);
-
+
DefaultOidsPanel oids = new DefaultOidsPanel(metadata);
JPanel panel = new JPanel(new BorderLayout());
panel.add(p1, BorderLayout.NORTH);
panel.add(oids, BorderLayout.CENTER);
- int result = JOptionPane.showConfirmDialog(GitblitAuthority.this,
+ int result = JOptionPane.showConfirmDialog(GitblitAuthority.this,
panel, Translation.get("gb.newCertificateDefaults"), JOptionPane.OK_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE, new ImageIcon(getClass().getResource("/settings_32x32.png")));
if (result == JOptionPane.OK_OPTION) {
@@ -611,7 +613,7 @@ public class GitblitAuthority extends JFrame implements X509Log {
certificateConfig.duration = Integer.parseInt(validityTF.getText());
certificateConfig.store(config, metadata);
config.save();
-
+
Map<String, String> updates = new HashMap<String, String>();
updates.put(Keys.web.siteName, siteNameTF.getText());
gitblitSettings.saveSettings(updates);
@@ -621,10 +623,10 @@ public class GitblitAuthority extends JFrame implements X509Log {
}
}
});
-
+
newSSLCertificate = new JButton(new ImageIcon(getClass().getResource("/rosette_16x16.png")));
newSSLCertificate.setFocusable(false);
- newSSLCertificate.setToolTipText(Translation.get("gb.newSSLCertificate"));
+ newSSLCertificate.setToolTipText(Translation.get("gb.newSSLCertificate"));
newSSLCertificate.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
@@ -638,7 +640,7 @@ public class GitblitAuthority extends JFrame implements X509Log {
final Date expires = dialog.getExpiration();
final String hostname = dialog.getHostname();
final boolean serveCertificate = dialog.isServeCertificate();
-
+
AuthorityWorker worker = new AuthorityWorker(GitblitAuthority.this) {
@Override
@@ -646,12 +648,12 @@ public class GitblitAuthority extends JFrame implements X509Log {
if (!prepareX509Infrastructure()) {
return false;
}
-
+
// read CA private key and certificate
File caKeystoreFile = new File(folder, X509Utils.CA_KEY_STORE);
PrivateKey caPrivateKey = X509Utils.getPrivateKey(X509Utils.CA_ALIAS, caKeystoreFile, caKeystorePassword);
X509Certificate caCert = X509Utils.getCertificate(X509Utils.CA_ALIAS, caKeystoreFile, caKeystorePassword);
-
+
// generate new SSL certificate
X509Metadata metadata = new X509Metadata(hostname, caKeystorePassword);
setMetadataDefaults(metadata);
@@ -671,24 +673,24 @@ public class GitblitAuthority extends JFrame implements X509Log {
@Override
protected void onSuccess() {
if (serveCertificate) {
- JOptionPane.showMessageDialog(GitblitAuthority.this,
+ JOptionPane.showMessageDialog(GitblitAuthority.this,
MessageFormat.format(Translation.get("gb.sslCertificateGeneratedRestart"), hostname),
Translation.get("gb.newSSLCertificate"), JOptionPane.INFORMATION_MESSAGE);
} else {
- JOptionPane.showMessageDialog(GitblitAuthority.this,
+ JOptionPane.showMessageDialog(GitblitAuthority.this,
MessageFormat.format(Translation.get("gb.sslCertificateGenerated"), hostname),
Translation.get("gb.newSSLCertificate"), JOptionPane.INFORMATION_MESSAGE);
}
}
};
-
+
worker.execute();
}
});
-
+
JButton emailBundle = new JButton(new ImageIcon(getClass().getResource("/mail_16x16.png")));
emailBundle.setFocusable(false);
- emailBundle.setToolTipText(Translation.get("gb.emailCertificateBundle"));
+ emailBundle.setToolTipText(Translation.get("gb.emailCertificateBundle"));
emailBundle.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
@@ -705,7 +707,7 @@ public class GitblitAuthority extends JFrame implements X509Log {
if (!zip.exists()) {
return;
}
-
+
AuthorityWorker worker = new AuthorityWorker(GitblitAuthority.this) {
@Override
protected Boolean doRequest() throws IOException {
@@ -723,15 +725,15 @@ public class GitblitAuthority extends JFrame implements X509Log {
JOptionPane.showMessageDialog(GitblitAuthority.this, MessageFormat.format(Translation.get("gb.clientCertificateBundleSent"),
ucm.user.getDisplayName()));
}
-
+
};
- worker.execute();
+ worker.execute();
}
});
-
+
JButton logButton = new JButton(new ImageIcon(getClass().getResource("/script_16x16.png")));
logButton.setFocusable(false);
- logButton.setToolTipText(Translation.get("gb.log"));
+ logButton.setToolTipText(Translation.get("gb.log"));
logButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
@@ -745,19 +747,21 @@ public class GitblitAuthority extends JFrame implements X509Log {
}
}
});
-
+
final JTextField filterTextfield = new JTextField(15);
filterTextfield.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
filterUsers(filterTextfield.getText());
}
});
filterTextfield.addKeyListener(new KeyAdapter() {
+ @Override
public void keyReleased(KeyEvent e) {
filterUsers(filterTextfield.getText());
}
});
-
+
JToolBar buttonControls = new JToolBar(JToolBar.HORIZONTAL);
buttonControls.setFloatable(false);
buttonControls.add(certificateDefaultsButton);
@@ -768,17 +772,17 @@ public class GitblitAuthority extends JFrame implements X509Log {
JPanel userControls = new JPanel(new FlowLayout(FlowLayout.RIGHT, Utils.MARGIN, Utils.MARGIN));
userControls.add(new JLabel(Translation.get("gb.filter")));
userControls.add(filterTextfield);
-
+
JPanel topPanel = new JPanel(new BorderLayout(0, 0));
topPanel.add(buttonControls, BorderLayout.WEST);
topPanel.add(userControls, BorderLayout.EAST);
-
+
JPanel leftPanel = new JPanel(new BorderLayout());
leftPanel.add(topPanel, BorderLayout.NORTH);
leftPanel.add(usersPanel, BorderLayout.CENTER);
-
+
userCertificatePanel.setMinimumSize(new Dimension(375, 10));
-
+
JLabel statusLabel = new JLabel();
statusLabel.setHorizontalAlignment(SwingConstants.RIGHT);
if (X509Utils.unlimitedStrength) {
@@ -786,9 +790,10 @@ public class GitblitAuthority extends JFrame implements X509Log {
} else {
statusLabel.setText("JCE Standard Encryption Policy");
}
-
+
JPanel root = new JPanel(new BorderLayout()) {
private static final long serialVersionUID = 1L;
+ @Override
public Insets getInsets() {
return Utils.INSETS;
}
@@ -799,7 +804,7 @@ public class GitblitAuthority extends JFrame implements X509Log {
root.add(statusLabel, BorderLayout.SOUTH);
return root;
}
-
+
private void filterUsers(final String fragment) {
table.clearSelection();
userCertificatePanel.setUserCertificateModel(null);
@@ -808,6 +813,7 @@ public class GitblitAuthority extends JFrame implements X509Log {
return;
}
RowFilter<UserCertificateTableModel, Object> containsFilter = new RowFilter<UserCertificateTableModel, Object>() {
+ @Override
public boolean include(Entry<? extends UserCertificateTableModel, ? extends Object> entry) {
for (int i = entry.getValueCount() - 1; i >= 0; i--) {
if (entry.getStringValue(i).toLowerCase().contains(fragment.toLowerCase())) {
@@ -822,7 +828,7 @@ public class GitblitAuthority extends JFrame implements X509Log {
sorter.setRowFilter(containsFilter);
table.setRowSorter(sorter);
}
-
+
@Override
public void log(String message) {
BufferedWriter writer = null;
@@ -842,7 +848,7 @@ public class GitblitAuthority extends JFrame implements X509Log {
}
}
}
-
+
private boolean sendEmail(UserModel user, X509Metadata metadata, File zip) {
// send email
try {
@@ -879,13 +885,13 @@ public class GitblitAuthority extends JFrame implements X509Log {
}
return false;
}
-
+
private void setMetadataDefaults(X509Metadata metadata) {
metadata.serverHostname = gitblitSettings.getString(Keys.web.siteName, Constants.NAME);
if (StringUtils.isEmpty(metadata.serverHostname)) {
metadata.serverHostname = Constants.NAME;
}
-
+
// set default values from config file
File certificatesConfigFile = new File(folder, X509Utils.CA_CONFIG);
FileBasedConfig config = new FileBasedConfig(certificatesConfigFile, FS.detect());
@@ -899,7 +905,7 @@ public class GitblitAuthority extends JFrame implements X509Log {
certificateConfig.update(metadata);
}
}
-
+
private void updateAuthorityConfig(UserCertificateModel ucm) {
File certificatesConfigFile = new File(folder, X509Utils.CA_CONFIG);
FileBasedConfig config = new FileBasedConfig(certificatesConfigFile, FS.detect());
diff --git a/src/main/java/com/gitblit/authority/Launcher.java b/src/main/java/com/gitblit/authority/Launcher.java
index 1da97149..bffeb68e 100644
--- a/src/main/java/com/gitblit/authority/Launcher.java
+++ b/src/main/java/com/gitblit/authority/Launcher.java
@@ -37,9 +37,9 @@ import com.gitblit.client.Translation;
/**
* Downloads dependencies and launches Gitblit Authority.
- *
+ *
* @author James Moger
- *
+ *
*/
public class Launcher {
@@ -53,10 +53,10 @@ public class Launcher {
public static void main(String[] args) {
final SplashScreen splash = SplashScreen.getSplashScreen();
-
+
File libFolder = new File("ext");
List<File> jars = findJars(libFolder.getAbsoluteFile());
-
+
// sort the jars by name and then reverse the order so the newer version
// of the library gets loaded in the event that this is an upgrade
Collections.sort(jars);
@@ -69,7 +69,7 @@ public class Launcher {
}
}
-
+
updateSplash(splash, Translation.get("gb.starting") + " Gitblit Authority...");
GitblitAuthority.main(args);
}
@@ -80,12 +80,13 @@ public class Launcher {
}
try {
EventQueue.invokeAndWait(new Runnable() {
+ @Override
public void run() {
Graphics2D g = splash.createGraphics();
if (g != null) {
// Splash is 320x120
FontMetrics fm = g.getFontMetrics();
-
+
// paint startup status
g.setColor(Color.darkGray);
int h = fm.getHeight() + fm.getMaxDescent();
@@ -98,7 +99,7 @@ public class Launcher {
g.setColor(Color.WHITE);
int xw = fm.stringWidth(string);
g.drawString(string, x + ((w - xw) / 2), y - 5);
-
+
// paint version
String ver = "v" + Constants.getVersion();
int vw = g.getFontMetrics().stringWidth(ver);
@@ -112,7 +113,7 @@ public class Launcher {
t.printStackTrace();
}
}
-
+
public static List<File> findJars(File folder) {
List<File> jars = new ArrayList<File>();
if (folder.exists()) {
@@ -137,7 +138,7 @@ public class Launcher {
/**
* Adds a file to the classpath
- *
+ *
* @param f
* the file to be added
* @throws IOException
diff --git a/src/main/java/com/gitblit/authority/NewCertificateConfig.java b/src/main/java/com/gitblit/authority/NewCertificateConfig.java
index ca047c82..b6ba6e68 100644
--- a/src/main/java/com/gitblit/authority/NewCertificateConfig.java
+++ b/src/main/java/com/gitblit/authority/NewCertificateConfig.java
@@ -26,11 +26,12 @@ import com.gitblit.utils.X509Utils.X509Metadata;
/**
* Certificate config file parser.
- *
+ *
* @author James Moger
*/
public class NewCertificateConfig {
public static final SectionParser<NewCertificateConfig> KEY = new SectionParser<NewCertificateConfig>() {
+ @Override
public NewCertificateConfig parse(final Config cfg) {
return new NewCertificateConfig(cfg);
}
@@ -41,18 +42,18 @@ public class NewCertificateConfig {
public String L;
public String ST;
public String C;
-
+
public int duration;
-
+
private NewCertificateConfig(final Config c) {
duration = c.getInt("new", null, "duration", 0);
OU = c.getString("new", null, "organizationalUnit");
O = c.getString("new", null, "organization");
L = c.getString("new", null, "locality");
ST = c.getString("new", null, "stateProvince");
- C = c.getString("new", null, "countryCode");
+ C = c.getString("new", null, "countryCode");
}
-
+
public void update(X509Metadata metadata) {
update(metadata, "OU", OU);
update(metadata, "O", O);
@@ -63,13 +64,13 @@ public class NewCertificateConfig {
metadata.notAfter = new Date(System.currentTimeMillis() + duration*TimeUtils.ONEDAY);
}
}
-
+
private void update(X509Metadata metadata, String oid, String value) {
if (!StringUtils.isEmpty(value)) {
metadata.oids.put(oid, value);
}
}
-
+
public void store(Config c, X509Metadata metadata) {
store(c, "new", "organizationalUnit", metadata.getOID("OU", null));
store(c, "new", "organization", metadata.getOID("O", null));
@@ -82,7 +83,7 @@ public class NewCertificateConfig {
c.setInt("new", null, "duration", duration);
}
}
-
+
private void store(Config c, String section, String name, String value) {
if (StringUtils.isEmpty(value)) {
c.unset(section, null, name);
diff --git a/src/main/java/com/gitblit/authority/NewClientCertificateDialog.java b/src/main/java/com/gitblit/authority/NewClientCertificateDialog.java
index 3d214390..3d8ea7e7 100644
--- a/src/main/java/com/gitblit/authority/NewClientCertificateDialog.java
+++ b/src/main/java/com/gitblit/authority/NewClientCertificateDialog.java
@@ -45,7 +45,7 @@ import com.toedter.calendar.JDateChooser;
public class NewClientCertificateDialog extends JDialog {
private static final long serialVersionUID = 1L;
-
+
JDateChooser expirationDate;
JPasswordField pw1;
JPasswordField pw2;
@@ -55,47 +55,48 @@ public class NewClientCertificateDialog extends JDialog {
public NewClientCertificateDialog(Frame owner, String displayname, Date defaultExpiration, boolean allowEmail) {
super(owner);
-
+
setTitle(Translation.get("gb.newCertificate"));
-
- JPanel content = new JPanel(new BorderLayout(Utils.MARGIN, Utils.MARGIN)) {
+
+ JPanel content = new JPanel(new BorderLayout(Utils.MARGIN, Utils.MARGIN)) {
private static final long serialVersionUID = 1L;
@Override
public Insets getInsets() {
-
+
return Utils.INSETS;
}
};
-
+
expirationDate = new JDateChooser(defaultExpiration);
pw1 = new JPasswordField(20);
pw2 = new JPasswordField(20);
hint = new JTextField(20);
sendEmail = new JCheckBox(Translation.get("gb.sendEmail"));
-
+
JPanel panel = new JPanel(new GridLayout(0, 2, Utils.MARGIN, Utils.MARGIN));
-
+
panel.add(new JLabel(Translation.get("gb.expires")));
panel.add(expirationDate);
-
+
panel.add(new JLabel(Translation.get("gb.password")));
panel.add(pw1);
panel.add(new JLabel(Translation.get("gb.confirmPassword")));
panel.add(pw2);
-
+
panel.add(new JLabel(Translation.get("gb.passwordHint")));
panel.add(hint);
-
+
if (allowEmail) {
panel.add(new JLabel(""));
panel.add(sendEmail);
}
-
+
JButton ok = new JButton(Translation.get("gb.ok"));
ok.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
if (validateInputs()) {
isCanceled = false;
@@ -105,34 +106,35 @@ public class NewClientCertificateDialog extends JDialog {
});
JButton cancel = new JButton(Translation.get("gb.cancel"));
cancel.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
isCanceled = true;
setVisible(false);
}
});
-
+
JPanel controls = new JPanel();
controls.add(ok);
controls.add(cancel);
-
+
JTextArea message = new JTextArea(Translation.get("gb.newClientCertificateMessage"));
message.setLineWrap(true);
message.setWrapStyleWord(true);
message.setEditable(false);
message.setRows(6);
message.setPreferredSize(new Dimension(300, 100));
-
+
content.add(new JScrollPane(message), BorderLayout.CENTER);
content.add(panel, BorderLayout.NORTH);
content.add(controls, BorderLayout.SOUTH);
-
+
getContentPane().add(new HeaderPanel(Translation.get("gb.newCertificate") + " (" + displayname + ")", "rosette_16x16.png"), BorderLayout.NORTH);
getContentPane().add(content, BorderLayout.CENTER);
pack();
-
+
setLocationRelativeTo(owner);
}
-
+
private boolean validateInputs() {
if (getExpiration().getTime() < System.currentTimeMillis()) {
// expires before now
@@ -154,23 +156,23 @@ public class NewClientCertificateDialog extends JDialog {
}
return true;
}
-
+
public String getPassword() {
return new String(pw1.getPassword());
}
-
+
public String getPasswordHint() {
return hint.getText();
}
-
+
public Date getExpiration() {
return expirationDate.getDate();
}
-
+
public boolean sendEmail() {
return sendEmail.isSelected();
}
-
+
public boolean isCanceled() {
return isCanceled;
}
diff --git a/src/main/java/com/gitblit/authority/NewSSLCertificateDialog.java b/src/main/java/com/gitblit/authority/NewSSLCertificateDialog.java
index 821e9e9f..654e4637 100644
--- a/src/main/java/com/gitblit/authority/NewSSLCertificateDialog.java
+++ b/src/main/java/com/gitblit/authority/NewSSLCertificateDialog.java
@@ -39,7 +39,7 @@ import com.toedter.calendar.JDateChooser;
public class NewSSLCertificateDialog extends JDialog {
private static final long serialVersionUID = 1L;
-
+
JDateChooser expirationDate;
JTextField hostname;
JCheckBox serveCertificate;
@@ -47,36 +47,37 @@ public class NewSSLCertificateDialog extends JDialog {
public NewSSLCertificateDialog(Frame owner, Date defaultExpiration) {
super(owner);
-
+
setTitle(Translation.get("gb.newSSLCertificate"));
-
- JPanel content = new JPanel(new BorderLayout(Utils.MARGIN, Utils.MARGIN)) {
+
+ JPanel content = new JPanel(new BorderLayout(Utils.MARGIN, Utils.MARGIN)) {
private static final long serialVersionUID = 1L;
@Override
public Insets getInsets() {
-
+
return Utils.INSETS;
}
};
-
+
expirationDate = new JDateChooser(defaultExpiration);
hostname = new JTextField(20);
serveCertificate = new JCheckBox(Translation.get("gb.serveCertificate"), true);
-
+
JPanel panel = new JPanel(new GridLayout(0, 2, Utils.MARGIN, Utils.MARGIN));
-
+
panel.add(new JLabel(Translation.get("gb.hostname")));
panel.add(hostname);
panel.add(new JLabel(Translation.get("gb.expires")));
panel.add(expirationDate);
-
+
panel.add(new JLabel(""));
panel.add(serveCertificate);
-
+
JButton ok = new JButton(Translation.get("gb.ok"));
ok.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
if (validateInputs()) {
isCanceled = false;
@@ -86,26 +87,27 @@ public class NewSSLCertificateDialog extends JDialog {
});
JButton cancel = new JButton(Translation.get("gb.cancel"));
cancel.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
isCanceled = true;
setVisible(false);
}
});
-
+
JPanel controls = new JPanel();
controls.add(ok);
controls.add(cancel);
content.add(panel, BorderLayout.CENTER);
content.add(controls, BorderLayout.SOUTH);
-
+
getContentPane().add(new HeaderPanel(Translation.get("gb.newSSLCertificate"), "rosette_16x16.png"), BorderLayout.NORTH);
getContentPane().add(content, BorderLayout.CENTER);
pack();
-
+
setLocationRelativeTo(owner);
}
-
+
private boolean validateInputs() {
if (getExpiration().getTime() < System.currentTimeMillis()) {
// expires before now
@@ -121,11 +123,11 @@ public class NewSSLCertificateDialog extends JDialog {
}
return true;
}
-
+
public String getHostname() {
return hostname.getText();
}
-
+
public Date getExpiration() {
return expirationDate.getDate();
}
diff --git a/src/main/java/com/gitblit/authority/RequestFocusListener.java b/src/main/java/com/gitblit/authority/RequestFocusListener.java
index 82eba6a0..bb7f1427 100644
--- a/src/main/java/com/gitblit/authority/RequestFocusListener.java
+++ b/src/main/java/com/gitblit/authority/RequestFocusListener.java
@@ -34,7 +34,7 @@ import javax.swing.event.AncestorListener;
* allows you to specify a boolean value of false to prevent the
* AncestorListener from being removed when the event is generated. This will
* allow you to reuse the listener each time the event is generated.
- *
+ *
* @author Rob Camick
*/
public class RequestFocusListener implements AncestorListener
diff --git a/src/main/java/com/gitblit/authority/UserCertificateConfig.java b/src/main/java/com/gitblit/authority/UserCertificateConfig.java
index 5ec76f77..411b88ab 100644
--- a/src/main/java/com/gitblit/authority/UserCertificateConfig.java
+++ b/src/main/java/com/gitblit/authority/UserCertificateConfig.java
@@ -30,35 +30,36 @@ import com.gitblit.models.UserModel;
/**
* User certificate config section parser.
- *
+ *
* @author James Moger
*/
public class UserCertificateConfig {
public static final SectionParser<UserCertificateConfig> KEY = new SectionParser<UserCertificateConfig>() {
- public UserCertificateConfig parse(final Config cfg) {
+ @Override
+ public UserCertificateConfig parse(final Config cfg) {
return new UserCertificateConfig(cfg);
}
};
-
+
public final List<UserCertificateModel> list;
private UserCertificateConfig(final Config c) {
SimpleDateFormat df = new SimpleDateFormat(Constants.ISO8601);
- list = new ArrayList<UserCertificateModel>();
+ list = new ArrayList<UserCertificateModel>();
for (String username : c.getSubsections("user")) {
UserCertificateModel uc = new UserCertificateModel(new UserModel(username));
try {
uc.expires = df.parse(c.getString("user", username, "expires"));
} catch (ParseException e) {
LoggerFactory.getLogger(UserCertificateConfig.class).error("Failed to parse date!", e);
- } catch (NullPointerException e) {
+ } catch (NullPointerException e) {
}
uc.notes = c.getString("user", username, "notes");
- uc.revoked = new ArrayList<String>(Arrays.asList(c.getStringList("user", username, "revoked")));
+ uc.revoked = new ArrayList<String>(Arrays.asList(c.getStringList("user", username, "revoked")));
list.add(uc);
}
}
-
+
public UserCertificateModel getUserCertificateModel(String username) {
for (UserCertificateModel ucm : list) {
if (ucm.user.username.equalsIgnoreCase(username)) {
diff --git a/src/main/java/com/gitblit/authority/UserCertificateModel.java b/src/main/java/com/gitblit/authority/UserCertificateModel.java
index 6c69a93b..446b4f60 100644
--- a/src/main/java/com/gitblit/authority/UserCertificateModel.java
+++ b/src/main/java/com/gitblit/authority/UserCertificateModel.java
@@ -41,7 +41,7 @@ public class UserCertificateModel implements Comparable<UserCertificateModel> {
public UserCertificateModel(UserModel user) {
this.user = user;
}
-
+
public void update(Config config) {
if (expires == null) {
config.unset("user", user.username, "expires");
@@ -65,7 +65,7 @@ public class UserCertificateModel implements Comparable<UserCertificateModel> {
public int compareTo(UserCertificateModel o) {
return user.compareTo(o.user);
}
-
+
public void revoke(BigInteger serial, RevocationReason reason) {
if (revoked == null) {
revoked = new ArrayList<String>();
@@ -82,7 +82,7 @@ public class UserCertificateModel implements Comparable<UserCertificateModel> {
}
}
}
-
+
public boolean isRevoked(BigInteger serial) {
return isRevoked(serial.toString());
}
@@ -99,7 +99,7 @@ public class UserCertificateModel implements Comparable<UserCertificateModel> {
}
return false;
}
-
+
public RevocationReason getRevocationReason(BigInteger serial) {
try {
String sn = serial + ":";
@@ -114,7 +114,7 @@ public class UserCertificateModel implements Comparable<UserCertificateModel> {
}
return RevocationReason.unspecified;
}
-
+
public CertificateStatus getStatus() {
if (expires == null) {
return CertificateStatus.unknown;
@@ -140,11 +140,11 @@ public class UserCertificateModel implements Comparable<UserCertificateModel> {
}
return CertificateStatus.ok;
}
-
+
private boolean isExpiring(Date date) {
return (date.getTime() - System.currentTimeMillis()) <= TimeUtils.ONEDAY * 30;
}
-
+
private boolean isExpired(Date date) {
return date.getTime() < System.currentTimeMillis();
}
diff --git a/src/main/java/com/gitblit/authority/UserCertificatePanel.java b/src/main/java/com/gitblit/authority/UserCertificatePanel.java
index 0c49252c..6ee281da 100644
--- a/src/main/java/com/gitblit/authority/UserCertificatePanel.java
+++ b/src/main/java/com/gitblit/authority/UserCertificatePanel.java
@@ -46,13 +46,13 @@ import com.gitblit.utils.X509Utils.X509Metadata;
public abstract class UserCertificatePanel extends JPanel {
private static final long serialVersionUID = 1L;
-
+
private Frame owner;
-
+
private UserCertificateModel ucm;
-
+
private UserOidsPanel oidsPanel;
-
+
private CertificatesTableModel tableModel;
private JButton saveUserButton;
@@ -60,27 +60,28 @@ public abstract class UserCertificatePanel extends JPanel {
private JButton editUserButton;
private JButton newCertificateButton;
-
+
private JButton revokeCertificateButton;
private JTable table;
-
+
public UserCertificatePanel(Frame owner) {
super(new BorderLayout());
-
+
this.owner = owner;
oidsPanel = new UserOidsPanel();
-
+
JPanel fp = new JPanel(new BorderLayout(Utils.MARGIN, Utils.MARGIN));
fp.add(oidsPanel, BorderLayout.NORTH);
-
+
JPanel fieldsPanel = new JPanel(new BorderLayout());
fieldsPanel.add(new HeaderPanel(Translation.get("gb.properties"), "vcard_16x16.png"), BorderLayout.NORTH);
fieldsPanel.add(fp, BorderLayout.CENTER);
-
+
saveUserButton = new JButton(Translation.get("gb.save"));
saveUserButton.setEnabled(false);
saveUserButton.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
setEditable(false);
String username = ucm.user.username;
@@ -88,22 +89,23 @@ public abstract class UserCertificatePanel extends JPanel {
saveUser(username, ucm);
}
});
-
+
editUserButton = new JButton(Translation.get("gb.edit"));
editUserButton.setEnabled(false);
editUserButton.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
setEditable(true);
}
});
-
+
JPanel userControls = new JPanel(new FlowLayout(FlowLayout.LEFT));
userControls.add(editUserButton);
userControls.add(saveUserButton);
fieldsPanel.add(userControls, BorderLayout.SOUTH);
-
+
JPanel certificatesPanel = new JPanel(new BorderLayout());
- certificatesPanel.add(new HeaderPanel(Translation.get("gb.certificates"), "rosette_16x16.png"), BorderLayout.NORTH);
+ certificatesPanel.add(new HeaderPanel(Translation.get("gb.certificates"), "rosette_16x16.png"), BorderLayout.NORTH);
tableModel = new CertificatesTableModel();
table = Utils.newTable(tableModel, Utils.DATE_FORMAT);
table.setRowSorter(new TableRowSorter<CertificatesTableModel>(tableModel));
@@ -125,21 +127,23 @@ public abstract class UserCertificatePanel extends JPanel {
}
});
table.addMouseListener(new MouseAdapter() {
+ @Override
public void mouseClicked(MouseEvent e) {
- if (e.getClickCount() == 2) {
+ if (e.getClickCount() == 2) {
int row = table.rowAtPoint(e.getPoint());
int modelIndex = table.convertRowIndexToModel(row);
X509Certificate cert = tableModel.get(modelIndex);
- X509CertificateViewer viewer = new X509CertificateViewer(UserCertificatePanel.this.owner, cert);
+ X509CertificateViewer viewer = new X509CertificateViewer(UserCertificatePanel.this.owner, cert);
viewer.setVisible(true);
}
}
});
certificatesPanel.add(new JScrollPane(table), BorderLayout.CENTER);
-
+
newCertificateButton = new JButton(Translation.get("gb.newCertificate"));
newCertificateButton.setEnabled(false);
newCertificateButton.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
try {
if (saveUserButton.isEnabled()) {
@@ -149,7 +153,7 @@ public abstract class UserCertificatePanel extends JPanel {
oidsPanel.updateUser(ucm);
saveUser(username, ucm);
}
-
+
NewClientCertificateDialog dialog = new NewClientCertificateDialog(UserCertificatePanel.this.owner,
ucm.user.getDisplayName(), getDefaultExpiration(), isAllowEmail());
dialog.setModal(true);
@@ -162,7 +166,7 @@ public abstract class UserCertificatePanel extends JPanel {
final UserModel user = ucm.user;
final X509Metadata metadata = new X509Metadata(user.username, dialog.getPassword());
metadata.userDisplayname = user.getDisplayName();
- metadata.emailAddress = user.emailAddress;
+ metadata.emailAddress = user.emailAddress;
metadata.passwordHint = dialog.getPasswordHint();
metadata.notAfter = dialog.getExpiration();
@@ -174,21 +178,22 @@ public abstract class UserCertificatePanel extends JPanel {
@Override
protected void onSuccess() {
- JOptionPane.showMessageDialog(UserCertificatePanel.this.owner,
+ JOptionPane.showMessageDialog(UserCertificatePanel.this.owner,
MessageFormat.format(Translation.get("gb.clientCertificateGenerated"), user.getDisplayName()),
Translation.get("gb.newCertificate"), JOptionPane.INFORMATION_MESSAGE);
}
};
- worker.execute();
+ worker.execute();
} catch (Exception x) {
Utils.showException(UserCertificatePanel.this, x);
}
}
});
-
+
revokeCertificateButton = new JButton(Translation.get("gb.revokeCertificate"));
revokeCertificateButton.setEnabled(false);
revokeCertificateButton.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
try {
int row = table.getSelectedRow();
@@ -197,12 +202,12 @@ public abstract class UserCertificatePanel extends JPanel {
}
int modelIndex = table.convertRowIndexToModel(row);
final X509Certificate cert = tableModel.get(modelIndex);
-
+
String [] choices = new String[RevocationReason.reasons.length];
for (int i = 0; i < choices.length; i++) {
choices[i] = Translation.get("gb." + RevocationReason.reasons[i].name());
}
-
+
Object choice = JOptionPane.showInputDialog(UserCertificatePanel.this.owner,
Translation.get("gb.revokeCertificateReason"), Translation.get("gb.revokeCertificate"),
JOptionPane.PLAIN_MESSAGE, new ImageIcon(getClass().getResource("/rosette_32x32.png")), choices, Translation.get("gb.unspecified"));
@@ -224,7 +229,7 @@ public abstract class UserCertificatePanel extends JPanel {
} else {
// determine new expires date for user
Date newExpires = null;
- for (X509Certificate c : ucm.certs) {
+ for (X509Certificate c : ucm.certs) {
if (!c.equals(cert)) {
if (!ucm.isRevoked(c.getSerialNumber())) {
if (newExpires == null || c.getNotAfter().after(newExpires)) {
@@ -235,7 +240,7 @@ public abstract class UserCertificatePanel extends JPanel {
}
ucm.expires = newExpires;
}
-
+
AuthorityWorker worker = new AuthorityWorker(UserCertificatePanel.this.owner) {
@Override
@@ -245,11 +250,11 @@ public abstract class UserCertificatePanel extends JPanel {
@Override
protected void onSuccess() {
- JOptionPane.showMessageDialog(UserCertificatePanel.this.owner,
+ JOptionPane.showMessageDialog(UserCertificatePanel.this.owner,
MessageFormat.format(Translation.get("gb.certificateRevoked"), cert.getSerialNumber(), cert.getIssuerDN().getName()),
Translation.get("gb.revokeCertificate"), JOptionPane.INFORMATION_MESSAGE);
}
-
+
};
worker.execute();
}
@@ -258,40 +263,40 @@ public abstract class UserCertificatePanel extends JPanel {
}
}
});
-
+
JPanel certificateControls = new JPanel(new FlowLayout(FlowLayout.LEFT));
certificateControls.add(newCertificateButton);
certificateControls.add(revokeCertificateButton);
certificatesPanel.add(certificateControls, BorderLayout.SOUTH);
-
+
add(fieldsPanel, BorderLayout.NORTH);
add(certificatesPanel, BorderLayout.CENTER);
setEditable(false);
}
-
+
public void setUserCertificateModel(UserCertificateModel ucm) {
this.ucm = ucm;
setEditable(false);
oidsPanel.setUserCertificateModel(ucm);
-
+
tableModel.setUserCertificateModel(ucm);
tableModel.fireTableDataChanged();
Utils.packColumns(table, Utils.MARGIN);
}
-
+
public void setEditable(boolean editable) {
oidsPanel.setEditable(editable);
-
+
editUserButton.setEnabled(!editable && ucm != null);
saveUserButton.setEnabled(editable && ucm != null);
-
+
newCertificateButton.setEnabled(ucm != null);
revokeCertificateButton.setEnabled(false);
}
-
+
public abstract Date getDefaultExpiration();
public abstract boolean isAllowEmail();
-
+
public abstract boolean saveUser(String username, UserCertificateModel ucm);
public abstract boolean newCertificate(UserCertificateModel ucm, X509Metadata metadata, boolean sendEmail);
public abstract boolean revoke(UserCertificateModel ucm, X509Certificate cert, RevocationReason reason);
diff --git a/src/main/java/com/gitblit/authority/UserCertificateTableModel.java b/src/main/java/com/gitblit/authority/UserCertificateTableModel.java
index dde73fc0..7763124d 100644
--- a/src/main/java/com/gitblit/authority/UserCertificateTableModel.java
+++ b/src/main/java/com/gitblit/authority/UserCertificateTableModel.java
@@ -26,9 +26,9 @@ import com.gitblit.client.Translation;
/**
* Table model of a list of user certificate models.
- *
+ *
* @author James Moger
- *
+ *
*/
public class UserCertificateTableModel extends AbstractTableModel {
@@ -82,11 +82,12 @@ public class UserCertificateTableModel extends AbstractTableModel {
/**
* Returns <code>Object.class</code> regardless of <code>columnIndex</code>.
- *
+ *
* @param columnIndex
* the column being queried
* @return the Object.class
*/
+ @Override
public Class<?> getColumnClass(int columnIndex) {
Columns col = Columns.values()[columnIndex];
switch (col) {
diff --git a/src/main/java/com/gitblit/authority/UserOidsPanel.java b/src/main/java/com/gitblit/authority/UserOidsPanel.java
index 5a33b3f3..815a4707 100644
--- a/src/main/java/com/gitblit/authority/UserOidsPanel.java
+++ b/src/main/java/com/gitblit/authority/UserOidsPanel.java
@@ -23,9 +23,9 @@ import javax.swing.JTextField;
import com.gitblit.client.Translation;
public class UserOidsPanel extends JPanel {
-
+
private static final long serialVersionUID = 1L;
-
+
private JTextField displayname;
private JTextField username;
private JTextField emailAddress;
@@ -37,7 +37,7 @@ public class UserOidsPanel extends JPanel {
public UserOidsPanel() {
super();
-
+
displayname = new JTextField(20);
username = new JTextField(20);
username.setEditable(false);
@@ -47,7 +47,7 @@ public class UserOidsPanel extends JPanel {
locality = new JTextField(20);
stateProvince = new JTextField(20);
countryCode = new JTextField(20);
-
+
setLayout(new GridLayout(0, 1, Utils.MARGIN, Utils.MARGIN));
add(Utils.newFieldPanel(Translation.get("gb.displayName"), displayname));
add(Utils.newFieldPanel(Translation.get("gb.username") + " (CN)", username));
@@ -58,7 +58,7 @@ public class UserOidsPanel extends JPanel {
add(Utils.newFieldPanel(Translation.get("gb.stateProvince") + " (ST)", stateProvince));
add(Utils.newFieldPanel(Translation.get("gb.countryCode") + " (C)", countryCode));
}
-
+
public void setUserCertificateModel(UserCertificateModel ucm) {
setEditable(false);
displayname.setText(ucm == null ? "" : ucm.user.getDisplayName());
@@ -70,7 +70,7 @@ public class UserOidsPanel extends JPanel {
stateProvince.setText(ucm == null ? "" : ucm.user.stateProvince);
countryCode.setText(ucm == null ? "" : ucm.user.countryCode);
}
-
+
public void setEditable(boolean editable) {
displayname.setEditable(editable);
// username.setEditable(editable);
@@ -81,7 +81,7 @@ public class UserOidsPanel extends JPanel {
stateProvince.setEditable(editable);
countryCode.setEditable(editable);
}
-
+
protected void updateUser(UserCertificateModel ucm) {
ucm.user.displayName = displayname.getText();
ucm.user.username = username.getText();
diff --git a/src/main/java/com/gitblit/authority/Utils.java b/src/main/java/com/gitblit/authority/Utils.java
index 45e028e7..68799602 100644
--- a/src/main/java/com/gitblit/authority/Utils.java
+++ b/src/main/java/com/gitblit/authority/Utils.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2011 gitblit.com.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package com.gitblit.authority;
import java.awt.Color;
@@ -26,7 +41,7 @@ import com.gitblit.client.Translation;
import com.gitblit.utils.StringUtils;
public class Utils {
-
+
public final static int LABEL_WIDTH = 175;
public final static int MARGIN = 5;
@@ -49,11 +64,11 @@ public class Utils {
new DateCellRenderer(datePattern, Color.orange.darker()));
return table;
}
-
+
public static JPanel newFieldPanel(String label, Component c) {
return newFieldPanel(label, c, null);
}
-
+
public static JPanel newFieldPanel(String label, Component c, String trailingLabel) {
JLabel jlabel = new JLabel(label);
jlabel.setPreferredSize(new Dimension(Utils.LABEL_WIDTH, 20));
@@ -61,11 +76,11 @@ public class Utils {
panel.add(jlabel);
panel.add(c);
if (!StringUtils.isEmpty(trailingLabel)) {
- panel.add(new JLabel(trailingLabel));
+ panel.add(new JLabel(trailingLabel));
}
return panel;
}
-
+
public static void showException(Component c, Throwable t) {
StringWriter writer = new StringWriter();
t.printStackTrace(new PrintWriter(writer));
@@ -81,7 +96,7 @@ public class Utils {
JOptionPane.showMessageDialog(c, jsp, Translation.get("gb.error"),
JOptionPane.ERROR_MESSAGE);
}
-
+
public static void packColumns(JTable table, int margin) {
for (int c = 0; c < table.getColumnCount(); c++) {
packColumn(table, c, 4);
diff --git a/src/main/java/com/gitblit/authority/X509CertificateViewer.java b/src/main/java/com/gitblit/authority/X509CertificateViewer.java
index 797b9a81..4711003b 100644
--- a/src/main/java/com/gitblit/authority/X509CertificateViewer.java
+++ b/src/main/java/com/gitblit/authority/X509CertificateViewer.java
@@ -41,24 +41,24 @@ import com.gitblit.utils.StringUtils;
public class X509CertificateViewer extends JDialog {
private static final long serialVersionUID = 1L;
-
+
public X509CertificateViewer(Frame owner, X509Certificate cert) {
super(owner);
-
+
setTitle(Translation.get("gb.viewCertificate"));
-
- JPanel content = new JPanel(new BorderLayout(Utils.MARGIN, Utils.MARGIN)) {
+
+ JPanel content = new JPanel(new BorderLayout(Utils.MARGIN, Utils.MARGIN)) {
private static final long serialVersionUID = 1L;
@Override
public Insets getInsets() {
-
+
return Utils.INSETS;
}
};
-
+
DateFormat df = DateFormat.getDateTimeInstance();
-
+
int l1 = 15;
int l2 = 25;
int l3 = 45;
@@ -82,26 +82,27 @@ public class X509CertificateViewer extends JDialog {
}
content.add(panel, BorderLayout.CENTER);
-
+
JButton ok = new JButton(Translation.get("gb.ok"));
ok.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
setVisible(false);
}
});
-
+
JPanel controls = new JPanel();
controls.add(ok);
-
+
content.add(controls, BorderLayout.SOUTH);
-
+
getContentPane().add(new HeaderPanel(Translation.get("gb.certificate"), "rosette_16x16.png"), BorderLayout.NORTH);
getContentPane().add(content, BorderLayout.CENTER);
pack();
-
+
setLocationRelativeTo(owner);
}
-
+
private JPanel newField(String label, String value, int cols) {
JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT, 2*Utils.MARGIN, 0));
JLabel lbl = new JLabel(label);
@@ -114,7 +115,7 @@ public class X509CertificateViewer extends JDialog {
panel.add(tf);
return panel;
}
-
+
private String fingerprint(String value) {
value = value.toUpperCase();
StringBuilder sb = new StringBuilder();
diff --git a/src/main/java/com/gitblit/client/BooleanCellRenderer.java b/src/main/java/com/gitblit/client/BooleanCellRenderer.java
index c8341df6..65a3c670 100644
--- a/src/main/java/com/gitblit/client/BooleanCellRenderer.java
+++ b/src/main/java/com/gitblit/client/BooleanCellRenderer.java
@@ -25,9 +25,9 @@ import javax.swing.table.TableCellRenderer;
/**
* Boolean checkbox cell renderer.
- *
+ *
* @author James Moger
- *
+ *
*/
public class BooleanCellRenderer extends JCheckBox implements TableCellRenderer, Serializable {
@@ -39,6 +39,7 @@ public class BooleanCellRenderer extends JCheckBox implements TableCellRenderer,
setHorizontalAlignment(SwingConstants.CENTER);
}
+ @Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
boolean hasFocus, int row, int column) {
if (value instanceof Boolean) {
diff --git a/src/main/java/com/gitblit/client/BranchRenderer.java b/src/main/java/com/gitblit/client/BranchRenderer.java
index 5f12c42c..43352d8f 100644
--- a/src/main/java/com/gitblit/client/BranchRenderer.java
+++ b/src/main/java/com/gitblit/client/BranchRenderer.java
@@ -26,9 +26,9 @@ import javax.swing.table.DefaultTableCellRenderer;
/**
* Branch renderer displays refs/heads and refs/remotes in a color similar to
* the site.
- *
+ *
* @author James Moger
- *
+ *
*/
public class BranchRenderer extends DefaultTableCellRenderer implements ListCellRenderer {
@@ -37,9 +37,10 @@ public class BranchRenderer extends DefaultTableCellRenderer implements ListCell
private static final String R_HEADS = "refs/heads/";
private static final String R_REMOTES = "refs/remotes/";
-
+
private static final String R_CHANGES = "refs/changes/";
+ @Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
diff --git a/src/main/java/com/gitblit/client/ClosableTabComponent.java b/src/main/java/com/gitblit/client/ClosableTabComponent.java
index a121806a..f6bbaebc 100644
--- a/src/main/java/com/gitblit/client/ClosableTabComponent.java
+++ b/src/main/java/com/gitblit/client/ClosableTabComponent.java
@@ -46,6 +46,7 @@ public class ClosableTabComponent extends JPanel {
private static final long serialVersionUID = 1L;
private static final MouseListener BUTTON_MOUSE_LISTENER = new MouseAdapter() {
+ @Override
public void mouseEntered(MouseEvent e) {
Component component = e.getComponent();
if (component instanceof AbstractButton) {
@@ -54,6 +55,7 @@ public class ClosableTabComponent extends JPanel {
}
}
+ @Override
public void mouseExited(MouseEvent e) {
Component component = e.getComponent();
if (component instanceof AbstractButton) {
@@ -112,6 +114,7 @@ public class ClosableTabComponent extends JPanel {
addActionListener(this);
}
+ @Override
public void actionPerformed(ActionEvent e) {
int i = pane.indexOfTabComponent(ClosableTabComponent.this);
Component c = pane.getComponentAt(i);
@@ -123,6 +126,7 @@ public class ClosableTabComponent extends JPanel {
}
}
+ @Override
public void updateUI() {
}
diff --git a/src/main/java/com/gitblit/client/DateCellRenderer.java b/src/main/java/com/gitblit/client/DateCellRenderer.java
index 751c7dbb..ef5be3a6 100644
--- a/src/main/java/com/gitblit/client/DateCellRenderer.java
+++ b/src/main/java/com/gitblit/client/DateCellRenderer.java
@@ -26,22 +26,23 @@ import javax.swing.table.DefaultTableCellRenderer;
/**
* Time ago cell renderer with real date tooltip.
- *
+ *
* @author James Moger
- *
+ *
*/
public class DateCellRenderer extends DefaultTableCellRenderer {
private static final long serialVersionUID = 1L;
private final String pattern;
-
+
public DateCellRenderer(String pattern, Color foreground) {
this.pattern = (pattern == null ? "yyyy-MM-dd HH:mm" : pattern);
setForeground(foreground);
setHorizontalAlignment(SwingConstants.CENTER);
}
+ @Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
diff --git a/src/main/java/com/gitblit/client/EditRegistrationDialog.java b/src/main/java/com/gitblit/client/EditRegistrationDialog.java
index 99cd36fa..66bb197a 100644
--- a/src/main/java/com/gitblit/client/EditRegistrationDialog.java
+++ b/src/main/java/com/gitblit/client/EditRegistrationDialog.java
@@ -42,9 +42,9 @@ import com.gitblit.utils.StringUtils;
/**
* Dialog to create or edit a Gitblit registration.
- *
+ *
* @author James Moger
- *
+ *
*/
public class EditRegistrationDialog extends JDialog {
@@ -71,6 +71,7 @@ public class EditRegistrationDialog extends JDialog {
KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
JRootPane rootPane = new JRootPane();
rootPane.registerKeyboardAction(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent actionEvent) {
setVisible(false);
}
@@ -98,6 +99,7 @@ public class EditRegistrationDialog extends JDialog {
JButton cancel = new JButton(Translation.get("gb.cancel"));
cancel.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent event) {
setVisible(false);
}
@@ -105,6 +107,7 @@ public class EditRegistrationDialog extends JDialog {
final JButton save = new JButton(Translation.get(isLogin ? "gb.login" : "gb.save"));
save.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent event) {
if (validateFields()) {
canceled = false;
@@ -115,6 +118,7 @@ public class EditRegistrationDialog extends JDialog {
// on enter in password field, save or login
passwordField.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent event) {
save.doClick();
}
diff --git a/src/main/java/com/gitblit/client/EditRepositoryDialog.java b/src/main/java/com/gitblit/client/EditRepositoryDialog.java
index 118c5c82..4a8a2153 100644
--- a/src/main/java/com/gitblit/client/EditRepositoryDialog.java
+++ b/src/main/java/com/gitblit/client/EditRepositoryDialog.java
@@ -69,7 +69,7 @@ import com.gitblit.utils.StringUtils;
/**
* Dialog to create/edit a repository.
- *
+ *
* @author James Moger
*/
public class EditRepositoryDialog extends JDialog {
@@ -93,7 +93,7 @@ public class EditRepositoryDialog extends JDialog {
private JCheckBox useDocs;
private JCheckBox useIncrementalPushTags;
-
+
private JCheckBox showRemoteBranches;
private JCheckBox showReadme;
@@ -107,11 +107,11 @@ public class EditRepositoryDialog extends JDialog {
private JTextField mailingListsField;
private JComboBox accessRestriction;
-
+
private JRadioButton allowAuthenticated;
-
+
private JRadioButton allowNamed;
-
+
private JCheckBox allowForks;
private JCheckBox verifyCommitter;
@@ -121,19 +121,19 @@ public class EditRepositoryDialog extends JDialog {
private JPalette<String> ownersPalette;
private JComboBox headRefField;
-
+
private JComboBox gcPeriod;
-
+
private JTextField gcThreshold;
-
+
private JComboBox maxActivityCommits;
-
+
private RegistrantPermissionsPanel usersPalette;
private JPalette<String> setsPalette;
private RegistrantPermissionsPanel teamsPalette;
-
+
private JPalette<String> indexedBranchesPalette;
private JPalette<String> preReceivePalette;
@@ -145,9 +145,9 @@ public class EditRepositoryDialog extends JDialog {
private JLabel postReceiveInherited;
private Set<String> repositoryNames;
-
+
private JPanel customFieldsPanel;
-
+
private List<JTextField> customTextfields;
public EditRepositoryDialog(int protocolVersion) {
@@ -175,6 +175,7 @@ public class EditRepositoryDialog extends JDialog {
KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
JRootPane rootPane = new JRootPane();
rootPane.registerKeyboardAction(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent actionEvent) {
setVisible(false);
}
@@ -194,17 +195,17 @@ public class EditRepositoryDialog extends JDialog {
if (ArrayUtils.isEmpty(anRepository.availableRefs)) {
headRefField = new JComboBox();
- headRefField.setEnabled(false);
+ headRefField.setEnabled(false);
} else {
headRefField = new JComboBox(
anRepository.availableRefs.toArray());
headRefField.setSelectedItem(anRepository.HEAD);
}
-
+
Integer [] gcPeriods = { 1, 2, 3, 4, 5, 7, 10, 14 };
gcPeriod = new JComboBox(gcPeriods);
gcPeriod.setSelectedItem(anRepository.gcPeriod);
-
+
gcThreshold = new JTextField(8);
gcThreshold.setText(anRepository.gcThreshold);
@@ -250,21 +251,21 @@ public class EditRepositoryDialog extends JDialog {
}
}
});
-
- boolean authenticated = anRepository.authorizationControl != null
+
+ boolean authenticated = anRepository.authorizationControl != null
&& AuthorizationControl.AUTHENTICATED.equals(anRepository.authorizationControl);
allowAuthenticated = new JRadioButton(Translation.get("gb.allowAuthenticatedDescription"));
allowAuthenticated.setSelected(authenticated);
allowAuthenticated.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
- if (e.getStateChange() == ItemEvent.SELECTED) {
+ if (e.getStateChange() == ItemEvent.SELECTED) {
usersPalette.setEnabled(false);
teamsPalette.setEnabled(false);
}
}
});
-
+
allowNamed = new JRadioButton(Translation.get("gb.allowNamedDescription"));
allowNamed.setSelected(!authenticated);
allowNamed.addItemListener(new ItemListener() {
@@ -276,15 +277,15 @@ public class EditRepositoryDialog extends JDialog {
}
}
});
-
+
ButtonGroup group = new ButtonGroup();
group.add(allowAuthenticated);
group.add(allowNamed);
-
+
JPanel authorizationPanel = new JPanel(new GridLayout(0, 1));
authorizationPanel.add(allowAuthenticated);
authorizationPanel.add(allowNamed);
-
+
allowForks = new JCheckBox(Translation.get("gb.allowForksDescription"), anRepository.allowForks);
verifyCommitter = new JCheckBox(Translation.get("gb.verifyCommitterDescription"), anRepository.verifyCommitter);
@@ -387,7 +388,7 @@ public class EditRepositoryDialog extends JDialog {
JPanel postReceivePanel = new JPanel(new BorderLayout(5, 5));
postReceivePanel.add(postReceivePalette, BorderLayout.CENTER);
postReceivePanel.add(postReceiveInherited, BorderLayout.WEST);
-
+
customFieldsPanel = new JPanel();
customFieldsPanel.setLayout(new BoxLayout(customFieldsPanel, BoxLayout.Y_AXIS));
JScrollPane customFieldsScrollPane = new JScrollPane(customFieldsPanel);
@@ -406,14 +407,15 @@ public class EditRepositoryDialog extends JDialog {
}
panel.addTab(Translation.get("gb.preReceiveScripts"), preReceivePanel);
panel.addTab(Translation.get("gb.postReceiveScripts"), postReceivePanel);
-
+
panel.addTab(Translation.get("gb.customFields"), customFieldsScrollPane);
-
+
setupAccessPermissions(anRepository.accessRestriction);
JButton createButton = new JButton(Translation.get("gb.save"));
createButton.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent event) {
if (validateFields()) {
canceled = false;
@@ -424,6 +426,7 @@ public class EditRepositoryDialog extends JDialog {
JButton cancelButton = new JButton(Translation.get("gb.cancel"));
cancelButton.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent event) {
canceled = true;
setVisible(false);
@@ -452,7 +455,7 @@ public class EditRepositoryDialog extends JDialog {
pack();
nameField.requestFocus();
}
-
+
private JPanel newFieldPanel(String label, JComponent comp) {
return newFieldPanel(label, 150, comp);
}
@@ -466,12 +469,12 @@ public class EditRepositoryDialog extends JDialog {
panel.add(comp);
return panel;
}
-
+
private void setupAccessPermissions(AccessRestrictionType art) {
if (AccessRestrictionType.NONE.equals(art)) {
usersPalette.setEnabled(false);
teamsPalette.setEnabled(false);
-
+
allowAuthenticated.setEnabled(false);
allowNamed.setEnabled(false);
verifyCommitter.setEnabled(false);
@@ -479,7 +482,7 @@ public class EditRepositoryDialog extends JDialog {
allowAuthenticated.setEnabled(true);
allowNamed.setEnabled(true);
verifyCommitter.setEnabled(true);
-
+
if (allowNamed.isSelected()) {
usersPalette.setEnabled(true);
teamsPalette.setEnabled(true);
@@ -575,7 +578,7 @@ public class EditRepositoryDialog extends JDialog {
repository.skipSizeCalculation = skipSizeCalculation.isSelected();
repository.skipSummaryMetrics = skipSummaryMetrics.isSelected();
repository.maxActivityCommits = (Integer) maxActivityCommits.getSelectedItem();
-
+
repository.isFrozen = isFrozen.isSelected();
repository.allowForks = allowForks.isSelected();
repository.verifyCommitter = verifyCommitter.isSelected();
@@ -594,7 +597,7 @@ public class EditRepositoryDialog extends JDialog {
repository.accessRestriction = (AccessRestrictionType) accessRestriction
.getSelectedItem();
- repository.authorizationControl = allowAuthenticated.isSelected() ?
+ repository.authorizationControl = allowAuthenticated.isSelected() ?
AuthorizationControl.AUTHENTICATED : AuthorizationControl.NAMED;
repository.federationStrategy = (FederationStrategy) federationStrategy
.getSelectedItem();
@@ -602,11 +605,11 @@ public class EditRepositoryDialog extends JDialog {
if (repository.federationStrategy.exceeds(FederationStrategy.EXCLUDE)) {
repository.federationSets = setsPalette.getSelections();
}
-
+
repository.indexedBranches = indexedBranchesPalette.getSelections();
repository.preReceiveScripts = preReceivePalette.getSelections();
repository.postReceiveScripts = postReceivePalette.getSelections();
-
+
// Custom Fields
repository.customFields = new LinkedHashMap<String, String>();
if (customTextfields != null) {
@@ -623,7 +626,7 @@ public class EditRepositoryDialog extends JDialog {
JOptionPane.showMessageDialog(EditRepositoryDialog.this, message,
Translation.get("gb.error"), JOptionPane.ERROR_MESSAGE);
}
-
+
public void setAccessRestriction(AccessRestrictionType restriction) {
this.accessRestriction.setSelectedItem(restriction);
setupAccessPermissions(restriction);
@@ -658,7 +661,7 @@ public class EditRepositoryDialog extends JDialog {
public void setFederationSets(List<String> all, List<String> selected) {
setsPalette.setObjects(all, selected);
}
-
+
public void setIndexedBranches(List<String> all, List<String> selected) {
indexedBranchesPalette.setObjects(all, selected);
}
@@ -701,11 +704,11 @@ public class EditRepositoryDialog extends JDialog {
public List<RegistrantAccessPermission> getTeamAccessPermissions() {
return teamsPalette.getPermissions();
}
-
+
public void setCustomFields(RepositoryModel repository, Map<String, String> customFields) {
customFieldsPanel.removeAll();
customTextfields = new ArrayList<JTextField>();
-
+
final Insets insets = new Insets(5, 5, 5, 5);
JPanel fields = new JPanel(new GridLayout(0, 1, 0, 5)) {
@@ -715,8 +718,8 @@ public class EditRepositoryDialog extends JDialog {
public Insets getInsets() {
return insets;
}
- };
-
+ };
+
for (Map.Entry<String, String> entry : customFields.entrySet()) {
String field = entry.getKey();
String value = "";
@@ -725,14 +728,14 @@ public class EditRepositoryDialog extends JDialog {
}
JTextField textField = new JTextField(value);
textField.setName(field);
-
+
textField.setPreferredSize(new Dimension(450, 26));
-
+
fields.add(newFieldPanel(entry.getValue(), 250, textField));
-
+
customTextfields.add(textField);
}
- JScrollPane jsp = new JScrollPane(fields);
+ JScrollPane jsp = new JScrollPane(fields);
jsp.getVerticalScrollBar().setBlockIncrement(100);
jsp.getVerticalScrollBar().setUnitIncrement(100);
jsp.setViewportBorder(null);
@@ -743,7 +746,7 @@ public class EditRepositoryDialog extends JDialog {
/**
* ListCellRenderer to display descriptive text about the access
* restriction.
- *
+ *
*/
private class AccessRestrictionRenderer extends DefaultListCellRenderer {
@@ -753,7 +756,7 @@ public class EditRepositoryDialog extends JDialog {
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
-
+
if (value instanceof AccessRestrictionType) {
AccessRestrictionType restriction = (AccessRestrictionType) value;
switch (restriction) {
diff --git a/src/main/java/com/gitblit/client/EditTeamDialog.java b/src/main/java/com/gitblit/client/EditTeamDialog.java
index 74640553..3c0b928c 100644
--- a/src/main/java/com/gitblit/client/EditTeamDialog.java
+++ b/src/main/java/com/gitblit/client/EditTeamDialog.java
@@ -70,11 +70,11 @@ public class EditTeamDialog extends JDialog {
private boolean canceled = true;
private JTextField teamnameField;
-
+
private JCheckBox canAdminCheckbox;
-
+
private JCheckBox canForkCheckbox;
-
+
private JCheckBox canCreateCheckbox;
private JTextField mailingListsField;
@@ -117,6 +117,7 @@ public class EditTeamDialog extends JDialog {
KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
JRootPane rootPane = new JRootPane();
rootPane.registerKeyboardAction(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent actionEvent) {
setVisible(false);
}
@@ -127,7 +128,7 @@ public class EditTeamDialog extends JDialog {
private void initialize(int protocolVersion, TeamModel aTeam) {
teamnameField = new JTextField(aTeam.name == null ? "" : aTeam.name, 25);
- canAdminCheckbox = new JCheckBox(Translation.get("gb.canAdminDescription"), aTeam.canAdmin);
+ canAdminCheckbox = new JCheckBox(Translation.get("gb.canAdminDescription"), aTeam.canAdmin);
canForkCheckbox = new JCheckBox(Translation.get("gb.canForkDescription"), aTeam.canFork);
canCreateCheckbox = new JCheckBox(Translation.get("gb.canCreateDescription"), aTeam.canCreate);
@@ -146,7 +147,7 @@ public class EditTeamDialog extends JDialog {
repositoryPalette = new RegistrantPermissionsPanel(RegistrantType.REPOSITORY);
userPalette = new JPalette<String>();
userPalette.setEnabled(settings.supportsTeamMembershipChanges);
-
+
JPanel fieldsPanelTop = new JPanel(new BorderLayout());
fieldsPanelTop.add(fieldsPanel, BorderLayout.NORTH);
@@ -154,6 +155,7 @@ public class EditTeamDialog extends JDialog {
private static final long serialVersionUID = 1L;
+ @Override
public Insets getInsets() {
return _insets;
}
@@ -164,6 +166,7 @@ public class EditTeamDialog extends JDialog {
private static final long serialVersionUID = 1L;
+ @Override
public Insets getInsets() {
return _insets;
}
@@ -175,7 +178,7 @@ public class EditTeamDialog extends JDialog {
JPanel preReceivePanel = new JPanel(new BorderLayout(5, 5));
preReceivePanel.add(preReceivePalette, BorderLayout.CENTER);
preReceivePanel.add(preReceiveInherited, BorderLayout.WEST);
-
+
postReceivePalette = new JPalette<String>(true);
postReceiveInherited = new JLabel();
JPanel postReceivePanel = new JPanel(new BorderLayout(5, 5));
@@ -191,6 +194,7 @@ public class EditTeamDialog extends JDialog {
JButton createButton = new JButton(Translation.get("gb.save"));
createButton.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent event) {
if (validateFields()) {
canceled = false;
@@ -201,6 +205,7 @@ public class EditTeamDialog extends JDialog {
JButton cancelButton = new JButton(Translation.get("gb.cancel"));
cancelButton.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent event) {
canceled = true;
setVisible(false);
@@ -317,10 +322,10 @@ public class EditTeamDialog extends JDialog {
if (repo.accessRestriction.exceeds(AccessRestrictionType.NONE)
&& repo.authorizationControl.equals(AuthorizationControl.NAMED)) {
restricted.add(repo.name);
- }
+ }
}
StringUtils.sortRepositorynames(restricted);
-
+
List<String> list = new ArrayList<String>();
// repositories
list.add(".*");
@@ -339,7 +344,7 @@ public class EditTeamDialog extends JDialog {
// all repositories excluding personal repositories
list.add("[^" + prefix + "].*");
}
-
+
String lastProject = null;
for (String repo : restricted) {
String projectPath = StringUtils.getFirstPathElement(repo);
diff --git a/src/main/java/com/gitblit/client/EditUserDialog.java b/src/main/java/com/gitblit/client/EditUserDialog.java
index fd6745ea..fd5cf79d 100644
--- a/src/main/java/com/gitblit/client/EditUserDialog.java
+++ b/src/main/java/com/gitblit/client/EditUserDialog.java
@@ -79,29 +79,29 @@ public class EditUserDialog extends JDialog {
private JPasswordField passwordField;
private JPasswordField confirmPasswordField;
-
+
private JTextField displayNameField;
-
+
private JTextField emailAddressField;
private JCheckBox canAdminCheckbox;
-
+
private JCheckBox canForkCheckbox;
-
+
private JCheckBox canCreateCheckbox;
private JCheckBox notFederatedCheckbox;
-
+
private JTextField organizationalUnitField;
-
+
private JTextField organizationField;
private JTextField localityField;
-
+
private JTextField stateProvinceField;
-
+
private JTextField countryCodeField;
-
+
private RegistrantPermissionsPanel repositoryPalette;
private JPalette<TeamModel> teamsPalette;
@@ -132,6 +132,7 @@ public class EditUserDialog extends JDialog {
KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
JRootPane rootPane = new JRootPane();
rootPane.registerKeyboardAction(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent actionEvent) {
setVisible(false);
}
@@ -146,19 +147,19 @@ public class EditUserDialog extends JDialog {
25);
displayNameField = new JTextField(anUser.displayName == null ? "" : anUser.displayName, 25);
emailAddressField = new JTextField(anUser.emailAddress == null ? "" : anUser.emailAddress, 25);
- canAdminCheckbox = new JCheckBox(Translation.get("gb.canAdminDescription"), anUser.canAdmin);
+ canAdminCheckbox = new JCheckBox(Translation.get("gb.canAdminDescription"), anUser.canAdmin);
canForkCheckbox = new JCheckBox(Translation.get("gb.canForkDescription"), anUser.canFork);
canCreateCheckbox = new JCheckBox(Translation.get("gb.canCreateDescription"), anUser.canCreate);
notFederatedCheckbox = new JCheckBox(
Translation.get("gb.excludeFromFederationDescription"),
anUser.excludeFromFederation);
-
+
organizationalUnitField = new JTextField(anUser.organizationalUnit == null ? "" : anUser.organizationalUnit, 25);
organizationField = new JTextField(anUser.organization == null ? "" : anUser.organization, 25);
localityField = new JTextField(anUser.locality == null ? "" : anUser.locality, 25);
stateProvinceField = new JTextField(anUser.stateProvince == null ? "" : anUser.stateProvince, 25);
countryCodeField = new JTextField(anUser.countryCode == null ? "" : anUser.countryCode, 15);
-
+
// credentials are optionally controlled by 3rd-party authentication
usernameField.setEnabled(settings.supportsCredentialChanges);
passwordField.setEnabled(settings.supportsCredentialChanges);
@@ -166,7 +167,7 @@ public class EditUserDialog extends JDialog {
displayNameField.setEnabled(settings.supportsDisplayNameChanges);
emailAddressField.setEnabled(settings.supportsEmailAddressChanges);
-
+
organizationalUnitField.setEnabled(settings.supportsDisplayNameChanges);
organizationField.setEnabled(settings.supportsDisplayNameChanges);
localityField.setEnabled(settings.supportsDisplayNameChanges);
@@ -191,7 +192,7 @@ public class EditUserDialog extends JDialog {
attributesPanel.add(newFieldPanel(Translation.get("gb.locality") + " (L)", localityField));
attributesPanel.add(newFieldPanel(Translation.get("gb.stateProvince") + " (ST)", stateProvinceField));
attributesPanel.add(newFieldPanel(Translation.get("gb.countryCode") + " (C)", countryCodeField));
-
+
final Insets _insets = new Insets(5, 5, 5, 5);
repositoryPalette = new RegistrantPermissionsPanel(RegistrantType.REPOSITORY);
teamsPalette = new JPalette<TeamModel>();
@@ -207,6 +208,7 @@ public class EditUserDialog extends JDialog {
private static final long serialVersionUID = 1L;
+ @Override
public Insets getInsets() {
return _insets;
}
@@ -217,6 +219,7 @@ public class EditUserDialog extends JDialog {
private static final long serialVersionUID = 1L;
+ @Override
public Insets getInsets() {
return _insets;
}
@@ -233,6 +236,7 @@ public class EditUserDialog extends JDialog {
JButton createButton = new JButton(Translation.get("gb.save"));
createButton.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent event) {
if (validateFields()) {
canceled = false;
@@ -243,6 +247,7 @@ public class EditUserDialog extends JDialog {
JButton cancelButton = new JButton(Translation.get("gb.cancel"));
cancelButton.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent event) {
canceled = true;
setVisible(false);
@@ -349,7 +354,7 @@ public class EditUserDialog extends JDialog {
// no change in password
user.password = password;
}
-
+
user.displayName = displayNameField.getText().trim();
user.emailAddress = emailAddressField.getText().trim();
@@ -363,7 +368,7 @@ public class EditUserDialog extends JDialog {
user.locality = localityField.getText().trim();
user.stateProvince = stateProvinceField.getText().trim();
user.countryCode = countryCodeField.getText().trim();
-
+
for (RegistrantAccessPermission rp : repositoryPalette.getPermissions()) {
user.setRepositoryPermission(rp.registrant, rp.permission);
}
@@ -394,16 +399,16 @@ public class EditUserDialog extends JDialog {
if (repo.accessRestriction.exceeds(AccessRestrictionType.NONE)
&& repo.authorizationControl.equals(AuthorizationControl.NAMED)) {
restricted.add(repo.name);
- }
+ }
}
repoMap.put(repo.name.toLowerCase(), repo);
}
StringUtils.sortRepositorynames(restricted);
-
+
List<String> list = new ArrayList<String>();
// repositories
list.add(".*");
-
+
String prefix;
if (settings.hasKey(Keys.git.userRepositoryPrefix)) {
prefix = settings.get(Keys.git.userRepositoryPrefix).currentValue;
@@ -418,7 +423,7 @@ public class EditUserDialog extends JDialog {
// all repositories excluding personal repositories
list.add("[^" + prefix + "].*");
}
-
+
String lastProject = null;
for (String repo : restricted) {
String projectPath = StringUtils.getFirstPathElement(repo).toLowerCase();
@@ -440,7 +445,7 @@ public class EditUserDialog extends JDialog {
list.remove(rp.registrant.toLowerCase());
}
}
-
+
// update owner and missing permissions for editing
for (RegistrantAccessPermission permission : permissions) {
if (permission.mutable && PermissionType.EXPLICIT.equals(permission.permissionType)) {
@@ -471,7 +476,7 @@ public class EditUserDialog extends JDialog {
}
teamsPalette.setObjects(teams, selected);
}
-
+
public UserModel getUser() {
if (canceled) {
return null;
diff --git a/src/main/java/com/gitblit/client/FeedEntryTableModel.java b/src/main/java/com/gitblit/client/FeedEntryTableModel.java
index 0b0ef178..2118bc33 100644
--- a/src/main/java/com/gitblit/client/FeedEntryTableModel.java
+++ b/src/main/java/com/gitblit/client/FeedEntryTableModel.java
@@ -26,9 +26,9 @@ import com.gitblit.models.FeedEntryModel;
/**
* Table model for a list of retrieved feed entries.
- *
+ *
* @author James Moger
- *
+ *
*/
public class FeedEntryTableModel extends AbstractTableModel {
@@ -84,11 +84,12 @@ public class FeedEntryTableModel extends AbstractTableModel {
/**
* Returns <code>Object.class</code> regardless of <code>columnIndex</code>.
- *
+ *
* @param columnIndex
* the column being queried
* @return the Object.class
*/
+ @Override
public Class<?> getColumnClass(int columnIndex) {
if (Columns.Date.ordinal() == columnIndex) {
return Date.class;
diff --git a/src/main/java/com/gitblit/client/FeedsPanel.java b/src/main/java/com/gitblit/client/FeedsPanel.java
index 392636e4..3b7959e7 100644
--- a/src/main/java/com/gitblit/client/FeedsPanel.java
+++ b/src/main/java/com/gitblit/client/FeedsPanel.java
@@ -49,9 +49,9 @@ import com.gitblit.utils.StringUtils;
/**
* RSS Feeds Panel displays recent entries and launches the browser to view the
* commit. commitdiff, or tree of a commit.
- *
+ *
* @author James Moger
- *
+ *
*/
public abstract class FeedsPanel extends JPanel {
@@ -95,6 +95,7 @@ public abstract class FeedsPanel extends JPanel {
prev.setToolTipText(Translation.get("gb.pagePrevious"));
prev.setEnabled(false);
prev.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
refreshFeeds(--page);
}
@@ -104,6 +105,7 @@ public abstract class FeedsPanel extends JPanel {
next.setToolTipText(Translation.get("gb.pageNext"));
next.setEnabled(false);
next.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
refreshFeeds(++page);
}
@@ -111,6 +113,7 @@ public abstract class FeedsPanel extends JPanel {
JButton refreshFeeds = new JButton(Translation.get("gb.refresh"));
refreshFeeds.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
refreshFeeds(0);
}
@@ -119,6 +122,7 @@ public abstract class FeedsPanel extends JPanel {
final JButton viewCommit = new JButton(Translation.get("gb.view"));
viewCommit.setEnabled(false);
viewCommit.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
viewCommit();
}
@@ -127,6 +131,7 @@ public abstract class FeedsPanel extends JPanel {
final JButton viewCommitDiff = new JButton(Translation.get("gb.commitdiff"));
viewCommitDiff.setEnabled(false);
viewCommitDiff.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
viewCommitDiff();
}
@@ -135,6 +140,7 @@ public abstract class FeedsPanel extends JPanel {
final JButton viewTree = new JButton(Translation.get("gb.tree"));
viewTree.setEnabled(false);
viewTree.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
viewTree();
}
@@ -142,6 +148,7 @@ public abstract class FeedsPanel extends JPanel {
JButton subscribeFeeds = new JButton(Translation.get("gb.subscribe") + "...");
subscribeFeeds.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
subscribeFeeds(gitblit.getAvailableFeeds());
}
@@ -171,6 +178,7 @@ public abstract class FeedsPanel extends JPanel {
table.getColumn(name).setCellRenderer(new MessageRenderer(gitblit));
table.addMouseListener(new MouseAdapter() {
+ @Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
if (e.isControlDown()) {
@@ -200,6 +208,7 @@ public abstract class FeedsPanel extends JPanel {
repositorySelector.setRenderer(nameRenderer);
repositorySelector.setForeground(nameRenderer.getForeground());
repositorySelector.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent event) {
// repopulate the author list based on repository selection
// preserve author selection, if possible
@@ -221,6 +230,7 @@ public abstract class FeedsPanel extends JPanel {
authorSelector.setRenderer(nameRenderer);
authorSelector.setForeground(nameRenderer.getForeground());
authorSelector.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent event) {
filterFeeds();
}
@@ -371,6 +381,7 @@ public abstract class FeedsPanel extends JPanel {
if (repository.equals(ALL)) {
// author filter
containsFilter = new RowFilter<FeedEntryTableModel, Object>() {
+ @Override
public boolean include(
Entry<? extends FeedEntryTableModel, ? extends Object> entry) {
return entry.getStringValue(authorIndex).equalsIgnoreCase(author);
@@ -379,6 +390,7 @@ public abstract class FeedsPanel extends JPanel {
} else if (author.equals(ALL)) {
// repository filter
containsFilter = new RowFilter<FeedEntryTableModel, Object>() {
+ @Override
public boolean include(
Entry<? extends FeedEntryTableModel, ? extends Object> entry) {
return entry.getStringValue(repositoryIndex).equalsIgnoreCase(repository);
@@ -387,6 +399,7 @@ public abstract class FeedsPanel extends JPanel {
} else {
// repository-author filter
containsFilter = new RowFilter<FeedEntryTableModel, Object>() {
+ @Override
public boolean include(
Entry<? extends FeedEntryTableModel, ? extends Object> entry) {
boolean authorMatch = entry.getStringValue(authorIndex)
diff --git a/src/main/java/com/gitblit/client/FeedsTableModel.java b/src/main/java/com/gitblit/client/FeedsTableModel.java
index 0979a4c9..e709b6a4 100644
--- a/src/main/java/com/gitblit/client/FeedsTableModel.java
+++ b/src/main/java/com/gitblit/client/FeedsTableModel.java
@@ -25,9 +25,9 @@ import com.gitblit.models.FeedModel;
/**
* Table model of a list of available feeds.
- *
+ *
* @author James Moger
- *
+ *
*/
public class FeedsTableModel extends AbstractTableModel {
@@ -77,11 +77,12 @@ public class FeedsTableModel extends AbstractTableModel {
/**
* Returns <code>Object.class</code> regardless of <code>columnIndex</code>.
- *
+ *
* @param columnIndex
* the column being queried
* @return the Object.class
*/
+ @Override
public Class<?> getColumnClass(int columnIndex) {
Columns col = Columns.values()[columnIndex];
switch (col) {
diff --git a/src/main/java/com/gitblit/client/GitblitClient.java b/src/main/java/com/gitblit/client/GitblitClient.java
index 427f45ba..66625a8e 100644
--- a/src/main/java/com/gitblit/client/GitblitClient.java
+++ b/src/main/java/com/gitblit/client/GitblitClient.java
@@ -55,9 +55,9 @@ import com.gitblit.utils.SyndicationUtils;
/**
* GitblitClient is a object that retrieves data from a Gitblit server, caches
* it for local operations, and allows updating or creating Gitblit objects.
- *
+ *
* @author James Moger
- *
+ *
*/
public class GitblitClient implements Serializable {
@@ -191,7 +191,7 @@ public class GitblitClient implements Serializable {
return sb.toString();
}
}
-
+
public AccessRestrictionType getDefaultAccessRestriction() {
String restriction = "PUSH";
if (settings.hasKey(Keys.git.defaultAccessRestriction)) {
@@ -211,7 +211,7 @@ public class GitblitClient implements Serializable {
/**
* Returns the list of pre-receive scripts the repository inherited from the
* global settings and team affiliations.
- *
+ *
* @param repository
* if null only the globally specified scripts are returned
* @return a list of scripts
@@ -243,7 +243,7 @@ public class GitblitClient implements Serializable {
* Returns the list of all available Groovy pre-receive push hook scripts
* that are not already inherited by the repository. Script files must have
* .groovy extension
- *
+ *
* @param repository
* optional parameter
* @return list of available hook scripts
@@ -264,7 +264,7 @@ public class GitblitClient implements Serializable {
/**
* Returns the list of post-receive scripts the repository inherited from
* the global settings and team affiliations.
- *
+ *
* @param repository
* if null only the globally specified scripts are returned
* @return a list of scripts
@@ -295,7 +295,7 @@ public class GitblitClient implements Serializable {
* Returns the list of unused Groovy post-receive push hook scripts that are
* not already inherited by the repository. Script files must have .groovy
* extension
- *
+ *
* @param repository
* optional parameter
* @return list of available hook scripts
@@ -305,7 +305,7 @@ public class GitblitClient implements Serializable {
// create list of available scripts by excluding inherited scripts
List<String> scripts = new ArrayList<String>();
- if (!ArrayUtils.isEmpty(settings.pushScripts)) {
+ if (!ArrayUtils.isEmpty(settings.pushScripts)) {
for (String script : settings.pushScripts) {
if (!inherited.contains(script)) {
scripts.add(script);
@@ -478,7 +478,7 @@ public class GitblitClient implements Serializable {
public List<UserModel> getUsers() {
return allUsers;
}
-
+
public UserModel getUser(String username) {
for (UserModel user : getUsers()) {
if (user.username.equalsIgnoreCase(username)) {
@@ -506,11 +506,11 @@ public class GitblitClient implements Serializable {
}
return usernames;
}
-
+
/**
* Returns the effective list of permissions for this user, taking into account
* team memberships, ownerships.
- *
+ *
* @param user
* @return the effective list of permissions for the user
*/
@@ -541,12 +541,12 @@ public class GitblitClient implements Serializable {
set.add(rp);
}
}
-
+
List<RegistrantAccessPermission> list = new ArrayList<RegistrantAccessPermission>(set);
Collections.sort(list);
return list;
}
-
+
public List<RegistrantAccessPermission> getUserAccessPermissions(RepositoryModel repository) {
List<RegistrantAccessPermission> list = new ArrayList<RegistrantAccessPermission>();
if (AccessRestrictionType.NONE.equals(repository.accessRestriction)) {
@@ -593,7 +593,7 @@ public class GitblitClient implements Serializable {
}
return teamnames;
}
-
+
public List<RegistrantAccessPermission> getTeamAccessPermissions(RepositoryModel repository) {
List<RegistrantAccessPermission> list = new ArrayList<RegistrantAccessPermission>();
for (TeamModel team : allTeams) {
@@ -626,7 +626,7 @@ public class GitblitClient implements Serializable {
public List<RepositoryModel> getRepositories() {
return allRepositories;
}
-
+
public RepositoryModel getRepository(String name) {
for (RepositoryModel repository : allRepositories) {
if (repository.name.equalsIgnoreCase(name)) {
@@ -682,7 +682,7 @@ public class GitblitClient implements Serializable {
public boolean deleteRepository(RepositoryModel repository) throws IOException {
return RpcUtils.deleteRepository(repository, url, account, password);
}
-
+
public boolean clearRepositoryCache() throws IOException {
return RpcUtils.clearRepositoryCache(url, account, password);
}
diff --git a/src/main/java/com/gitblit/client/GitblitManager.java b/src/main/java/com/gitblit/client/GitblitManager.java
index d2fd7f7b..06e48923 100644
--- a/src/main/java/com/gitblit/client/GitblitManager.java
+++ b/src/main/java/com/gitblit/client/GitblitManager.java
@@ -70,9 +70,9 @@ import com.gitblit.utils.StringUtils;
/**
* Gitblit Manager issues JSON RPC requests to a Gitblit server.
- *
+ *
* @author James Moger
- *
+ *
*/
public class GitblitManager extends JFrame implements RegistrationsDialog.RegistrationListener {
@@ -173,6 +173,7 @@ public class GitblitManager extends JFrame implements RegistrationsDialog.Regist
JMenuItem manage = new JMenuItem(Translation.get("gb.manage") + "...");
manage.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M, KeyEvent.CTRL_DOWN_MASK, false));
manage.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent event) {
manageRegistrations();
}
@@ -287,6 +288,7 @@ public class GitblitManager extends JFrame implements RegistrationsDialog.Regist
item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1 + i, KeyEvent.CTRL_DOWN_MASK,
false));
item.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
login(reg);
}
@@ -317,6 +319,7 @@ public class GitblitManager extends JFrame implements RegistrationsDialog.Regist
GitblitRegistration reg = new GitblitRegistration(server, url, account, password) {
private static final long serialVersionUID = 1L;
+ @Override
protected void cacheFeeds() {
writeFeedCache(this);
}
@@ -444,6 +447,7 @@ public class GitblitManager extends JFrame implements RegistrationsDialog.Regist
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
+ @Override
public void run() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
diff --git a/src/main/java/com/gitblit/client/GitblitManagerLauncher.java b/src/main/java/com/gitblit/client/GitblitManagerLauncher.java
index d0cc8393..8a43c472 100644
--- a/src/main/java/com/gitblit/client/GitblitManagerLauncher.java
+++ b/src/main/java/com/gitblit/client/GitblitManagerLauncher.java
@@ -36,9 +36,9 @@ import com.gitblit.Constants;
/**
* Downloads dependencies and launches Gitblit Manager.
- *
+ *
* @author James Moger
- *
+ *
*/
public class GitblitManagerLauncher {
@@ -51,10 +51,10 @@ public class GitblitManagerLauncher {
public static void main(String[] args) {
final SplashScreen splash = SplashScreen.getSplashScreen();
-
+
File libFolder = new File("ext");
List<File> jars = findJars(libFolder.getAbsoluteFile());
-
+
// sort the jars by name and then reverse the order so the newer version
// of the library gets loaded in the event that this is an upgrade
Collections.sort(jars);
@@ -67,7 +67,7 @@ public class GitblitManagerLauncher {
}
}
-
+
updateSplash(splash, Translation.get("gb.starting") + " Gitblit Manager...");
GitblitManager.main(args);
}
@@ -78,12 +78,13 @@ public class GitblitManagerLauncher {
}
try {
EventQueue.invokeAndWait(new Runnable() {
+ @Override
public void run() {
Graphics2D g = splash.createGraphics();
if (g != null) {
// Splash is 320x120
FontMetrics fm = g.getFontMetrics();
-
+
// paint startup status
g.setColor(Color.darkGray);
int h = fm.getHeight() + fm.getMaxDescent();
@@ -96,7 +97,7 @@ public class GitblitManagerLauncher {
g.setColor(Color.WHITE);
int xw = fm.stringWidth(string);
g.drawString(string, x + ((w - xw) / 2), y - 5);
-
+
// paint version
String ver = "v" + Constants.getVersion();
int vw = g.getFontMetrics().stringWidth(ver);
@@ -110,7 +111,7 @@ public class GitblitManagerLauncher {
t.printStackTrace();
}
}
-
+
public static List<File> findJars(File folder) {
List<File> jars = new ArrayList<File>();
if (folder.exists()) {
@@ -135,7 +136,7 @@ public class GitblitManagerLauncher {
/**
* Adds a file to the classpath
- *
+ *
* @param f
* the file to be added
* @throws IOException
diff --git a/src/main/java/com/gitblit/client/GitblitPanel.java b/src/main/java/com/gitblit/client/GitblitPanel.java
index f14ce790..84c79050 100644
--- a/src/main/java/com/gitblit/client/GitblitPanel.java
+++ b/src/main/java/com/gitblit/client/GitblitPanel.java
@@ -31,9 +31,9 @@ import com.gitblit.models.FeedModel;
/**
* GitblitPanel is a container for the repository, users, settings, etc panels.
- *
+ *
* @author James Moger
- *
+ *
*/
public class GitblitPanel extends JPanel implements CloseTabListener {
@@ -50,7 +50,7 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
private FeedsPanel feedsPanel;
private UsersPanel usersPanel;
-
+
private TeamsPanel teamsPanel;
private SettingsPanel settingsPanel;
@@ -69,6 +69,7 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
tabs.addTab(Translation.get("gb.settings"), createSettingsPanel());
tabs.addTab(Translation.get("gb.status"), createStatusPanel());
tabs.addChangeListener(new ChangeListener() {
+ @Override
public void stateChanged(ChangeEvent e) {
tabs.getSelectedComponent().requestFocus();
}
@@ -92,7 +93,7 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
protected void updateUsersTable() {
usersPanel.updateTable(false);
}
-
+
@Override
protected void updateTeamsTable() {
teamsPanel.updateTable(false);
@@ -116,9 +117,9 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
private JPanel createUsersPanel() {
usersPanel = new UsersPanel(gitblit) {
-
+
private static final long serialVersionUID = 1L;
-
+
@Override
protected void updateTeamsTable() {
teamsPanel.updateTable(false);
@@ -126,10 +127,10 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
};
return usersPanel;
}
-
+
private JPanel createTeamsPanel() {
teamsPanel = new TeamsPanel(gitblit) {
-
+
private static final long serialVersionUID = 1L;
@Override
@@ -138,7 +139,7 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
}
};
return teamsPanel;
- }
+ }
private JPanel createSettingsPanel() {
settingsPanel = new SettingsPanel(gitblit);
diff --git a/src/main/java/com/gitblit/client/GitblitRegistration.java b/src/main/java/com/gitblit/client/GitblitRegistration.java
index f9d07488..c95f01ac 100644
--- a/src/main/java/com/gitblit/client/GitblitRegistration.java
+++ b/src/main/java/com/gitblit/client/GitblitRegistration.java
@@ -25,9 +25,9 @@ import com.gitblit.utils.StringUtils;
/**
* Simple class to encapsulate a Gitblit server registration.
- *
+ *
* @author James Moger
- *
+ *
*/
public class GitblitRegistration implements Serializable, Comparable<GitblitRegistration> {
diff --git a/src/main/java/com/gitblit/client/GitblitWorker.java b/src/main/java/com/gitblit/client/GitblitWorker.java
index 93c35d6b..86ec9204 100644
--- a/src/main/java/com/gitblit/client/GitblitWorker.java
+++ b/src/main/java/com/gitblit/client/GitblitWorker.java
@@ -50,6 +50,7 @@ public abstract class GitblitWorker extends SwingWorker<Boolean, Void> {
return doRequest();
}
+ @Override
protected void done() {
parent.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
try {
diff --git a/src/main/java/com/gitblit/client/IndicatorsRenderer.java b/src/main/java/com/gitblit/client/IndicatorsRenderer.java
index 44b39d01..66cce018 100644
--- a/src/main/java/com/gitblit/client/IndicatorsRenderer.java
+++ b/src/main/java/com/gitblit/client/IndicatorsRenderer.java
@@ -30,9 +30,9 @@ import com.gitblit.models.RepositoryModel;
/**
* Renders the type indicators (tickets, frozen, access restriction, etc) in a
* single cell.
- *
+ *
* @author James Moger
- *
+ *
*/
public class IndicatorsRenderer extends JPanel implements TableCellRenderer, Serializable {
@@ -53,9 +53,9 @@ public class IndicatorsRenderer extends JPanel implements TableCellRenderer, Ser
private final ImageIcon frozenIcon;
private final ImageIcon federatedIcon;
-
+
private final ImageIcon forkIcon;
-
+
private final ImageIcon sparkleshareIcon;
public IndicatorsRenderer() {
diff --git a/src/main/java/com/gitblit/client/JPalette.java b/src/main/java/com/gitblit/client/JPalette.java
index a0c2b258..47b3f4dd 100644
--- a/src/main/java/com/gitblit/client/JPalette.java
+++ b/src/main/java/com/gitblit/client/JPalette.java
@@ -58,6 +58,7 @@ public class JPalette<T> extends JPanel {
add = new JButton("->");
add.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent event) {
List<T> move = new ArrayList<T>();
if (available.getSelectedRowCount() <= 0) {
@@ -65,7 +66,7 @@ public class JPalette<T> extends JPanel {
}
for (int row : available.getSelectedRows()) {
int modelIndex = available.convertRowIndexToModel(row);
- T item = (T) availableModel.list.get(modelIndex);
+ T item = availableModel.list.get(modelIndex);
move.add(item);
}
availableModel.list.removeAll(move);
@@ -76,6 +77,7 @@ public class JPalette<T> extends JPanel {
});
subtract = new JButton("<-");
subtract.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent event) {
List<T> move = new ArrayList<T>();
if (selected.getSelectedRowCount() <= 0) {
@@ -83,7 +85,7 @@ public class JPalette<T> extends JPanel {
}
for (int row : selected.getSelectedRows()) {
int modelIndex = selected.convertRowIndexToModel(row);
- T item = (T) selectedModel.list.get(modelIndex);
+ T item = selectedModel.list.get(modelIndex);
move.add(item);
}
selectedModel.list.removeAll(move);
@@ -96,6 +98,7 @@ public class JPalette<T> extends JPanel {
up = new JButton("\u2191");
up.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent event) {
int row = selected.getSelectedRow();
if (row > 0) {
@@ -108,6 +111,7 @@ public class JPalette<T> extends JPanel {
down = new JButton("\u2193");
down.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent event) {
int row = selected.getSelectedRow();
if (row < selected.getRowCount() - 1) {
@@ -152,7 +156,7 @@ public class JPalette<T> extends JPanel {
panel.add(jsp, BorderLayout.CENTER);
return panel;
}
-
+
@Override
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
@@ -211,6 +215,7 @@ public class JPalette<T> extends JPanel {
return Translation.get("gb.name");
}
+ @Override
public Class<?> getColumnClass(int columnIndex) {
return String.class;
}
diff --git a/src/main/java/com/gitblit/client/MessageRenderer.java b/src/main/java/com/gitblit/client/MessageRenderer.java
index 2fe3415a..453c4fcf 100644
--- a/src/main/java/com/gitblit/client/MessageRenderer.java
+++ b/src/main/java/com/gitblit/client/MessageRenderer.java
@@ -36,20 +36,20 @@ import com.gitblit.models.FeedEntryModel;
/**
* Message renderer displays the short log message and then any refs in a style
* like the site.
- *
+ *
* @author James Moger
- *
+ *
*/
public class MessageRenderer extends JPanel implements TableCellRenderer, Serializable {
private static final long serialVersionUID = 1L;
private final GitblitClient gitblit;
-
+
private final ImageIcon mergeIcon;
-
+
private final ImageIcon blankIcon;
-
+
private final JLabel messageLabel;
private final JLabel headLabel;
@@ -67,12 +67,12 @@ public class MessageRenderer extends JPanel implements TableCellRenderer, Serial
public MessageRenderer(GitblitClient gitblit) {
super(new FlowLayout(FlowLayout.LEFT, Utils.MARGIN, 1));
this.gitblit = gitblit;
-
+
mergeIcon = new ImageIcon(getClass().getResource("/commit_merge_16x16.png"));
blankIcon = new ImageIcon(getClass().getResource("/blank.png"));
messageLabel = new JLabel();
-
+
headLabel = newRefLabel();
branchLabel = newRefLabel();
remoteLabel = newRefLabel();
@@ -85,7 +85,7 @@ public class MessageRenderer extends JPanel implements TableCellRenderer, Serial
add(tagLabel);
}
- private JLabel newRefLabel() {
+ private JLabel newRefLabel() {
JLabel label = new JLabel();
label.setOpaque(true);
Font font = label.getFont();
@@ -131,6 +131,7 @@ public class MessageRenderer extends JPanel implements TableCellRenderer, Serial
label.setVisible(true);
}
+ @Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
boolean hasFocus, int row, int column) {
if (isSelected)
diff --git a/src/main/java/com/gitblit/client/NameRenderer.java b/src/main/java/com/gitblit/client/NameRenderer.java
index 4cbb5906..29b8f9b8 100644
--- a/src/main/java/com/gitblit/client/NameRenderer.java
+++ b/src/main/java/com/gitblit/client/NameRenderer.java
@@ -26,9 +26,9 @@ import javax.swing.table.DefaultTableCellRenderer;
/**
* Repository name cell renderer. This renderer shows the group name in a gray
* color and accentuates the repository name in a cornflower blue color.
- *
+ *
* @author James Moger
- *
+ *
*/
public class NameRenderer extends DefaultTableCellRenderer implements ListCellRenderer {
@@ -56,6 +56,7 @@ public class NameRenderer extends DefaultTableCellRenderer implements ListCellRe
return sb.toString();
}
+ @Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
diff --git a/src/main/java/com/gitblit/client/PropertiesTableModel.java b/src/main/java/com/gitblit/client/PropertiesTableModel.java
index 0c803f47..9941ee43 100644
--- a/src/main/java/com/gitblit/client/PropertiesTableModel.java
+++ b/src/main/java/com/gitblit/client/PropertiesTableModel.java
@@ -25,9 +25,9 @@ import javax.swing.table.AbstractTableModel;
/**
* Table model of a map of properties.
- *
+ *
* @author James Moger
- *
+ *
*/
public class PropertiesTableModel extends AbstractTableModel {
@@ -82,11 +82,12 @@ public class PropertiesTableModel extends AbstractTableModel {
/**
* Returns <code>Object.class</code> regardless of <code>columnIndex</code>.
- *
+ *
* @param columnIndex
* the column being queried
* @return the Object.class
*/
+ @Override
public Class<?> getColumnClass(int columnIndex) {
return String.class;
}
diff --git a/src/main/java/com/gitblit/client/RegistrantPermissionsPanel.java b/src/main/java/com/gitblit/client/RegistrantPermissionsPanel.java
index 98dbfb72..3d5aa4a7 100644
--- a/src/main/java/com/gitblit/client/RegistrantPermissionsPanel.java
+++ b/src/main/java/com/gitblit/client/RegistrantPermissionsPanel.java
@@ -46,7 +46,7 @@ import com.gitblit.utils.StringUtils;
public class RegistrantPermissionsPanel extends JPanel {
private static final long serialVersionUID = 1L;
-
+
private JTable permissionsTable;
private RegistrantPermissionsTableModel tableModel;
@@ -67,7 +67,7 @@ public class RegistrantPermissionsPanel extends JPanel {
permissionsTable = Utils.newTable(tableModel, Utils.DATE_FORMAT, new RowRenderer() {
Color clear = new Color(0, 0, 0, 0);
Color iceGray = new Color(0xf0, 0xf0, 0xf0);
-
+
@Override
public void prepareRow(Component c, boolean isSelected, int row, int column) {
if (isSelected) {
@@ -85,19 +85,20 @@ public class RegistrantPermissionsPanel extends JPanel {
permissionsTable.setPreferredScrollableViewportSize(new Dimension(400, 150));
JScrollPane jsp = new JScrollPane(permissionsTable);
add(jsp, BorderLayout.CENTER);
-
+
permissionsTable.getColumnModel().getColumn(RegistrantPermissionsTableModel.Columns.Registrant.ordinal())
.setCellRenderer(new NameRenderer());
permissionsTable.getColumnModel().getColumn(RegistrantPermissionsTableModel.Columns.Type.ordinal())
.setCellRenderer(new PermissionTypeRenderer());
permissionsTable.getColumnModel().getColumn(RegistrantPermissionsTableModel.Columns.Permission.ordinal())
.setCellEditor(new AccessPermissionEditor());
-
+
registrantModel = new DefaultComboBoxModel();
registrantSelector = new JComboBox(registrantModel);
permissionSelector = new JComboBox(AccessPermission.NEWPERMISSIONS);
addButton = new JButton(Translation.get("gb.add"));
addButton.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
if (registrantSelector.getSelectedIndex() < 0) {
return;
@@ -105,7 +106,7 @@ public class RegistrantPermissionsPanel extends JPanel {
if (permissionSelector.getSelectedIndex() < 0) {
return;
}
-
+
RegistrantAccessPermission rp = new RegistrantAccessPermission(registrantType);
rp.registrant = registrantSelector.getSelectedItem().toString();
rp.permission = (AccessPermission) permissionSelector.getSelectedItem();
@@ -119,16 +120,16 @@ public class RegistrantPermissionsPanel extends JPanel {
tableModel.permissions.add(rp);
// resort permissions after insert to convey idea of eval order
Collections.sort(tableModel.permissions);
-
+
registrantModel.removeElement(rp.registrant);
registrantSelector.setSelectedIndex(-1);
registrantSelector.invalidate();
addPanel.setVisible(registrantModel.getSize() > 0);
-
+
tableModel.fireTableDataChanged();
}
});
-
+
addPanel = new JPanel();
addPanel.add(registrantSelector);
addPanel.add(permissionSelector);
@@ -172,7 +173,7 @@ public class RegistrantPermissionsPanel extends JPanel {
registrantModel.addElement(registrant);
}
tableModel.setPermissions(permissions);
-
+
registrantSelector.setSelectedIndex(-1);
permissionSelector.setSelectedIndex(-1);
addPanel.setVisible(filtered.size() > 0);
@@ -181,16 +182,16 @@ public class RegistrantPermissionsPanel extends JPanel {
public List<RegistrantAccessPermission> getPermissions() {
return tableModel.permissions;
}
-
+
private class AccessPermissionEditor extends DefaultCellEditor {
-
+
private static final long serialVersionUID = 1L;
public AccessPermissionEditor() {
- super(new JComboBox(AccessPermission.values()));
+ super(new JComboBox(AccessPermission.values()));
}
}
-
+
private class PermissionTypeRenderer extends DefaultTableCellRenderer {
private static final long serialVersionUID = 1L;
diff --git a/src/main/java/com/gitblit/client/RegistrantPermissionsTableModel.java b/src/main/java/com/gitblit/client/RegistrantPermissionsTableModel.java
index 28d25345..402104df 100644
--- a/src/main/java/com/gitblit/client/RegistrantPermissionsTableModel.java
+++ b/src/main/java/com/gitblit/client/RegistrantPermissionsTableModel.java
@@ -25,9 +25,9 @@ import com.gitblit.models.RegistrantAccessPermission;
/**
* Table model of a registrant permissions.
- *
+ *
* @author James Moger
- *
+ *
*/
public class RegistrantPermissionsTableModel extends AbstractTableModel {
@@ -82,11 +82,12 @@ public class RegistrantPermissionsTableModel extends AbstractTableModel {
/**
* Returns <code>Object.class</code> regardless of <code>columnIndex</code>.
- *
+ *
* @param columnIndex
* the column being queried
* @return the Object.class
*/
+ @Override
public Class<?> getColumnClass(int columnIndex) {
if (columnIndex == Columns.Permission.ordinal()) {
return AccessPermission.class;
@@ -95,7 +96,7 @@ public class RegistrantPermissionsTableModel extends AbstractTableModel {
}
return String.class;
}
-
+
@Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
if (columnIndex == Columns.Permission.ordinal()) {
@@ -123,7 +124,7 @@ public class RegistrantPermissionsTableModel extends AbstractTableModel {
}
return null;
}
-
+
@Override
public void setValueAt(Object o, int rowIndex, int columnIndex) {
RegistrantAccessPermission rp = permissions.get(rowIndex);
diff --git a/src/main/java/com/gitblit/client/RegistrationsDialog.java b/src/main/java/com/gitblit/client/RegistrationsDialog.java
index 9550e97a..edbc8623 100644
--- a/src/main/java/com/gitblit/client/RegistrationsDialog.java
+++ b/src/main/java/com/gitblit/client/RegistrationsDialog.java
@@ -41,9 +41,9 @@ import javax.swing.event.ListSelectionListener;
/**
* Displays a list of registrations and allows management of server
* registrations.
- *
+ *
* @author James Moger
- *
+ *
*/
public class RegistrationsDialog extends JDialog {
@@ -82,6 +82,7 @@ public class RegistrationsDialog extends JDialog {
KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
JRootPane rootPane = new JRootPane();
rootPane.registerKeyboardAction(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent actionEvent) {
setVisible(false);
}
@@ -98,6 +99,7 @@ public class RegistrationsDialog extends JDialog {
.getColumnName(RegistrationsTableModel.Columns.Name.ordinal());
registrationsTable.getColumn(id).setCellRenderer(nameRenderer);
registrationsTable.addMouseListener(new MouseAdapter() {
+ @Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
login();
@@ -107,6 +109,7 @@ public class RegistrationsDialog extends JDialog {
final JButton create = new JButton(Translation.get("gb.create"));
create.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent event) {
create();
}
@@ -115,6 +118,7 @@ public class RegistrationsDialog extends JDialog {
final JButton login = new JButton(Translation.get("gb.login"));
login.setEnabled(false);
login.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent event) {
login();
}
@@ -123,6 +127,7 @@ public class RegistrationsDialog extends JDialog {
final JButton edit = new JButton(Translation.get("gb.edit"));
edit.setEnabled(false);
edit.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent event) {
edit();
}
@@ -131,6 +136,7 @@ public class RegistrationsDialog extends JDialog {
final JButton delete = new JButton(Translation.get("gb.delete"));
delete.setEnabled(false);
delete.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent event) {
delete();
}
@@ -162,6 +168,7 @@ public class RegistrationsDialog extends JDialog {
private static final long serialVersionUID = 1L;
+ @Override
public Insets getInsets() {
return insets;
}
diff --git a/src/main/java/com/gitblit/client/RegistrationsTableModel.java b/src/main/java/com/gitblit/client/RegistrationsTableModel.java
index 8c6b34ff..4c106bc7 100644
--- a/src/main/java/com/gitblit/client/RegistrationsTableModel.java
+++ b/src/main/java/com/gitblit/client/RegistrationsTableModel.java
@@ -23,9 +23,9 @@ import javax.swing.table.AbstractTableModel;
/**
* Table model of a list of Gitblit server registrations.
- *
+ *
* @author James Moger
- *
+ *
*/
public class RegistrationsTableModel extends AbstractTableModel {
@@ -73,11 +73,12 @@ public class RegistrationsTableModel extends AbstractTableModel {
/**
* Returns <code>Object.class</code> regardless of <code>columnIndex</code>.
- *
+ *
* @param columnIndex
* the column being queried
* @return the Object.class
*/
+ @Override
public Class<?> getColumnClass(int columnIndex) {
if (columnIndex == Columns.Last_Login.ordinal()) {
return Date.class;
diff --git a/src/main/java/com/gitblit/client/RepositoriesPanel.java b/src/main/java/com/gitblit/client/RepositoriesPanel.java
index 64bde9b8..0fab934d 100644
--- a/src/main/java/com/gitblit/client/RepositoriesPanel.java
+++ b/src/main/java/com/gitblit/client/RepositoriesPanel.java
@@ -57,9 +57,9 @@ import com.gitblit.utils.StringUtils;
/**
* RSS Feeds Panel displays recent entries and launches the browser to view the
* commit. commitdiff, or tree of a commit.
- *
+ *
* @author James Moger
- *
+ *
*/
public abstract class RepositoriesPanel extends JPanel {
@@ -95,6 +95,7 @@ public abstract class RepositoriesPanel extends JPanel {
final JButton browseRepository = new JButton(Translation.get("gb.browse"));
browseRepository.setEnabled(false);
browseRepository.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
RepositoryModel model = getSelectedRepositories().get(0);
String url = gitblit.getURL("summary", model.name, null);
@@ -104,13 +105,15 @@ public abstract class RepositoriesPanel extends JPanel {
JButton refreshRepositories = new JButton(Translation.get("gb.refresh"));
refreshRepositories.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
refreshRepositories();
}
});
-
+
clearCache = new JButton(Translation.get("gb.clearCache"));
clearCache.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
clearCache();
}
@@ -118,6 +121,7 @@ public abstract class RepositoriesPanel extends JPanel {
createRepository = new JButton(Translation.get("gb.create"));
createRepository.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
createRepository();
}
@@ -126,6 +130,7 @@ public abstract class RepositoriesPanel extends JPanel {
editRepository = new JButton(Translation.get("gb.edit"));
editRepository.setEnabled(false);
editRepository.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
editRepository(getSelectedRepositories().get(0));
}
@@ -134,6 +139,7 @@ public abstract class RepositoriesPanel extends JPanel {
delRepository = new JButton(Translation.get("gb.delete"));
delRepository.setEnabled(false);
delRepository.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
deleteRepositories(getSelectedRepositories());
}
@@ -142,6 +148,7 @@ public abstract class RepositoriesPanel extends JPanel {
final JButton subscribeRepository = new JButton(Translation.get("gb.subscribe") + "...");
subscribeRepository.setEnabled(false);
subscribeRepository.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
List<FeedModel> feeds = gitblit.getAvailableFeeds(getSelectedRepositories().get(0));
subscribeFeeds(feeds);
@@ -151,6 +158,7 @@ public abstract class RepositoriesPanel extends JPanel {
final JButton logRepository = new JButton(Translation.get("gb.log") + "...");
logRepository.setEnabled(false);
logRepository.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
RepositoryModel model = getSelectedRepositories().get(0);
showSearchDialog(false, model);
@@ -160,6 +168,7 @@ public abstract class RepositoriesPanel extends JPanel {
final JButton searchRepository = new JButton(Translation.get("gb.search") + "...");
searchRepository.setEnabled(false);
searchRepository.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
RepositoryModel model = getSelectedRepositories().get(0);
showSearchDialog(true, model);
@@ -223,6 +232,7 @@ public abstract class RepositoriesPanel extends JPanel {
});
table.addMouseListener(new MouseAdapter() {
+ @Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2 && gitblit.allowManagement()) {
editRepository(getSelectedRepositories().get(0));
@@ -232,11 +242,13 @@ public abstract class RepositoriesPanel extends JPanel {
filterTextfield = new JTextField();
filterTextfield.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
filterRepositories(filterTextfield.getText());
}
});
filterTextfield.addKeyListener(new KeyAdapter() {
+ @Override
public void keyReleased(KeyEvent e) {
filterRepositories(filterTextfield.getText());
}
@@ -318,6 +330,7 @@ public abstract class RepositoriesPanel extends JPanel {
return;
}
RowFilter<RepositoriesTableModel, Object> containsFilter = new RowFilter<RepositoriesTableModel, Object>() {
+ @Override
public boolean include(Entry<? extends RepositoriesTableModel, ? extends Object> entry) {
for (int i = entry.getValueCount() - 1; i >= 0; i--) {
if (entry.getStringValue(i).toLowerCase().contains(fragment.toLowerCase())) {
@@ -359,7 +372,7 @@ public abstract class RepositoriesPanel extends JPanel {
};
worker.execute();
}
-
+
protected void clearCache() {
GitblitWorker worker = new GitblitWorker(RepositoriesPanel.this,
RpcRequest.CLEAR_REPOSITORY_CACHE) {
@@ -383,7 +396,7 @@ public abstract class RepositoriesPanel extends JPanel {
/**
* Displays the create repository dialog and fires a SwingWorker to update
* the server, if appropriate.
- *
+ *
*/
protected void createRepository() {
EditRepositoryDialog dialog = new EditRepositoryDialog(gitblit.getProtocolVersion());
@@ -444,7 +457,7 @@ public abstract class RepositoriesPanel extends JPanel {
/**
* Displays the edit repository dialog and fires a SwingWorker to update the
* server, if appropriate.
- *
+ *
* @param repository
*/
protected void editRepository(final RepositoryModel repository) {
diff --git a/src/main/java/com/gitblit/client/RepositoriesTableModel.java b/src/main/java/com/gitblit/client/RepositoriesTableModel.java
index 6b295a4b..0d26e42c 100644
--- a/src/main/java/com/gitblit/client/RepositoriesTableModel.java
+++ b/src/main/java/com/gitblit/client/RepositoriesTableModel.java
@@ -27,9 +27,9 @@ import com.gitblit.utils.ArrayUtils;
/**
* Table model of a list of repositories.
- *
+ *
* @author James Moger
- *
+ *
*/
public class RepositoriesTableModel extends AbstractTableModel {
@@ -85,11 +85,12 @@ public class RepositoriesTableModel extends AbstractTableModel {
/**
* Returns <code>Object.class</code> regardless of <code>columnIndex</code>.
- *
+ *
* @param columnIndex
* the column being queried
* @return the Object.class
*/
+ @Override
public Class<?> getColumnClass(int columnIndex) {
Columns col = Columns.values()[columnIndex];
switch (col) {
diff --git a/src/main/java/com/gitblit/client/SearchDialog.java b/src/main/java/com/gitblit/client/SearchDialog.java
index 829bc52a..71204cba 100644
--- a/src/main/java/com/gitblit/client/SearchDialog.java
+++ b/src/main/java/com/gitblit/client/SearchDialog.java
@@ -51,9 +51,9 @@ import com.gitblit.utils.StringUtils;
/**
* The search dialog allows searching of a repository branch. This matches the
* search implementation of the site.
- *
+ *
* @author James Moger
- *
+ *
*/
public class SearchDialog extends JFrame {
@@ -103,6 +103,7 @@ public class SearchDialog extends JFrame {
prev.setToolTipText(Translation.get("gb.pagePrevious"));
prev.setEnabled(false);
prev.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
search(--page);
}
@@ -112,6 +113,7 @@ public class SearchDialog extends JFrame {
next.setToolTipText(Translation.get("gb.pageNext"));
next.setEnabled(false);
next.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
search(++page);
}
@@ -119,6 +121,7 @@ public class SearchDialog extends JFrame {
final JButton search = new JButton(Translation.get(isSearch ? "gb.search" : "gb.refresh"));
search.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
search(0);
}
@@ -127,6 +130,7 @@ public class SearchDialog extends JFrame {
final JButton viewCommit = new JButton(Translation.get("gb.view"));
viewCommit.setEnabled(false);
viewCommit.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
viewCommit();
}
@@ -135,6 +139,7 @@ public class SearchDialog extends JFrame {
final JButton viewCommitDiff = new JButton(Translation.get("gb.commitdiff"));
viewCommitDiff.setEnabled(false);
viewCommitDiff.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
viewCommitDiff();
}
@@ -143,6 +148,7 @@ public class SearchDialog extends JFrame {
final JButton viewTree = new JButton(Translation.get("gb.tree"));
viewTree.setEnabled(false);
viewTree.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
viewTree();
}
@@ -171,6 +177,7 @@ public class SearchDialog extends JFrame {
table.getColumn(name).setCellRenderer(new MessageRenderer());
table.addMouseListener(new MouseAdapter() {
+ @Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
if (e.isControlDown()) {
@@ -199,6 +206,7 @@ public class SearchDialog extends JFrame {
repositorySelector.setRenderer(nameRenderer);
repositorySelector.setForeground(nameRenderer.getForeground());
repositorySelector.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent event) {
// repopulate the branch list based on repository selection
// preserve branch selection, if possible
@@ -234,6 +242,7 @@ public class SearchDialog extends JFrame {
searchFragment = new JTextField(25);
searchFragment.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent event) {
search(0);
}
diff --git a/src/main/java/com/gitblit/client/SettingCellRenderer.java b/src/main/java/com/gitblit/client/SettingCellRenderer.java
index d164fb1a..2f52ddb0 100644
--- a/src/main/java/com/gitblit/client/SettingCellRenderer.java
+++ b/src/main/java/com/gitblit/client/SettingCellRenderer.java
@@ -27,9 +27,9 @@ import com.gitblit.models.SettingModel;
/**
* SettingModel cell renderer that indicates if a setting is the default or
* modified.
- *
+ *
* @author James Moger
- *
+ *
*/
public class SettingCellRenderer extends DefaultTableCellRenderer {
@@ -44,6 +44,7 @@ public class SettingCellRenderer extends DefaultTableCellRenderer {
modifiedFont = defaultFont.deriveFont(Font.BOLD);
}
+ @Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
diff --git a/src/main/java/com/gitblit/client/SettingPanel.java b/src/main/java/com/gitblit/client/SettingPanel.java
index 6da09e18..9e644004 100644
--- a/src/main/java/com/gitblit/client/SettingPanel.java
+++ b/src/main/java/com/gitblit/client/SettingPanel.java
@@ -33,7 +33,7 @@ import com.gitblit.utils.StringUtils;
/**
* This panel displays the metadata for a particular setting.
- *
+ *
* @author James Moger
*/
public class SettingPanel extends JPanel {
diff --git a/src/main/java/com/gitblit/client/SettingsPanel.java b/src/main/java/com/gitblit/client/SettingsPanel.java
index b0adc0c7..b4129fa0 100644
--- a/src/main/java/com/gitblit/client/SettingsPanel.java
+++ b/src/main/java/com/gitblit/client/SettingsPanel.java
@@ -50,9 +50,9 @@ import com.gitblit.utils.StringUtils;
/**
* Settings panel displays a list of server settings and their associated
* metadata. This panel also allows editing of a setting.
- *
+ *
* @author James Moger
- *
+ *
*/
public class SettingsPanel extends JPanel {
@@ -79,6 +79,7 @@ public class SettingsPanel extends JPanel {
private void initialize() {
JButton refreshSettings = new JButton(Translation.get("gb.refresh"));
refreshSettings.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
refreshSettings();
}
@@ -86,6 +87,7 @@ public class SettingsPanel extends JPanel {
final JButton editSetting = new JButton(Translation.get("gb.edit"));
editSetting.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
int viewRow = table.getSelectedRow();
int modelRow = table.convertRowIndexToModel(viewRow);
@@ -125,6 +127,7 @@ public class SettingsPanel extends JPanel {
}
});
table.addMouseListener(new MouseAdapter() {
+ @Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
int viewRow = table.getSelectedRow();
@@ -137,11 +140,13 @@ public class SettingsPanel extends JPanel {
filterTextfield = new JTextField();
filterTextfield.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
filterSettings(filterTextfield.getText());
}
});
filterTextfield.addKeyListener(new KeyAdapter() {
+ @Override
public void keyReleased(KeyEvent e) {
filterSettings(filterTextfield.getText());
}
@@ -166,7 +171,7 @@ public class SettingsPanel extends JPanel {
add(settingsTablePanel, BorderLayout.CENTER);
add(settingsControls, BorderLayout.SOUTH);
}
-
+
@Override
public void requestFocus() {
filterTextfield.requestFocus();
@@ -192,6 +197,7 @@ public class SettingsPanel extends JPanel {
return;
}
RowFilter<SettingsTableModel, Object> containsFilter = new RowFilter<SettingsTableModel, Object>() {
+ @Override
public boolean include(Entry<? extends SettingsTableModel, ? extends Object> entry) {
for (int i = entry.getValueCount() - 1; i >= 0; i--) {
if (entry.getStringValue(i).toLowerCase().contains(fragment.toLowerCase())) {
diff --git a/src/main/java/com/gitblit/client/SettingsTableModel.java b/src/main/java/com/gitblit/client/SettingsTableModel.java
index f14eae4b..a781c697 100644
--- a/src/main/java/com/gitblit/client/SettingsTableModel.java
+++ b/src/main/java/com/gitblit/client/SettingsTableModel.java
@@ -26,9 +26,9 @@ import com.gitblit.models.SettingModel;
/**
* Table model of Map<String, SettingModel>.
- *
+ *
* @author James Moger
- *
+ *
*/
public class SettingsTableModel extends AbstractTableModel {
@@ -89,11 +89,12 @@ public class SettingsTableModel extends AbstractTableModel {
/**
* Returns <code>Object.class</code> regardless of <code>columnIndex</code>.
- *
+ *
* @param columnIndex
* the column being queried
* @return the Object.class
*/
+ @Override
public Class<?> getColumnClass(int columnIndex) {
if (Columns.Value.ordinal() == columnIndex) {
return SettingModel.class;
diff --git a/src/main/java/com/gitblit/client/StatusPanel.java b/src/main/java/com/gitblit/client/StatusPanel.java
index 6d004f16..2c061c2d 100644
--- a/src/main/java/com/gitblit/client/StatusPanel.java
+++ b/src/main/java/com/gitblit/client/StatusPanel.java
@@ -38,7 +38,7 @@ import com.gitblit.utils.ByteFormat;
/**
* This panel displays the server status.
- *
+ *
* @author James Moger
*/
public class StatusPanel extends JPanel {
@@ -65,6 +65,7 @@ public class StatusPanel extends JPanel {
private void initialize() {
JButton refreshStatus = new JButton(Translation.get("gb.refresh"));
refreshStatus.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
refreshStatus();
}
@@ -153,7 +154,7 @@ public class StatusPanel extends JPanel {
ServerStatus status = gitblit.getStatus();
header.setText(Translation.get("gb.status"));
version.setText(Constants.NAME + (status.isGO ? " GO v" : " WAR v") + status.version);
- releaseDate.setText(status.releaseDate);
+ releaseDate.setText(status.releaseDate);
bootDate.setText(status.bootDate.toString() + " (" + Translation.getTimeUtils().timeAgo(status.bootDate)
+ ")");
url.setText(gitblit.url);
diff --git a/src/main/java/com/gitblit/client/SubscribedRepositoryRenderer.java b/src/main/java/com/gitblit/client/SubscribedRepositoryRenderer.java
index 9943333f..37769f93 100644
--- a/src/main/java/com/gitblit/client/SubscribedRepositoryRenderer.java
+++ b/src/main/java/com/gitblit/client/SubscribedRepositoryRenderer.java
@@ -25,9 +25,9 @@ import com.gitblit.models.RepositoryModel;
/**
* Displays a subscribed icon on the left of the repository name, if there is at
* least one subscribed branch.
- *
+ *
* @author James Moger
- *
+ *
*/
public class SubscribedRepositoryRenderer extends NameRenderer {
@@ -46,6 +46,7 @@ public class SubscribedRepositoryRenderer extends NameRenderer {
subscribedIcon = new ImageIcon(getClass().getResource("/bullet_feed.png"));
}
+ @Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
diff --git a/src/main/java/com/gitblit/client/SubscriptionsDialog.java b/src/main/java/com/gitblit/client/SubscriptionsDialog.java
index 5ae836a5..f348e90b 100644
--- a/src/main/java/com/gitblit/client/SubscriptionsDialog.java
+++ b/src/main/java/com/gitblit/client/SubscriptionsDialog.java
@@ -40,9 +40,9 @@ import com.gitblit.models.FeedModel;
/**
* Displays a list of repository branches and allows the user to check or
* uncheck branches.
- *
+ *
* @author James Moger
- *
+ *
*/
public abstract class SubscriptionsDialog extends JDialog {
@@ -68,6 +68,7 @@ public abstract class SubscriptionsDialog extends JDialog {
KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
JRootPane rootPane = new JRootPane();
rootPane.registerKeyboardAction(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent actionEvent) {
setVisible(false);
}
@@ -111,6 +112,7 @@ public abstract class SubscriptionsDialog extends JDialog {
final JButton cancel = new JButton(Translation.get("gb.cancel"));
cancel.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent event) {
setVisible(false);
}
@@ -118,6 +120,7 @@ public abstract class SubscriptionsDialog extends JDialog {
final JButton save = new JButton(Translation.get("gb.save"));
save.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent event) {
save();
}
@@ -141,6 +144,7 @@ public abstract class SubscriptionsDialog extends JDialog {
private static final long serialVersionUID = 1L;
+ @Override
public Insets getInsets() {
return insets;
}
diff --git a/src/main/java/com/gitblit/client/TeamsPanel.java b/src/main/java/com/gitblit/client/TeamsPanel.java
index 92182222..4f52fde0 100644
--- a/src/main/java/com/gitblit/client/TeamsPanel.java
+++ b/src/main/java/com/gitblit/client/TeamsPanel.java
@@ -47,9 +47,9 @@ import com.gitblit.utils.StringUtils;
/**
* Users panel displays a list of user accounts and allows management of those
* accounts.
- *
+ *
* @author James Moger
- *
+ *
*/
public abstract class TeamsPanel extends JPanel {
@@ -76,6 +76,7 @@ public abstract class TeamsPanel extends JPanel {
private void initialize() {
JButton refreshTeams = new JButton(Translation.get("gb.refresh"));
refreshTeams.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
refreshTeams();
}
@@ -83,6 +84,7 @@ public abstract class TeamsPanel extends JPanel {
JButton createTeam = new JButton(Translation.get("gb.create"));
createTeam.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
createTeam();
}
@@ -91,6 +93,7 @@ public abstract class TeamsPanel extends JPanel {
final JButton editTeam = new JButton(Translation.get("gb.edit"));
editTeam.setEnabled(false);
editTeam.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
editTeam(getSelectedTeams().get(0));
}
@@ -99,6 +102,7 @@ public abstract class TeamsPanel extends JPanel {
final JButton delTeam = new JButton(Translation.get("gb.delete"));
delTeam.setEnabled(false);
delTeam.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
deleteTeams(getSelectedTeams());
}
@@ -136,6 +140,7 @@ public abstract class TeamsPanel extends JPanel {
});
table.addMouseListener(new MouseAdapter() {
+ @Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
editTeam(getSelectedTeams().get(0));
@@ -145,11 +150,13 @@ public abstract class TeamsPanel extends JPanel {
filterTextfield = new JTextField();
filterTextfield.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
filterTeams(filterTextfield.getText());
}
});
filterTextfield.addKeyListener(new KeyAdapter() {
+ @Override
public void keyReleased(KeyEvent e) {
filterTeams(filterTextfield.getText());
}
@@ -204,6 +211,7 @@ public abstract class TeamsPanel extends JPanel {
return;
}
RowFilter<TeamsTableModel, Object> containsFilter = new RowFilter<TeamsTableModel, Object>() {
+ @Override
public boolean include(Entry<? extends TeamsTableModel, ? extends Object> entry) {
for (int i = entry.getValueCount() - 1; i >= 0; i--) {
if (entry.getStringValue(i).toLowerCase().contains(fragment.toLowerCase())) {
@@ -247,7 +255,7 @@ public abstract class TeamsPanel extends JPanel {
/**
* Displays the create team dialog and fires a SwingWorker to update the
* server, if appropriate.
- *
+ *
*/
protected void createTeam() {
EditTeamDialog dialog = new EditTeamDialog(gitblit.getProtocolVersion(),
@@ -296,7 +304,7 @@ public abstract class TeamsPanel extends JPanel {
/**
* Displays the edit team dialog and fires a SwingWorker to update the
* server, if appropriate.
- *
+ *
* @param user
*/
protected void editTeam(final TeamModel team) {
diff --git a/src/main/java/com/gitblit/client/TeamsTableModel.java b/src/main/java/com/gitblit/client/TeamsTableModel.java
index e6d8a945..bc43a6cd 100644
--- a/src/main/java/com/gitblit/client/TeamsTableModel.java
+++ b/src/main/java/com/gitblit/client/TeamsTableModel.java
@@ -25,9 +25,9 @@ import com.gitblit.models.TeamModel;
/**
* Table model of a list of teams.
- *
+ *
* @author James Moger
- *
+ *
*/
public class TeamsTableModel extends AbstractTableModel {
@@ -79,11 +79,12 @@ public class TeamsTableModel extends AbstractTableModel {
/**
* Returns <code>Object.class</code> regardless of <code>columnIndex</code>.
- *
+ *
* @param columnIndex
* the column being queried
* @return the Object.class
*/
+ @Override
public Class<?> getColumnClass(int columnIndex) {
return String.class;
}
diff --git a/src/main/java/com/gitblit/client/Translation.java b/src/main/java/com/gitblit/client/Translation.java
index 9f643db4..87e2b83e 100644
--- a/src/main/java/com/gitblit/client/Translation.java
+++ b/src/main/java/com/gitblit/client/Translation.java
@@ -22,14 +22,14 @@ import com.gitblit.utils.TimeUtils;
/**
* Loads the Gitblit language resource file.
- *
+ *
* @author James Moger
- *
+ *
*/
public class Translation {
private final static ResourceBundle translation;
-
+
private final static TimeUtils timeUtils;
static {
@@ -42,7 +42,7 @@ public class Translation {
bundle = ResourceBundle.getBundle("GitBlitWebApp");
}
translation = bundle;
-
+
timeUtils = new TimeUtils(translation, null);
}
@@ -52,7 +52,7 @@ public class Translation {
}
return key;
}
-
+
public static TimeUtils getTimeUtils() {
return timeUtils;
}
diff --git a/src/main/java/com/gitblit/client/UsersPanel.java b/src/main/java/com/gitblit/client/UsersPanel.java
index c53a5791..f947e696 100644
--- a/src/main/java/com/gitblit/client/UsersPanel.java
+++ b/src/main/java/com/gitblit/client/UsersPanel.java
@@ -48,9 +48,9 @@ import com.gitblit.utils.StringUtils;
/**
* Users panel displays a list of user accounts and allows management of those
* accounts.
- *
+ *
* @author James Moger
- *
+ *
*/
public abstract class UsersPanel extends JPanel {
@@ -77,6 +77,7 @@ public abstract class UsersPanel extends JPanel {
private void initialize() {
JButton refreshUsers = new JButton(Translation.get("gb.refresh"));
refreshUsers.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
refreshUsers();
}
@@ -84,6 +85,7 @@ public abstract class UsersPanel extends JPanel {
JButton createUser = new JButton(Translation.get("gb.create"));
createUser.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
createUser();
}
@@ -92,6 +94,7 @@ public abstract class UsersPanel extends JPanel {
final JButton editUser = new JButton(Translation.get("gb.edit"));
editUser.setEnabled(false);
editUser.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
editUser(getSelectedUsers().get(0));
}
@@ -100,6 +103,7 @@ public abstract class UsersPanel extends JPanel {
final JButton delUser = new JButton(Translation.get("gb.delete"));
delUser.setEnabled(false);
delUser.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
deleteUsers(getSelectedUsers());
}
@@ -111,7 +115,7 @@ public abstract class UsersPanel extends JPanel {
table = Utils.newTable(tableModel, Utils.DATE_FORMAT);
String name = table.getColumnName(UsersTableModel.Columns.Name.ordinal());
table.getColumn(name).setCellRenderer(nameRenderer);
-
+
int w = 130;
name = table.getColumnName(UsersTableModel.Columns.Type.ordinal());
table.getColumn(name).setMinWidth(w);
@@ -122,7 +126,7 @@ public abstract class UsersPanel extends JPanel {
name = table.getColumnName(UsersTableModel.Columns.Repositories.ordinal());
table.getColumn(name).setMinWidth(w);
table.getColumn(name).setMaxWidth(w);
-
+
table.setRowSorter(defaultSorter);
table.getRowSorter().toggleSortOrder(UsersTableModel.Columns.Name.ordinal());
table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@@ -140,6 +144,7 @@ public abstract class UsersPanel extends JPanel {
});
table.addMouseListener(new MouseAdapter() {
+ @Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
editUser(getSelectedUsers().get(0));
@@ -149,11 +154,13 @@ public abstract class UsersPanel extends JPanel {
filterTextfield = new JTextField();
filterTextfield.addActionListener(new ActionListener() {
+ @Override
public void actionPerformed(ActionEvent e) {
filterUsers(filterTextfield.getText());
}
});
filterTextfield.addKeyListener(new KeyAdapter() {
+ @Override
public void keyReleased(KeyEvent e) {
filterUsers(filterTextfield.getText());
}
@@ -191,7 +198,7 @@ public abstract class UsersPanel extends JPanel {
}
protected abstract void updateTeamsTable();
-
+
protected void updateTable(boolean pack) {
tableModel.list.clear();
tableModel.list.addAll(gitblit.getUsers());
@@ -208,6 +215,7 @@ public abstract class UsersPanel extends JPanel {
return;
}
RowFilter<UsersTableModel, Object> containsFilter = new RowFilter<UsersTableModel, Object>() {
+ @Override
public boolean include(Entry<? extends UsersTableModel, ? extends Object> entry) {
for (int i = entry.getValueCount() - 1; i >= 0; i--) {
if (entry.getStringValue(i).toLowerCase().contains(fragment.toLowerCase())) {
@@ -251,7 +259,7 @@ public abstract class UsersPanel extends JPanel {
/**
* Displays the create user dialog and fires a SwingWorker to update the
* server, if appropriate.
- *
+ *
*/
protected void createUser() {
EditUserDialog dialog = new EditUserDialog(gitblit.getProtocolVersion(),
@@ -300,7 +308,7 @@ public abstract class UsersPanel extends JPanel {
/**
* Displays the edit user dialog and fires a SwingWorker to update the
* server, if appropriate.
- *
+ *
* @param user
*/
protected void editUser(final UserModel user) {
diff --git a/src/main/java/com/gitblit/client/UsersTableModel.java b/src/main/java/com/gitblit/client/UsersTableModel.java
index 439d5afb..aedb9cbb 100644
--- a/src/main/java/com/gitblit/client/UsersTableModel.java
+++ b/src/main/java/com/gitblit/client/UsersTableModel.java
@@ -25,9 +25,9 @@ import com.gitblit.models.UserModel;
/**
* Table model of a list of users.
- *
+ *
* @author James Moger
- *
+ *
*/
public class UsersTableModel extends AbstractTableModel {
@@ -83,11 +83,12 @@ public class UsersTableModel extends AbstractTableModel {
/**
* Returns <code>Object.class</code> regardless of <code>columnIndex</code>.
- *
+ *
* @param columnIndex
* the column being queried
* @return the Object.class
*/
+ @Override
public Class<?> getColumnClass(int columnIndex) {
return String.class;
}
diff --git a/src/main/java/com/gitblit/client/Utils.java b/src/main/java/com/gitblit/client/Utils.java
index 1e6ab2bf..ad3a307d 100644
--- a/src/main/java/com/gitblit/client/Utils.java
+++ b/src/main/java/com/gitblit/client/Utils.java
@@ -51,14 +51,14 @@ public class Utils {
public static JTable newTable(TableModel model, String datePattern) {
return newTable(model, datePattern, null);
}
-
+
public static JTable newTable(TableModel model, String datePattern, final RowRenderer rowRenderer) {
JTable table;
if (rowRenderer == null) {
table = new JTable(model);
} else {
table = new JTable(model) {
-
+
@Override
public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
Component c = super.prepareRenderer(renderer, row, column);
@@ -166,7 +166,7 @@ public class Utils {
showException(null, x);
}
}
-
+
public static abstract class RowRenderer {
public abstract void prepareRow(Component c, boolean isSelected, int row, int column);
}
diff --git a/src/main/java/com/gitblit/fanout/FanoutClient.java b/src/main/java/com/gitblit/fanout/FanoutClient.java
index b9ace4be..a676abcd 100644
--- a/src/main/java/com/gitblit/fanout/FanoutClient.java
+++ b/src/main/java/com/gitblit/fanout/FanoutClient.java
@@ -39,7 +39,7 @@ import org.slf4j.LoggerFactory;
/**
* Fanout client class.
- *
+ *
* @author James Moger
*
*/
@@ -57,24 +57,26 @@ public class FanoutClient implements Runnable {
private volatile Selector selector;
private volatile SocketChannel socketCh;
private Thread clientThread;
-
+
private final AtomicBoolean isConnected;
private final AtomicBoolean isRunning;
private final AtomicBoolean isAutomaticReconnect;
private final ByteBuffer writeBuffer;
private final ByteBuffer readBuffer;
private final CharsetDecoder decoder;
-
+
private final Set<String> subscriptions;
private boolean resubscribe;
-
+
public interface FanoutListener {
public void pong(Date timestamp);
public void announcement(String channel, String message);
}
-
+
public static class FanoutAdapter implements FanoutListener {
+ @Override
public void pong(Date timestamp) { }
+ @Override
public void announcement(String channel, String message) { }
}
@@ -86,20 +88,20 @@ public class FanoutClient implements Runnable {
public void pong(Date timestamp) {
System.out.println("Pong. " + timestamp);
}
-
+
@Override
public void announcement(String channel, String message) {
System.out.println(MessageFormat.format("Here ye, Here ye. {0} says {1}", channel, message));
}
});
client.start();
-
+
Thread.sleep(5000);
client.ping();
client.subscribe("james");
- client.announce("james", "12345");
+ client.announce("james", "12345");
client.subscribe("c52f99d16eb5627877ae957df7ce1be102783bd5");
-
+
while (true) {
Thread.sleep(10000);
client.ping();
@@ -126,11 +128,11 @@ public class FanoutClient implements Runnable {
public void removeListener(FanoutListener listener) {
listeners.remove(listener);
}
-
+
public boolean isAutomaticReconnect() {
return isAutomaticReconnect.get();
}
-
+
public void setAutomaticReconnect(boolean value) {
isAutomaticReconnect.set(value);
}
@@ -144,21 +146,21 @@ public class FanoutClient implements Runnable {
confirmConnection();
write("status");
}
-
+
public void subscribe(String channel) {
confirmConnection();
if (subscriptions.add(channel)) {
write("subscribe " + channel);
}
}
-
+
public void unsubscribe(String channel) {
confirmConnection();
if (subscriptions.remove(channel)) {
write("unsubscribe " + channel);
}
}
-
+
public void announce(String channel, String message) {
confirmConnection();
write("announce " + channel + " " + message);
@@ -169,11 +171,11 @@ public class FanoutClient implements Runnable {
throw new RuntimeException("Fanout client is disconnected!");
}
}
-
+
public boolean isConnected() {
return isRunning.get() && socketCh != null && isConnected.get();
}
-
+
/**
* Start client connection and return immediately.
*/
@@ -185,13 +187,13 @@ public class FanoutClient implements Runnable {
clientThread = new Thread(this, "Fanout client");
clientThread.start();
}
-
+
/**
* Start client connection and wait until it has connected.
*/
public void startSynchronously() {
start();
- while (!isConnected()) {
+ while (!isConnected()) {
try {
Thread.sleep(100);
} catch (Exception e) {
@@ -221,8 +223,8 @@ public class FanoutClient implements Runnable {
@Override
public void run() {
resetState();
-
- isRunning.set(true);
+
+ isRunning.set(true);
while (isRunning.get()) {
// (re)connect
if (socketCh == null) {
@@ -231,7 +233,7 @@ public class FanoutClient implements Runnable {
socketCh = SocketChannel.open(new InetSocketAddress(addr, port));
socketCh.configureBlocking(false);
selector = Selector.open();
- id = FanoutConstants.getLocalSocketId(socketCh.socket());
+ id = FanoutConstants.getLocalSocketId(socketCh.socket());
socketCh.register(selector, SelectionKey.OP_READ);
} catch (Exception e) {
logger.error(MessageFormat.format("failed to open client connection to {0}:{1,number,0}", host, port), e);
@@ -242,7 +244,7 @@ public class FanoutClient implements Runnable {
continue;
}
}
-
+
// read/write
try {
selector.select(clientTimeout);
@@ -251,7 +253,7 @@ public class FanoutClient implements Runnable {
while (i.hasNext()) {
SelectionKey key = i.next();
i.remove();
-
+
if (key.isReadable()) {
// read message
String content = read();
@@ -266,7 +268,7 @@ public class FanoutClient implements Runnable {
// resubscribe
if (resubscribe) {
resubscribe = false;
- logger.info(MessageFormat.format("fanout client {0} re-subscribing to {1} channels", id, subscriptions.size()));
+ logger.info(MessageFormat.format("fanout client {0} re-subscribing to {1} channels", id, subscriptions.size()));
for (String subscription : subscriptions) {
write("subscribe " + subscription);
}
@@ -276,25 +278,25 @@ public class FanoutClient implements Runnable {
}
} catch (IOException e) {
logger.error(MessageFormat.format("fanout client {0} error: {1}", id, e.getMessage()));
- closeChannel();
+ closeChannel();
if (!isAutomaticReconnect.get()) {
isRunning.set(false);
continue;
}
}
}
-
+
closeChannel();
resetState();
}
-
+
protected void resetState() {
readBuffer.clear();
writeBuffer.clear();
isRunning.set(false);
isConnected.set(false);
}
-
+
private void closeChannel() {
try {
if (socketCh != null) {
@@ -315,7 +317,7 @@ public class FanoutClient implements Runnable {
long time = Long.parseLong(fields[0]);
Date date = new Date(time);
firePong(date);
- } catch (Exception e) {
+ } catch (Exception e) {
}
return true;
} else if (fields.length == 2) {
@@ -366,7 +368,7 @@ public class FanoutClient implements Runnable {
}
}
}
-
+
protected synchronized String read() throws IOException {
readBuffer.clear();
long len = socketCh.read(readBuffer);
@@ -382,7 +384,7 @@ public class FanoutClient implements Runnable {
return content;
}
}
-
+
protected synchronized boolean write(String message) {
try {
logger.info(MessageFormat.format("fanout client {0} > {1}", id, message));
diff --git a/src/main/java/com/gitblit/fanout/FanoutConstants.java b/src/main/java/com/gitblit/fanout/FanoutConstants.java
index 6e6964c9..84fd2c59 100644
--- a/src/main/java/com/gitblit/fanout/FanoutConstants.java
+++ b/src/main/java/com/gitblit/fanout/FanoutConstants.java
@@ -25,11 +25,11 @@ public class FanoutConstants {
public final static String CH_DEBUG = "debug";
public final static String MSG_CONNECTED = "connected...";
public final static String MSG_BUSY = "busy";
-
+
public static String getRemoteSocketId(Socket socket) {
return socket.getInetAddress().getHostAddress() + ":" + socket.getPort();
}
-
+
public static String getLocalSocketId(Socket socket) {
return socket.getInetAddress().getHostAddress() + ":" + socket.getLocalPort();
}
diff --git a/src/main/java/com/gitblit/fanout/FanoutNioService.java b/src/main/java/com/gitblit/fanout/FanoutNioService.java
index 65d022ab..e7aff34b 100644
--- a/src/main/java/com/gitblit/fanout/FanoutNioService.java
+++ b/src/main/java/com/gitblit/fanout/FanoutNioService.java
@@ -44,7 +44,7 @@ import org.slf4j.LoggerFactory;
*
* This implementation uses channels and selectors, which are the Java analog of
* the Linux epoll mechanism used in the original fanout C code.
- *
+ *
* @author James Moger
*
*/
@@ -54,7 +54,7 @@ public class FanoutNioService extends FanoutService {
private volatile ServerSocketChannel serviceCh;
private volatile Selector selector;
-
+
public static void main(String[] args) throws Exception {
FanoutNioService pubsub = new FanoutNioService(null, DEFAULT_PORT);
pubsub.setStrictRequestTermination(false);
@@ -64,7 +64,7 @@ public class FanoutNioService extends FanoutService {
/**
* Create a single-threaded fanout service.
- *
+ *
* @param host
* @param port
* the port for running the fanout PubSub service
@@ -73,10 +73,10 @@ public class FanoutNioService extends FanoutService {
public FanoutNioService(int port) {
this(null, port);
}
-
+
/**
* Create a single-threaded fanout service.
- *
+ *
* @param bindInterface
* the ip address to bind for the service, may be null
* @param port
@@ -86,7 +86,7 @@ public class FanoutNioService extends FanoutService {
public FanoutNioService(String bindInterface, int port) {
super(bindInterface, port, "Fanout nio service");
}
-
+
@Override
protected boolean isConnected() {
return serviceCh != null;
@@ -102,10 +102,10 @@ public class FanoutNioService extends FanoutService {
serviceCh.socket().bind(host == null ? new InetSocketAddress(port) : new InetSocketAddress(host, port));
selector = Selector.open();
serviceCh.register(selector, SelectionKey.OP_ACCEPT);
- logger.info(MessageFormat.format("{0} is ready on {1}:{2,number,0}",
+ logger.info(MessageFormat.format("{0} is ready on {1}:{2,number,0}",
name, host == null ? "0.0.0.0" : host, port));
} catch (IOException e) {
- logger.error(MessageFormat.format("failed to open {0} on {1}:{2,number,0}",
+ logger.error(MessageFormat.format("failed to open {0} on {1}:{2,number,0}",
name, name, host == null ? "0.0.0.0" : host, port), e);
return false;
}
@@ -122,11 +122,11 @@ public class FanoutNioService extends FanoutService {
for (Map.Entry<String, SocketChannel> client : clients.entrySet()) {
closeClientSocket(client.getKey(), client.getValue());
}
-
+
// close service socket channel
logger.debug(MessageFormat.format("closing {0} socket channel", name));
serviceCh.socket().close();
- serviceCh.close();
+ serviceCh.close();
serviceCh = null;
selector.close();
selector = null;
@@ -142,7 +142,7 @@ public class FanoutNioService extends FanoutService {
Set<SelectionKey> keys = selector.selectedKeys();
Iterator<SelectionKey> keyItr = keys.iterator();
while (keyItr.hasNext()) {
- SelectionKey key = (SelectionKey) keyItr.next();
+ SelectionKey key = keyItr.next();
if (key.isAcceptable()) {
// new fanout client connection
ServerSocketChannel sch = (ServerSocketChannel) key.channel();
@@ -213,7 +213,7 @@ public class FanoutNioService extends FanoutService {
}
}
}
-
+
protected void closeClientSocket(String id, SocketChannel ch) {
try {
ch.close();
@@ -221,10 +221,11 @@ public class FanoutNioService extends FanoutService {
logger.error(MessageFormat.format("fanout connection {0}", id), e);
}
}
-
+
+ @Override
protected void broadcast(Collection<FanoutServiceConnection> connections, String channel, String message) {
super.broadcast(connections, channel, message);
-
+
// register queued write
Map<String, SocketChannel> sockets = getCurrentClientSockets();
for (FanoutServiceConnection connection : connections) {
@@ -241,7 +242,7 @@ public class FanoutNioService extends FanoutService {
}
}
}
-
+
protected Map<String, SocketChannel> getCurrentClientSockets() {
Map<String, SocketChannel> sockets = new HashMap<String, SocketChannel>();
for (SelectionKey key : selector.keys()) {
@@ -253,11 +254,11 @@ public class FanoutNioService extends FanoutService {
}
return sockets;
}
-
+
/**
* FanoutNioConnection handles reading/writing messages from a remote fanout
* connection.
- *
+ *
* @author James Moger
*
*/
@@ -276,7 +277,7 @@ public class FanoutNioService extends FanoutService {
replyQueue = new ArrayList<String>();
decoder = Charset.forName(FanoutConstants.CHARSET).newDecoder();
}
-
+
protected void read(SocketChannel ch, boolean strictRequestTermination) throws CharacterCodingException, IOException {
long bytesRead = 0;
readBuffer.clear();
@@ -293,7 +294,7 @@ public class FanoutNioService extends FanoutService {
String [] lines = req.split(strictRequestTermination ? "\n" : "\n|\r");
requestQueue.addAll(Arrays.asList(lines));
}
-
+
protected void write(SocketChannel ch) throws IOException {
Iterator<String> itr = replyQueue.iterator();
while (itr.hasNext()) {
@@ -306,7 +307,7 @@ public class FanoutNioService extends FanoutService {
writeBuffer.put((byte) 0xa);
}
writeBuffer.flip();
-
+
// loop until write buffer has been completely sent
int written = 0;
int toWrite = writeBuffer.remaining();
@@ -316,7 +317,7 @@ public class FanoutNioService extends FanoutService {
Thread.sleep(10);
} catch (Exception x) {
}
- }
+ }
itr.remove();
}
writeBuffer.clear();
diff --git a/src/main/java/com/gitblit/fanout/FanoutService.java b/src/main/java/com/gitblit/fanout/FanoutService.java
index cbfd8a24..e0e4d64d 100644
--- a/src/main/java/com/gitblit/fanout/FanoutService.java
+++ b/src/main/java/com/gitblit/fanout/FanoutService.java
@@ -37,29 +37,29 @@ import org.slf4j.LoggerFactory;
/**
* Base class for Fanout service implementations.
- *
+ *
* Subclass implementations can be used as a Sparkleshare PubSub notification
* server. This allows Sparkleshare to be used in conjunction with Gitblit
* behind a corporate firewall that restricts or prohibits client internet access
* to the default Sparkleshare PubSub server: notifications.sparkleshare.org
- *
+ *
* @author James Moger
*
*/
public abstract class FanoutService implements Runnable {
private final static Logger logger = LoggerFactory.getLogger(FanoutService.class);
-
+
public final static int DEFAULT_PORT = 17000;
-
+
protected final static int serviceTimeout = 5000;
protected final String host;
protected final int port;
- protected final String name;
-
+ protected final String name;
+
private Thread serviceThread;
-
+
private final Map<String, FanoutServiceConnection> connections;
private final Map<String, Set<FanoutServiceConnection>> subscriptions;
@@ -67,7 +67,7 @@ public abstract class FanoutService implements Runnable {
private final AtomicBoolean strictRequestTermination;
private final AtomicBoolean allowAllChannelAnnouncements;
private final AtomicInteger concurrentConnectionLimit;
-
+
private final Date bootDate;
private final AtomicLong rejectedConnectionCount;
private final AtomicInteger peakConnectionCount;
@@ -82,16 +82,16 @@ public abstract class FanoutService implements Runnable {
this.host = host;
this.port = port;
this.name = name;
-
+
connections = new ConcurrentHashMap<String, FanoutServiceConnection>();
subscriptions = new ConcurrentHashMap<String, Set<FanoutServiceConnection>>();
subscriptions.put(FanoutConstants.CH_ALL, new ConcurrentSkipListSet<FanoutServiceConnection>());
-
+
isRunning = new AtomicBoolean(false);
strictRequestTermination = new AtomicBoolean(false);
allowAllChannelAnnouncements = new AtomicBoolean(false);
concurrentConnectionLimit = new AtomicInteger(0);
-
+
bootDate = new Date();
rejectedConnectionCount = new AtomicLong(0);
peakConnectionCount = new AtomicInteger(0);
@@ -106,18 +106,18 @@ public abstract class FanoutService implements Runnable {
/*
* Abstract methods
*/
-
+
protected abstract boolean isConnected();
-
+
protected abstract boolean connect();
-
+
protected abstract void listen() throws IOException;
-
+
protected abstract void disconnect();
-
+
/**
* Returns true if the service requires \n request termination.
- *
+ *
* @return true if request requires \n termination
*/
public boolean isStrictRequestTermination() {
@@ -128,62 +128,62 @@ public abstract class FanoutService implements Runnable {
* Control the termination of fanout requests. If true, fanout requests must
* be terminated with \n. If false, fanout requests may be terminated with
* \n, \r, \r\n, or \n\r. This is useful for debugging with a telnet client.
- *
+ *
* @param isStrictTermination
*/
public void setStrictRequestTermination(boolean isStrictTermination) {
strictRequestTermination.set(isStrictTermination);
}
-
+
/**
* Returns the maximum allowable concurrent fanout connections.
- *
+ *
* @return the maximum allowable concurrent connection count
*/
public int getConcurrentConnectionLimit() {
return concurrentConnectionLimit.get();
}
-
+
/**
* Sets the maximum allowable concurrent fanout connection count.
- *
+ *
* @param value
*/
public void setConcurrentConnectionLimit(int value) {
concurrentConnectionLimit.set(value);
}
-
+
/**
* Returns true if connections are allowed to announce on the all channel.
- *
+ *
* @return true if connections are allowed to announce on the all channel
*/
public boolean allowAllChannelAnnouncements() {
return allowAllChannelAnnouncements.get();
}
-
+
/**
* Allows/prohibits connections from announcing on the ALL channel.
- *
+ *
* @param value
*/
public void setAllowAllChannelAnnouncements(boolean value) {
allowAllChannelAnnouncements.set(value);
}
-
+
/**
* Returns the current connections
- *
+ *
* @param channel
* @return map of current connections keyed by their id
*/
public Map<String, FanoutServiceConnection> getCurrentConnections() {
return connections;
}
-
+
/**
* Returns all subscriptions
- *
+ *
* @return map of current subscriptions keyed by channel name
*/
public Map<String, Set<FanoutServiceConnection>> getCurrentSubscriptions() {
@@ -192,7 +192,7 @@ public abstract class FanoutService implements Runnable {
/**
* Returns the subscriptions for the specified channel
- *
+ *
* @param channel
* @return set of subscribed connections for the specified channel
*/
@@ -202,17 +202,17 @@ public abstract class FanoutService implements Runnable {
/**
* Returns the runtime statistics object for this service.
- *
+ *
* @return stats
*/
public FanoutStats getStatistics() {
FanoutStats stats = new FanoutStats();
-
+
// settings
stats.allowAllChannelAnnouncements = allowAllChannelAnnouncements();
stats.concurrentConnectionLimit = getConcurrentConnectionLimit();
stats.strictRequestTermination = isStrictRequestTermination();
-
+
// runtime stats
stats.bootDate = bootDate;
stats.rejectedConnectionCount = rejectedConnectionCount.get();
@@ -222,16 +222,16 @@ public abstract class FanoutService implements Runnable {
stats.totalMessages = totalMessages.get();
stats.totalSubscribes = totalSubscribes.get();
stats.totalUnsubscribes = totalUnsubscribes.get();
- stats.totalPings = totalPings.get();
+ stats.totalPings = totalPings.get();
stats.currentConnections = connections.size();
stats.currentChannels = subscriptions.size();
stats.currentSubscriptions = subscriptions.size() * connections.size();
return stats;
}
-
+
/**
* Returns true if the service is ready.
- *
+ *
* @return true, if the service is ready
*/
public boolean isReady() {
@@ -243,7 +243,7 @@ public abstract class FanoutService implements Runnable {
/**
* Start the Fanout service thread and immediatel return.
- *
+ *
*/
public void start() {
if (isRunning.get()) {
@@ -254,10 +254,10 @@ public abstract class FanoutService implements Runnable {
serviceThread.setName(MessageFormat.format("{0} {1}:{2,number,0}", name, host == null ? "all" : host, port));
serviceThread.start();
}
-
+
/**
* Start the Fanout service thread and wait until it is accepting connections.
- *
+ *
*/
public void startSynchronously() {
start();
@@ -268,7 +268,7 @@ public abstract class FanoutService implements Runnable {
}
}
}
-
+
/**
* Stop the Fanout service. This method returns when the service has been
* completely shutdown.
@@ -290,7 +290,7 @@ public abstract class FanoutService implements Runnable {
}
logger.info(MessageFormat.format("stopped {0}", name));
}
-
+
/**
* Main execution method of the service
*/
@@ -314,10 +314,10 @@ public abstract class FanoutService implements Runnable {
}
}
}
- disconnect();
+ disconnect();
resetState();
}
-
+
protected void resetState() {
// reset state data
connections.clear();
@@ -334,23 +334,23 @@ public abstract class FanoutService implements Runnable {
/**
* Configure the client connection socket.
- *
+ *
* @param socket
* @throws SocketException
*/
protected void configureClientSocket(Socket socket) throws SocketException {
- socket.setKeepAlive(true);
+ socket.setKeepAlive(true);
socket.setSoLinger(true, 0); // immediately discard any remaining data
}
-
+
/**
* Add the connection to the connections map.
- *
+ *
* @param connection
* @return false if the connection was rejected due to too many concurrent
* connections
*/
- protected boolean addConnection(FanoutServiceConnection connection) {
+ protected boolean addConnection(FanoutServiceConnection connection) {
int limit = getConcurrentConnectionLimit();
if (limit > 0 && connections.size() > limit) {
logger.info(MessageFormat.format("hit {0,number,0} connection limit, rejecting fanout connection", concurrentConnectionLimit));
@@ -358,7 +358,7 @@ public abstract class FanoutService implements Runnable {
connection.busy();
return false;
}
-
+
// add the connection to our map
connections.put(connection.id, connection);
@@ -371,10 +371,10 @@ public abstract class FanoutService implements Runnable {
connection.connected();
return true;
}
-
+
/**
* Remove the connection from the connections list and from subscriptions.
- *
+ *
* @param connection
*/
protected void removeConnection(FanoutServiceConnection connection) {
@@ -393,46 +393,46 @@ public abstract class FanoutService implements Runnable {
}
logger.info(MessageFormat.format("fanout connection {0} removed", connection.id));
}
-
+
/**
* Tests to see if the connection is being monitored by the service.
- *
+ *
* @param connection
* @return true if the service is monitoring the connection
*/
protected boolean hasConnection(FanoutServiceConnection connection) {
return connections.containsKey(connection.id);
}
-
+
/**
* Reply to a connection on the specified channel.
- *
+ *
* @param connection
* @param channel
* @param message
* @return the reply
*/
- protected String reply(FanoutServiceConnection connection, String channel, String message) {
+ protected String reply(FanoutServiceConnection connection, String channel, String message) {
if (channel != null && channel.length() > 0) {
increment(totalMessages);
}
return connection.reply(channel, message);
}
-
+
/**
* Service method to broadcast a message to all connections.
- *
+ *
* @param message
*/
public void broadcastAll(String message) {
broadcast(connections.values(), FanoutConstants.CH_ALL, message);
increment(totalAnnouncements);
}
-
+
/**
* Service method to broadcast a message to connections subscribed to the
* channel.
- *
+ *
* @param message
*/
public void broadcast(String channel, String message) {
@@ -440,10 +440,10 @@ public abstract class FanoutService implements Runnable {
broadcast(connections, channel, message);
increment(totalAnnouncements);
}
-
+
/**
* Broadcast a message to connections subscribed to the specified channel.
- *
+ *
* @param connections
* @param channel
* @param message
@@ -453,10 +453,10 @@ public abstract class FanoutService implements Runnable {
reply(connection, channel, message);
}
}
-
+
/**
* Process an incoming Fanout request.
- *
+ *
* @param connection
* @param req
* @return the reply to the request, may be null
@@ -476,10 +476,10 @@ public abstract class FanoutService implements Runnable {
}
return null;
}
-
+
/**
* Process the Fanout request.
- *
+ *
* @param connection
* @param action
* @param channel
@@ -535,7 +535,7 @@ public abstract class FanoutService implements Runnable {
}
return null;
}
-
+
private String asHexArray(String req) {
StringBuilder sb = new StringBuilder();
for (char c : req.toCharArray()) {
@@ -543,10 +543,10 @@ public abstract class FanoutService implements Runnable {
}
return "[ " + sb.toString().trim() + " ]";
}
-
+
/**
* Increment a long and prevent negative rollover.
- *
+ *
* @param counter
*/
private void increment(AtomicLong counter) {
@@ -555,7 +555,7 @@ public abstract class FanoutService implements Runnable {
counter.set(0);
}
}
-
+
@Override
public String toString() {
return name;
diff --git a/src/main/java/com/gitblit/fanout/FanoutServiceConnection.java b/src/main/java/com/gitblit/fanout/FanoutServiceConnection.java
index f7f2c959..2515ab1d 100644
--- a/src/main/java/com/gitblit/fanout/FanoutServiceConnection.java
+++ b/src/main/java/com/gitblit/fanout/FanoutServiceConnection.java
@@ -24,14 +24,14 @@ import org.slf4j.LoggerFactory;
/**
* FanoutServiceConnection handles reading/writing messages from a remote fanout
* connection.
- *
+ *
* @author James Moger
- *
+ *
*/
public abstract class FanoutServiceConnection implements Comparable<FanoutServiceConnection> {
-
+
private static final Logger logger = LoggerFactory.getLogger(FanoutServiceConnection.class);
-
+
public final String id;
protected FanoutServiceConnection(Socket socket) {
@@ -42,25 +42,25 @@ public abstract class FanoutServiceConnection implements Comparable<FanoutServic
/**
* Send the connection a debug channel connected message.
- *
+ *
* @param message
*/
protected void connected() {
reply(FanoutConstants.CH_DEBUG, FanoutConstants.MSG_CONNECTED);
}
-
+
/**
* Send the connection a debug channel busy message.
- *
+ *
* @param message
*/
protected void busy() {
reply(FanoutConstants.CH_DEBUG, FanoutConstants.MSG_BUSY);
}
-
+
/**
* Send the connection a message for the specified channel.
- *
+ *
* @param channel
* @param message
* @return the reply
diff --git a/src/main/java/com/gitblit/fanout/FanoutSocketService.java b/src/main/java/com/gitblit/fanout/FanoutSocketService.java
index 07c18f90..342b2774 100644
--- a/src/main/java/com/gitblit/fanout/FanoutSocketService.java
+++ b/src/main/java/com/gitblit/fanout/FanoutSocketService.java
@@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory;
* This implementation creates a master acceptor thread which accepts incoming
* fanout connections and then spawns a daemon thread for each accepted connection.
* If there are 100 concurrent fanout connections, there are 101 threads.
- *
+ *
* @author James Moger
*
*/
@@ -50,10 +50,10 @@ public class FanoutSocketService extends FanoutService {
pubsub.setAllowAllChannelAnnouncements(false);
pubsub.start();
}
-
+
/**
* Create a multi-threaded fanout service.
- *
+ *
* @param port
* the port for running the fanout PubSub service
* @throws IOException
@@ -64,7 +64,7 @@ public class FanoutSocketService extends FanoutService {
/**
* Create a multi-threaded fanout service.
- *
+ *
* @param bindInterface
* the ip address to bind for the service, may be null
* @param port
@@ -74,12 +74,12 @@ public class FanoutSocketService extends FanoutService {
public FanoutSocketService(String bindInterface, int port) {
super(bindInterface, port, "Fanout socket service");
}
-
+
@Override
protected boolean isConnected() {
return serviceSocket != null;
}
-
+
@Override
protected boolean connect() {
if (serviceSocket == null) {
@@ -88,7 +88,7 @@ public class FanoutSocketService extends FanoutService {
serviceSocket.setReuseAddress(true);
serviceSocket.setSoTimeout(serviceTimeout);
serviceSocket.bind(host == null ? new InetSocketAddress(port) : new InetSocketAddress(host, port));
- logger.info(MessageFormat.format("{0} is ready on {1}:{2,number,0}",
+ logger.info(MessageFormat.format("{0} is ready on {1}:{2,number,0}",
name, host == null ? "0.0.0.0" : host, serviceSocket.getLocalPort()));
} catch (IOException e) {
logger.error(MessageFormat.format("failed to open {0} on {1}:{2,number,0}",
@@ -140,17 +140,17 @@ public class FanoutSocketService extends FanoutService {
// ignore accept timeout exceptions
}
}
-
+
/**
* FanoutSocketConnection handles reading/writing messages from a remote fanout
* connection.
- *
+ *
* @author James Moger
*
*/
class FanoutSocketConnection extends FanoutServiceConnection implements Runnable {
Socket socket;
-
+
FanoutSocketConnection(Socket socket) {
super(socket);
this.socket = socket;
@@ -205,7 +205,7 @@ public class FanoutSocketService extends FanoutService {
logger.info(MessageFormat.format("thread for fanout connection {0} is finished", id));
}
-
+
@Override
protected void reply(String content) throws IOException {
// synchronously send reply
@@ -218,7 +218,7 @@ public class FanoutSocketService extends FanoutService {
}
os.flush();
}
-
+
protected void closeConnection() {
// close the connection socket
try {
@@ -226,7 +226,7 @@ public class FanoutSocketService extends FanoutService {
} catch (IOException e) {
}
socket = null;
-
+
// remove this connection from the service
removeConnection(this);
}
diff --git a/src/main/java/com/gitblit/fanout/FanoutStats.java b/src/main/java/com/gitblit/fanout/FanoutStats.java
index b06884d3..3545472f 100644
--- a/src/main/java/com/gitblit/fanout/FanoutStats.java
+++ b/src/main/java/com/gitblit/fanout/FanoutStats.java
@@ -21,18 +21,18 @@ import java.util.Date;
/**
* Encapsulates the runtime stats of a fanout service.
- *
+ *
* @author James Moger
*
*/
public class FanoutStats implements Serializable {
private static final long serialVersionUID = 1L;
-
+
public long concurrentConnectionLimit;
public boolean allowAllChannelAnnouncements;
public boolean strictRequestTermination;
-
+
public Date bootDate;
public long rejectedConnectionCount;
public int peakConnectionCount;
@@ -45,7 +45,7 @@ public class FanoutStats implements Serializable {
public long totalSubscribes;
public long totalUnsubscribes;
public long totalPings;
-
+
public String info() {
int i = 0;
StringBuilder sb = new StringBuilder();
@@ -67,14 +67,14 @@ public class FanoutStats implements Serializable {
sb.append(infoInt(i++, "total pings"));
String template = sb.toString();
- String info = MessageFormat.format(template,
+ String info = MessageFormat.format(template,
bootDate.toString(),
Boolean.toString(strictRequestTermination),
Boolean.toString(allowAllChannelAnnouncements),
concurrentConnectionLimit,
rejectedConnectionCount,
peakConnectionCount,
- currentConnections,
+ currentConnections,
currentChannels,
currentSubscriptions,
currentSubscriptions == 0 ? 0 : (currentSubscriptions - currentConnections),
@@ -86,11 +86,11 @@ public class FanoutStats implements Serializable {
totalPings);
return info;
}
-
+
private String infoStr(int index, String label) {
return label + ": {" + index + "}\n";
}
-
+
private String infoInt(int index, String label) {
return label + ": {" + index + ",number,0}\n";
}
diff --git a/src/main/java/com/gitblit/git/GitDaemon.java b/src/main/java/com/gitblit/git/GitDaemon.java
index b760fbcc..bb578efc 100644
--- a/src/main/java/com/gitblit/git/GitDaemon.java
+++ b/src/main/java/com/gitblit/git/GitDaemon.java
@@ -73,9 +73,9 @@ import com.gitblit.utils.StringUtils;
/**
* Gitblit's Git Daemon ignores any and all per-repository daemon settings and
* integrates into Gitblit's security model.
- *
+ *
* @author James Moger
- *
+ *
*/
public class GitDaemon {
@@ -113,7 +113,7 @@ public class GitDaemon {
/**
* Construct the Gitblit Git daemon.
- *
+ *
* @param bindInterface
* the ip address of the interface to bind
* @param port
@@ -128,10 +128,10 @@ public class GitDaemon {
// set the repository resolver and pack factories
repositoryResolver = new RepositoryResolver<GitDaemonClient>(folder);
}
-
+
/**
* Configure a new daemon for the specified network address.
- *
+ *
* @param addr
* address to listen for connections on. If null, any available
* port will be chosen on all network interfaces.
@@ -177,11 +177,11 @@ public class GitDaemon {
}
} };
}
-
+
public int getPort() {
return myAddress.getPort();
}
-
+
public String formatUrl(String servername, String repository) {
if (getPort() == 9418) {
// standard port
@@ -199,7 +199,7 @@ public class GitDaemon {
/**
* Set the timeout before willing to abort an IO call.
- *
+ *
* @param seconds
* number of seconds to wait (with no data transfer occurring)
* before aborting an IO read or write operation with the
@@ -211,7 +211,7 @@ public class GitDaemon {
/**
* Start this daemon on a background thread.
- *
+ *
* @throws IOException
* the server socket could not be opened.
* @throws IllegalStateException
@@ -228,6 +228,7 @@ public class GitDaemon {
run.set(true);
acceptSocket = listenSock;
acceptThread = new Thread(processors, "Git-Daemon-Accept") {
+ @Override
public void run() {
while (isRunning()) {
try {
@@ -250,7 +251,7 @@ public class GitDaemon {
}
};
acceptThread.start();
-
+
logger.info(MessageFormat.format("Git Daemon is listening on {0}:{1,number,0}", myAddress.getAddress().getHostAddress(), myAddress.getPort()));
}
@@ -290,6 +291,7 @@ public class GitDaemon {
dc.setRemoteAddress(((InetSocketAddress) peer).getAddress());
new Thread(processors, "Git-Daemon-Client " + peer.toString()) {
+ @Override
public void run() {
try {
dc.execute(s);
diff --git a/src/main/java/com/gitblit/git/GitDaemonClient.java b/src/main/java/com/gitblit/git/GitDaemonClient.java
index e7455e0d..8d8cac6d 100644
--- a/src/main/java/com/gitblit/git/GitDaemonClient.java
+++ b/src/main/java/com/gitblit/git/GitDaemonClient.java
@@ -65,7 +65,7 @@ public class GitDaemonClient {
private InputStream rawIn;
private OutputStream rawOut;
-
+
private String repositoryName;
GitDaemonClient(final GitDaemon d) {
@@ -95,11 +95,11 @@ public class GitDaemonClient {
public OutputStream getOutputStream() {
return rawOut;
}
-
+
public void setRepositoryName(String repositoryName) {
this.repositoryName = repositoryName;
}
-
+
/** @return the name of the requested repository. */
public String getRepositoryName() {
return repositoryName;
diff --git a/src/main/java/com/gitblit/git/GitDaemonService.java b/src/main/java/com/gitblit/git/GitDaemonService.java
index 03c4e1cd..8dee7d0b 100644
--- a/src/main/java/com/gitblit/git/GitDaemonService.java
+++ b/src/main/java/com/gitblit/git/GitDaemonService.java
@@ -68,6 +68,7 @@ public abstract class GitDaemonService {
GitDaemonService(final String cmdName, final String cfgName) {
command = cmdName.startsWith("git-") ? cmdName : "git-" + cmdName; //$NON-NLS-1$ //$NON-NLS-2$
configKey = new SectionParser<ServiceConfig>() {
+ @Override
public ServiceConfig parse(final Config cfg) {
return new ServiceConfig(GitDaemonService.this, cfg, cfgName);
}
diff --git a/src/main/java/com/gitblit/git/GitServlet.java b/src/main/java/com/gitblit/git/GitServlet.java
index 5a401066..310d4da3 100644
--- a/src/main/java/com/gitblit/git/GitServlet.java
+++ b/src/main/java/com/gitblit/git/GitServlet.java
@@ -24,9 +24,9 @@ import com.gitblit.GitBlit;
/**
* The GitServlet provides http/https access to Git repositories.
* Access to this servlet is protected by the GitFilter.
- *
+ *
* @author James Moger
- *
+ *
*/
public class GitServlet extends org.eclipse.jgit.http.server.GitServlet {
diff --git a/src/main/java/com/gitblit/git/GitblitReceivePack.java b/src/main/java/com/gitblit/git/GitblitReceivePack.java
index 2d648bdd..090e5416 100644
--- a/src/main/java/com/gitblit/git/GitblitReceivePack.java
+++ b/src/main/java/com/gitblit/git/GitblitReceivePack.java
@@ -106,7 +106,7 @@ public class GitblitReceivePack extends ReceivePack implements PreReceiveHook, P
setAllowCreates(user.canCreateRef(repository));
setAllowDeletes(user.canDeleteRef(repository));
setAllowNonFastForwards(user.canRewindRef(repository));
-
+
// setup pre and post receive hook
setPreReceiveHook(this);
setPostReceiveHook(this);
diff --git a/src/main/java/com/gitblit/git/GitblitUploadPackFactory.java b/src/main/java/com/gitblit/git/GitblitUploadPackFactory.java
index 6c06fa3d..01dfc08b 100644
--- a/src/main/java/com/gitblit/git/GitblitUploadPackFactory.java
+++ b/src/main/java/com/gitblit/git/GitblitUploadPackFactory.java
@@ -36,9 +36,9 @@ import com.gitblit.models.UserModel;
/**
* The upload pack factory creates an upload pack which controls what refs are
* advertised to cloning/pulling clients.
- *
+ *
* @author James Moger
- *
+ *
* @param <X> the connection type
*/
public class GitblitUploadPackFactory<X> implements UploadPackFactory<X> {
@@ -51,7 +51,7 @@ public class GitblitUploadPackFactory<X> implements UploadPackFactory<X> {
int timeout = 0;
if (req instanceof HttpServletRequest) {
- // http/https request may or may not be authenticated
+ // http/https request may or may not be authenticated
user = GitBlit.self().authenticate((HttpServletRequest) req);
if (user == null) {
user = UserModel.ANONYMOUS;
@@ -67,7 +67,7 @@ public class GitblitUploadPackFactory<X> implements UploadPackFactory<X> {
UploadPack up = new UploadPack(db);
up.setRefFilter(refFilter);
up.setTimeout(timeout);
-
+
return up;
}
@@ -76,13 +76,13 @@ public class GitblitUploadPackFactory<X> implements UploadPackFactory<X> {
* requesting user.
*/
public static class UserRefFilter implements RefFilter {
-
+
final UserModel user;
-
+
public UserRefFilter(UserModel user) {
this.user = user;
}
-
+
@Override
public Map<String, Ref> filter(Map<String, Ref> refs) {
if (user.canAdmin()) {
diff --git a/src/main/java/com/gitblit/git/RepositoryResolver.java b/src/main/java/com/gitblit/git/RepositoryResolver.java
index 21a83760..e44b153f 100644
--- a/src/main/java/com/gitblit/git/RepositoryResolver.java
+++ b/src/main/java/com/gitblit/git/RepositoryResolver.java
@@ -34,14 +34,14 @@ import com.gitblit.models.UserModel;
/**
* Resolves repositories and grants export access.
- *
+ *
* @author James Moger
*
*/
public class RepositoryResolver<X> extends FileResolver<X> {
private final Logger logger = LoggerFactory.getLogger(RepositoryResolver.class);
-
+
public RepositoryResolver(File repositoriesFolder) {
super(repositoriesFolder, true);
}
@@ -53,7 +53,7 @@ public class RepositoryResolver<X> extends FileResolver<X> {
public Repository open(final X req, final String name)
throws RepositoryNotFoundException, ServiceNotEnabledException {
Repository repo = super.open(req, name);
-
+
// Set repository name for the pack factories
// We do this because the JGit API does not have a consistent way to
// retrieve the repository name from the pack factories or the hooks.
@@ -68,7 +68,7 @@ public class RepositoryResolver<X> extends FileResolver<X> {
}
return repo;
}
-
+
/**
* Check if this repository can be served by the requested client connection.
*/
@@ -79,7 +79,7 @@ public class RepositoryResolver<X> extends FileResolver<X> {
String scheme = null;
UserModel user = null;
String origin = null;
-
+
if (req instanceof GitDaemonClient) {
// git daemon request
// this is an anonymous/unauthenticated protocol
@@ -90,7 +90,7 @@ public class RepositoryResolver<X> extends FileResolver<X> {
} else if (req instanceof HttpServletRequest) {
// http/https request
HttpServletRequest httpRequest = (HttpServletRequest) req;
- scheme = httpRequest.getScheme();
+ scheme = httpRequest.getScheme();
origin = httpRequest.getRemoteAddr();
user = GitBlit.self().authenticate(httpRequest);
if (user == null) {
@@ -104,7 +104,7 @@ public class RepositoryResolver<X> extends FileResolver<X> {
scheme, repositoryName, user.username, origin));
return true;
}
-
+
// user can not access this git repo
logger.warn(MessageFormat.format("{0}:// access of {1} by {2} from {3} DENIED",
scheme, repositoryName, user.username, origin));
diff --git a/src/main/java/com/gitblit/models/Activity.java b/src/main/java/com/gitblit/models/Activity.java
index 8af86d61..ff0920c7 100644
--- a/src/main/java/com/gitblit/models/Activity.java
+++ b/src/main/java/com/gitblit/models/Activity.java
@@ -35,7 +35,7 @@ import com.gitblit.utils.TimeUtils;
/**
* Model class to represent the commit activity across many repositories. This
* class is used by the Activity page.
- *
+ *
* @author James Moger
*/
public class Activity implements Serializable, Comparable<Activity> {
@@ -45,7 +45,7 @@ public class Activity implements Serializable, Comparable<Activity> {
public final Date startDate;
public final Date endDate;
-
+
private final Set<RepositoryCommit> commits;
private final Map<String, Metric> authorMetrics;
@@ -56,7 +56,7 @@ public class Activity implements Serializable, Comparable<Activity> {
/**
* Constructor for one day of activity.
- *
+ *
* @param date
*/
public Activity(Date date) {
@@ -65,7 +65,7 @@ public class Activity implements Serializable, Comparable<Activity> {
/**
* Constructor for specified duration of activity from start date.
- *
+ *
* @param date
* the start date of the activity
* @param duration
@@ -79,10 +79,10 @@ public class Activity implements Serializable, Comparable<Activity> {
repositoryMetrics = new HashMap<String, Metric>();
authorExclusions = new TreeSet<String>();
}
-
+
/**
* Exclude the specified authors from the metrics.
- *
+ *
* @param authors
*/
public void excludeAuthors(Collection<String> authors) {
@@ -94,7 +94,7 @@ public class Activity implements Serializable, Comparable<Activity> {
/**
* Adds a commit to the activity object as long as the commit is not a
* duplicate.
- *
+ *
* @param repository
* @param branch
* @param commit
@@ -109,7 +109,7 @@ public class Activity implements Serializable, Comparable<Activity> {
/**
* Adds a commit to the activity object as long as the commit is not a
* duplicate.
- *
+ *
* @param repository
* @param branch
* @param commit
@@ -140,7 +140,7 @@ public class Activity implements Serializable, Comparable<Activity> {
public int getCommitCount() {
return commits.size();
}
-
+
public List<RepositoryCommit> getCommits() {
List<RepositoryCommit> list = new ArrayList<RepositoryCommit>(commits);
Collections.sort(list);
diff --git a/src/main/java/com/gitblit/models/AnnotatedLine.java b/src/main/java/com/gitblit/models/AnnotatedLine.java
index 439a3222..a8b595ee 100644
--- a/src/main/java/com/gitblit/models/AnnotatedLine.java
+++ b/src/main/java/com/gitblit/models/AnnotatedLine.java
@@ -24,9 +24,9 @@ import org.eclipse.jgit.revwalk.RevCommit;
/**
* AnnotatedLine is a serializable model class that represents a the most recent
* author, date, and commit id of a line in a source file.
- *
+ *
* @author James Moger
- *
+ *
*/
public class AnnotatedLine implements Serializable {
diff --git a/src/main/java/com/gitblit/models/DailyLogEntry.java b/src/main/java/com/gitblit/models/DailyLogEntry.java
index 41f13818..a6bc6a44 100644
--- a/src/main/java/com/gitblit/models/DailyLogEntry.java
+++ b/src/main/java/com/gitblit/models/DailyLogEntry.java
@@ -25,7 +25,7 @@ import org.eclipse.jgit.transport.ReceiveCommand;
* Model class to simulate a push for presentation in the push log news feed
* for a repository that does not have a Gitblit push log. Commits are grouped
* by date and may be additionally split by ref.
- *
+ *
* @author James Moger
*/
public class DailyLogEntry extends RefLogEntry implements Serializable {
@@ -45,7 +45,7 @@ public class DailyLogEntry extends RefLogEntry implements Serializable {
if (getAuthorCount() == 1) {
return getCommits().get(0).getCommitterIdent();
}
-
+
return super.getCommitterIdent();
}
@@ -54,20 +54,21 @@ public class DailyLogEntry extends RefLogEntry implements Serializable {
if (getAuthorCount() == 1) {
return getCommits().get(0).getAuthorIdent();
}
-
+
return super.getAuthorIdent();
}
-
+
/**
* Tracks the change type for the specified ref.
- *
+ *
* @param ref
* @param type
* @param oldId
* @param newId
*/
+ @Override
public void updateRef(String ref, ReceiveCommand.Type type, String oldId, String newId) {
- // daily digests are filled from most recent to oldest
+ // daily digests are filled from most recent to oldest
String preservedNewId = getNewId(ref);
if (preservedNewId == null) {
// no preserved new id, this is newest commit
diff --git a/src/main/java/com/gitblit/models/FederationModel.java b/src/main/java/com/gitblit/models/FederationModel.java
index 1d211ce9..2c07c504 100644
--- a/src/main/java/com/gitblit/models/FederationModel.java
+++ b/src/main/java/com/gitblit/models/FederationModel.java
@@ -30,7 +30,7 @@ import com.gitblit.utils.StringUtils;
* Gitblit instance to pull the repositories and configuration from another
* Gitblit instance. This is a backup operation and can be considered something
* like svn-sync.
- *
+ *
*/
public class FederationModel implements Serializable, Comparable<FederationModel> {
@@ -45,7 +45,7 @@ public class FederationModel implements Serializable, Comparable<FederationModel
public String frequency;
public String folder;
-
+
public boolean bare;
public boolean mirror;
@@ -68,7 +68,7 @@ public class FederationModel implements Serializable, Comparable<FederationModel
/**
* The constructor for a remote server configuration.
- *
+ *
* @param serverName
*/
public FederationModel(String serverName) {
@@ -109,7 +109,7 @@ public class FederationModel implements Serializable, Comparable<FederationModel
/**
* Updates the pull status of a particular repository in this federation
* registration.
- *
+ *
* @param repository
* @param status
*/
@@ -133,7 +133,7 @@ public class FederationModel implements Serializable, Comparable<FederationModel
/**
* Iterates over the current pull results and returns the lowest pull
* status.
- *
+ *
* @return the lowest pull status of the registration
*/
public FederationPullStatus getLowestStatus() {
@@ -152,7 +152,7 @@ public class FederationModel implements Serializable, Comparable<FederationModel
/**
* Returns true if this registration represents the result data sent by a
* pulling Gitblit instance.
- *
+ *
* @return true, if this is result data
*/
public boolean isResultData() {
@@ -181,7 +181,7 @@ public class FederationModel implements Serializable, Comparable<FederationModel
/**
* Class that encapsulates a point-in-time pull result.
- *
+ *
*/
public static class RepositoryStatus implements Serializable, Comparable<RepositoryStatus> {
diff --git a/src/main/java/com/gitblit/models/FederationProposal.java b/src/main/java/com/gitblit/models/FederationProposal.java
index 5cf9182c..de1b8e60 100644
--- a/src/main/java/com/gitblit/models/FederationProposal.java
+++ b/src/main/java/com/gitblit/models/FederationProposal.java
@@ -37,14 +37,14 @@ public class FederationProposal implements Serializable {
public FederationToken tokenType;
public String token;
-
+
public String message;
public Map<String, RepositoryModel> repositories;
/**
* The constructor for a federation proposal.
- *
+ *
* @param url
* the url of the source Gitblit instance
* @param tokenType
diff --git a/src/main/java/com/gitblit/models/FederationSet.java b/src/main/java/com/gitblit/models/FederationSet.java
index 357689c9..dede66bf 100644
--- a/src/main/java/com/gitblit/models/FederationSet.java
+++ b/src/main/java/com/gitblit/models/FederationSet.java
@@ -37,7 +37,7 @@ public class FederationSet implements Serializable {
/**
* The constructor for a federation set.
- *
+ *
* @param name
* the name of this federation set
* @param tokenType
diff --git a/src/main/java/com/gitblit/models/FeedEntryModel.java b/src/main/java/com/gitblit/models/FeedEntryModel.java
index e1c00c38..c94f6e96 100644
--- a/src/main/java/com/gitblit/models/FeedEntryModel.java
+++ b/src/main/java/com/gitblit/models/FeedEntryModel.java
@@ -21,7 +21,7 @@ import java.util.List;
/**
* FeedEntryModel represents an entry in a syndication (RSS) feed.
- *
+ *
* @author James Moger
*/
public class FeedEntryModel implements Serializable, Comparable<FeedEntryModel> {
diff --git a/src/main/java/com/gitblit/models/FeedModel.java b/src/main/java/com/gitblit/models/FeedModel.java
index 08f9e48e..5fc6c1f2 100644
--- a/src/main/java/com/gitblit/models/FeedModel.java
+++ b/src/main/java/com/gitblit/models/FeedModel.java
@@ -22,7 +22,7 @@ import com.gitblit.utils.StringUtils;
/**
* FeedModel represents a syndication (RSS) feed.
- *
+ *
* @author James Moger
*/
public class FeedModel implements Serializable, Comparable<FeedModel> {
diff --git a/src/main/java/com/gitblit/models/ForkModel.java b/src/main/java/com/gitblit/models/ForkModel.java
index 849986c1..5c9f0370 100644
--- a/src/main/java/com/gitblit/models/ForkModel.java
+++ b/src/main/java/com/gitblit/models/ForkModel.java
@@ -24,44 +24,44 @@ import com.gitblit.utils.StringUtils;
/**
* A ForkModel represents a repository, its direct descendants, and its origin.
- *
+ *
* @author James Moger
*
*/
public class ForkModel implements Serializable {
private static final long serialVersionUID = 1L;
-
+
public final RepositoryModel repository;
-
+
public final List<ForkModel> forks;
-
+
public ForkModel(RepositoryModel repository) {
this.repository = repository;
this.forks = new ArrayList<ForkModel>();
}
-
+
public boolean isRoot() {
return StringUtils.isEmpty(repository.originRepository);
}
-
+
public boolean isNode() {
return !ArrayUtils.isEmpty(forks);
}
-
+
public boolean isLeaf() {
return ArrayUtils.isEmpty(forks);
}
-
+
public boolean isPersonalRepository() {
return repository.isPersonalRepository();
}
-
+
@Override
public int hashCode() {
return repository.hashCode();
}
-
+
@Override
public boolean equals(Object o) {
if (o instanceof ForkModel) {
@@ -69,7 +69,7 @@ public class ForkModel implements Serializable {
}
return false;
}
-
+
@Override
public String toString() {
return repository.toString();
diff --git a/src/main/java/com/gitblit/models/GitClientApplication.java b/src/main/java/com/gitblit/models/GitClientApplication.java
index eb47eb1f..e5b2e6c4 100644
--- a/src/main/java/com/gitblit/models/GitClientApplication.java
+++ b/src/main/java/com/gitblit/models/GitClientApplication.java
@@ -23,7 +23,7 @@ import com.gitblit.utils.StringUtils;
/**
* Model class to represent a git client application.
- *
+ *
* @author James Moger
*
*/
@@ -60,18 +60,18 @@ public class GitClientApplication implements Serializable {
}
return false;
}
-
+
public boolean supportsTransport(String transportOrUrl) {
if (ArrayUtils.isEmpty(transports)) {
return true;
}
-
+
String scheme = transportOrUrl;
if (transportOrUrl.indexOf(':') > -1) {
// strip scheme
scheme = transportOrUrl.substring(0, transportOrUrl.indexOf(':'));
}
-
+
for (String transport : transports) {
if (transport.equalsIgnoreCase(scheme)) {
return true;
@@ -79,7 +79,7 @@ public class GitClientApplication implements Serializable {
}
return false;
}
-
+
@Override
public String toString() {
return StringUtils.isEmpty(title) ? name : title;
diff --git a/src/main/java/com/gitblit/models/GitNote.java b/src/main/java/com/gitblit/models/GitNote.java
index c333a881..90b9a815 100644
--- a/src/main/java/com/gitblit/models/GitNote.java
+++ b/src/main/java/com/gitblit/models/GitNote.java
@@ -21,9 +21,9 @@ import java.io.Serializable;
* GitNote is a serializable model class that represents a git note. This class
* retains an instance of the RefModel which contains the commit in which this
* git note was created.
- *
+ *
* @author James Moger
- *
+ *
*/
public class GitNote implements Serializable {
diff --git a/src/main/java/com/gitblit/models/GravatarProfile.java b/src/main/java/com/gitblit/models/GravatarProfile.java
index aa128ce0..ec1aeea3 100644
--- a/src/main/java/com/gitblit/models/GravatarProfile.java
+++ b/src/main/java/com/gitblit/models/GravatarProfile.java
@@ -20,9 +20,9 @@ import java.util.List;
/**
* Represents a Gravatar profile.
- *
+ *
* @author James Moger
- *
+ *
*/
public class GravatarProfile implements Serializable {
@@ -35,7 +35,7 @@ public class GravatarProfile implements Serializable {
public String preferredUsername;
public String currentLocation;
public String aboutMe;
-
+
public String profileUrl;
public String thumbnailUrl;
public List<ProfileObject> photos;
diff --git a/src/main/java/com/gitblit/models/Metric.java b/src/main/java/com/gitblit/models/Metric.java
index 2845c527..2310a9aa 100644
--- a/src/main/java/com/gitblit/models/Metric.java
+++ b/src/main/java/com/gitblit/models/Metric.java
@@ -20,9 +20,9 @@ import java.io.Serializable;
/**
* Metric is a serializable model class that encapsulates metrics for some given
* type.
- *
+ *
* @author James Moger
- *
+ *
*/
public class Metric implements Serializable, Comparable<Metric> {
diff --git a/src/main/java/com/gitblit/models/PathModel.java b/src/main/java/com/gitblit/models/PathModel.java
index 9093a445..bf585425 100644
--- a/src/main/java/com/gitblit/models/PathModel.java
+++ b/src/main/java/com/gitblit/models/PathModel.java
@@ -24,9 +24,9 @@ import org.eclipse.jgit.lib.FileMode;
/**
* PathModel is a serializable model class that represents a file or a folder,
* including all its metadata and associated commit id.
- *
+ *
* @author James Moger
- *
+ *
*/
public class PathModel implements Serializable, Comparable<PathModel> {
@@ -56,7 +56,7 @@ public class PathModel implements Serializable, Comparable<PathModel> {
public boolean isSubmodule() {
return FileMode.GITLINK.equals(mode);
}
-
+
public boolean isTree() {
return FileMode.TREE.equals(mode);
}
@@ -105,26 +105,26 @@ public class PathModel implements Serializable, Comparable<PathModel> {
/**
* PathChangeModel is a serializable class that represents a file changed in
* a commit.
- *
+ *
* @author James Moger
- *
+ *
*/
public static class PathChangeModel extends PathModel {
private static final long serialVersionUID = 1L;
public ChangeType changeType;
-
+
public int insertions;
-
+
public int deletions;
-
+
public PathChangeModel(String name, String path, long size, int mode, String objectId,
String commitId, ChangeType type) {
super(name, path, size, mode, objectId, commitId);
this.changeType = type;
}
-
+
public void update(char op) {
switch (op) {
case '+':
diff --git a/src/main/java/com/gitblit/models/ProjectModel.java b/src/main/java/com/gitblit/models/ProjectModel.java
index cd912aea..3a082de3 100644
--- a/src/main/java/com/gitblit/models/ProjectModel.java
+++ b/src/main/java/com/gitblit/models/ProjectModel.java
@@ -26,9 +26,9 @@ import com.gitblit.utils.StringUtils;
/**
* ProjectModel is a serializable model class.
- *
+ *
* @author James Moger
- *
+ *
*/
public class ProjectModel implements Serializable, Comparable<ProjectModel> {
@@ -39,7 +39,7 @@ public class ProjectModel implements Serializable, Comparable<ProjectModel> {
public String title;
public String description;
public final Set<String> repositories = new HashSet<String>();
-
+
public String projectMarkdown;
public String repositoriesMarkdown;
public Date lastChange;
@@ -48,7 +48,7 @@ public class ProjectModel implements Serializable, Comparable<ProjectModel> {
public ProjectModel(String name) {
this(name, false);
}
-
+
public ProjectModel(String name, boolean isRoot) {
this.name = name;
this.isRoot = isRoot;
@@ -56,7 +56,7 @@ public class ProjectModel implements Serializable, Comparable<ProjectModel> {
this.title = "";
this.description = "";
}
-
+
public boolean isUserProject() {
return ModelUtils.isPersonalRepository(name);
}
@@ -80,16 +80,16 @@ public class ProjectModel implements Serializable, Comparable<ProjectModel> {
for (String name:names) {
repositories.add(name.toLowerCase());
}
- }
+ }
public void removeRepository(String name) {
repositories.remove(name.toLowerCase());
}
-
+
public String getDisplayName() {
return StringUtils.isEmpty(title) ? name : title;
}
-
+
@Override
public String toString() {
return name;
diff --git a/src/main/java/com/gitblit/models/RefLogEntry.java b/src/main/java/com/gitblit/models/RefLogEntry.java
index abfc56b1..07dc6f31 100644
--- a/src/main/java/com/gitblit/models/RefLogEntry.java
+++ b/src/main/java/com/gitblit/models/RefLogEntry.java
@@ -36,7 +36,7 @@ import com.gitblit.utils.StringUtils;
/**
* Model class to represent a push into a repository.
- *
+ *
* @author James Moger
*/
public class RefLogEntry implements Serializable, Comparable<RefLogEntry> {
@@ -44,22 +44,22 @@ public class RefLogEntry implements Serializable, Comparable<RefLogEntry> {
private static final long serialVersionUID = 1L;
public final String repository;
-
+
public final Date date;
-
+
public final UserModel user;
private final Set<RepositoryCommit> commits;
-
+
protected final Map<String, ReceiveCommand.Type> refUpdates;
-
+
protected final Map<String, String> refIdChanges;
-
+
private int authorCount;
/**
* Constructor for specified duration of push from start date.
- *
+ *
* @param repository
* the repository that received the push
* @param date
@@ -76,10 +76,10 @@ public class RefLogEntry implements Serializable, Comparable<RefLogEntry> {
this.refIdChanges = new HashMap<String, String>();
this.authorCount = -1;
}
-
+
/**
* Tracks the change type for the specified ref.
- *
+ *
* @param ref
* @param type
*/
@@ -88,10 +88,10 @@ public class RefLogEntry implements Serializable, Comparable<RefLogEntry> {
refUpdates.put(ref, type);
}
}
-
+
/**
* Tracks the change type for the specified ref.
- *
+ *
* @param ref
* @param type
* @param oldId
@@ -103,10 +103,10 @@ public class RefLogEntry implements Serializable, Comparable<RefLogEntry> {
refIdChanges.put(ref, oldId + "-" + newId);
}
}
-
+
/**
* Returns the old id of a ref.
- *
+ *
* @param ref
* @return the old id
*/
@@ -120,7 +120,7 @@ public class RefLogEntry implements Serializable, Comparable<RefLogEntry> {
/**
* Returns the new id of a ref
- *
+ *
* @param ref
* @return the new id
*/
@@ -131,10 +131,10 @@ public class RefLogEntry implements Serializable, Comparable<RefLogEntry> {
}
return change.split("-")[1];
}
-
+
/**
* Returns the change type of the ref change.
- *
+ *
* @param ref
* @return the change type for the ref
*/
@@ -146,7 +146,7 @@ public class RefLogEntry implements Serializable, Comparable<RefLogEntry> {
/**
* Adds a commit to the push entry object as long as the commit is not a
* duplicate.
- *
+ *
* @param branch
* @param commit
* @return a RepositoryCommit, if one was added. Null if this is duplicate
@@ -164,7 +164,7 @@ public class RefLogEntry implements Serializable, Comparable<RefLogEntry> {
/**
* Adds a commit to the push entry object as long as the commit is not a
* duplicate.
- *
+ *
* @param branch
* @param commit
* @return a RepositoryCommit, if one was added. Null if this is duplicate
@@ -181,17 +181,17 @@ public class RefLogEntry implements Serializable, Comparable<RefLogEntry> {
/**
* Adds a a list of repository commits. This is used to construct discrete
* ref push log entries
- *
+ *
* @param commits
*/
public void addCommits(List<RepositoryCommit> list) {
commits.addAll(list);
authorCount = -1;
}
-
+
/**
* Returns true if this push contains a non-fastforward ref update.
- *
+ *
* @return true if this is a non-fastforward push
*/
public boolean isNonFastForward() {
@@ -202,10 +202,10 @@ public class RefLogEntry implements Serializable, Comparable<RefLogEntry> {
}
return false;
}
-
+
/**
* Returns true if this ref has been rewound.
- *
+ *
* @param ref
* @return true if this is a non-fastforward ref update
*/
@@ -219,7 +219,7 @@ public class RefLogEntry implements Serializable, Comparable<RefLogEntry> {
/**
* Returns true if this ref has been deleted.
- *
+ *
* @param ref
* @return true if this is a delete ref update
*/
@@ -230,28 +230,28 @@ public class RefLogEntry implements Serializable, Comparable<RefLogEntry> {
}
return ReceiveCommand.Type.DELETE.equals(type);
}
-
+
/**
* Returns the list of refs changed by the push.
- *
+ *
* @return a list of refs
*/
public List<String> getChangedRefs() {
return new ArrayList<String>(refUpdates.keySet());
}
-
+
/**
* Returns the list of branches changed by the push.
- *
+ *
* @return a list of branches
*/
public List<String> getChangedBranches() {
return getChangedRefs(Constants.R_HEADS);
}
-
+
/**
* Returns the list of tags changed by the push.
- *
+ *
* @return a list of tags
*/
public List<String> getChangedTags() {
@@ -260,7 +260,7 @@ public class RefLogEntry implements Serializable, Comparable<RefLogEntry> {
/**
* Gets the changed refs in the push.
- *
+ *
* @param baseRef
* @return the changed refs
*/
@@ -275,7 +275,7 @@ public class RefLogEntry implements Serializable, Comparable<RefLogEntry> {
Collections.sort(list);
return list;
}
-
+
public int getAuthorCount() {
if (authorCount == -1) {
Set<String> authors = new HashSet<String>();
@@ -287,19 +287,19 @@ public class RefLogEntry implements Serializable, Comparable<RefLogEntry> {
}
return authorCount;
}
-
+
/**
* The total number of commits in the push.
- *
+ *
* @return the number of commits in the push
*/
public int getCommitCount() {
return commits.size();
}
-
+
/**
* Returns all commits in the push.
- *
+ *
* @return a list of commits
*/
public List<RepositoryCommit> getCommits() {
@@ -307,10 +307,10 @@ public class RefLogEntry implements Serializable, Comparable<RefLogEntry> {
Collections.sort(list);
return list;
}
-
+
/**
* Returns all commits that belong to a particular ref
- *
+ *
* @param ref
* @return a list of commits
*/
@@ -324,7 +324,7 @@ public class RefLogEntry implements Serializable, Comparable<RefLogEntry> {
Collections.sort(list);
return list;
}
-
+
public PersonIdent getCommitterIdent() {
return new PersonIdent(user.getDisplayName(), user.emailAddress == null ? user.username : user.emailAddress);
}
@@ -341,7 +341,7 @@ public class RefLogEntry implements Serializable, Comparable<RefLogEntry> {
// reverse chronological order
return o.date.compareTo(date);
}
-
+
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
diff --git a/src/main/java/com/gitblit/models/RefModel.java b/src/main/java/com/gitblit/models/RefModel.java
index 8489c817..6b031ed3 100644
--- a/src/main/java/com/gitblit/models/RefModel.java
+++ b/src/main/java/com/gitblit/models/RefModel.java
@@ -28,9 +28,9 @@ import org.eclipse.jgit.revwalk.RevTag;
/**
* RefModel is a serializable model class that represents a tag or branch and
* includes the referenced object.
- *
+ *
* @author James Moger
- *
+ *
*/
public class RefModel implements Serializable, Comparable<RefModel> {
diff --git a/src/main/java/com/gitblit/models/RegistrantAccessPermission.java b/src/main/java/com/gitblit/models/RegistrantAccessPermission.java
index 8f4049a8..a7fcde44 100644
--- a/src/main/java/com/gitblit/models/RegistrantAccessPermission.java
+++ b/src/main/java/com/gitblit/models/RegistrantAccessPermission.java
@@ -24,7 +24,7 @@ import com.gitblit.utils.StringUtils;
/**
* Represents a Registrant-AccessPermission tuple.
- *
+ *
* @author James Moger
*/
public class RegistrantAccessPermission implements Serializable, Comparable<RegistrantAccessPermission> {
@@ -37,7 +37,7 @@ public class RegistrantAccessPermission implements Serializable, Comparable<Regi
public PermissionType permissionType;
public boolean mutable;
public String source;
-
+
public RegistrantAccessPermission() {
}
@@ -46,7 +46,7 @@ public class RegistrantAccessPermission implements Serializable, Comparable<Regi
this.permissionType = PermissionType.EXPLICIT;
this.mutable = true;
}
-
+
public RegistrantAccessPermission(String registrant, AccessPermission permission, PermissionType permissionType, RegistrantType registrantType, String source, boolean mutable) {
this.registrant = registrant;
this.permission = permission;
@@ -55,7 +55,7 @@ public class RegistrantAccessPermission implements Serializable, Comparable<Regi
this.source = source;
this.mutable = mutable;
}
-
+
public boolean isAdmin() {
return PermissionType.ADMINISTRATOR.equals(permissionType);
}
@@ -63,7 +63,7 @@ public class RegistrantAccessPermission implements Serializable, Comparable<Regi
public boolean isOwner() {
return PermissionType.OWNER.equals(permissionType);
}
-
+
public boolean isExplicit() {
return PermissionType.EXPLICIT.equals(permissionType);
}
@@ -79,7 +79,7 @@ public class RegistrantAccessPermission implements Serializable, Comparable<Regi
public boolean isMissing() {
return PermissionType.MISSING.equals(permissionType);
}
-
+
public int getScore() {
switch (registrantType) {
case REPOSITORY:
@@ -102,7 +102,7 @@ public class RegistrantAccessPermission implements Serializable, Comparable<Regi
return 0;
}
}
-
+
@Override
public int compareTo(RegistrantAccessPermission p) {
switch (registrantType) {
@@ -113,7 +113,7 @@ public class RegistrantAccessPermission implements Serializable, Comparable<Regi
int score2 = p.getScore();
if (score1 <= 2 && score2 <= 2) {
// group admin, owner, and explicit together
- return StringUtils.compareRepositoryNames(registrant, p.registrant);
+ return StringUtils.compareRepositoryNames(registrant, p.registrant);
}
if (score1 < score2) {
return -1;
@@ -126,22 +126,22 @@ public class RegistrantAccessPermission implements Serializable, Comparable<Regi
return registrant.toLowerCase().compareTo(p.registrant.toLowerCase());
}
}
-
+
@Override
public int hashCode() {
return registrant.hashCode();
}
-
+
@Override
public boolean equals(Object o) {
if (o instanceof RegistrantAccessPermission) {
RegistrantAccessPermission p = (RegistrantAccessPermission) o;
return registrant.equals(p.registrant);
}
-
+
return false;
}
-
+
@Override
public String toString() {
return permission.asRole(registrant);
diff --git a/src/main/java/com/gitblit/models/RepositoryCommit.java b/src/main/java/com/gitblit/models/RepositoryCommit.java
index dd58b42b..765b4898 100644
--- a/src/main/java/com/gitblit/models/RepositoryCommit.java
+++ b/src/main/java/com/gitblit/models/RepositoryCommit.java
@@ -27,7 +27,7 @@ import org.eclipse.jgit.revwalk.RevCommit;
/**
* Model class to represent a RevCommit, it's source repository, and the branch.
* This class is used by the activity page.
- *
+ *
* @author James Moger
*/
public class RepositoryCommit implements Serializable, Comparable<RepositoryCommit> {
@@ -71,7 +71,7 @@ public class RepositoryCommit implements Serializable, Comparable<RepositoryComm
public String getShortMessage() {
return commit.getShortMessage();
}
-
+
public Date getCommitDate() {
return new Date(commit.getCommitTime() * 1000L);
}
@@ -79,7 +79,7 @@ public class RepositoryCommit implements Serializable, Comparable<RepositoryComm
public int getParentCount() {
return commit.getParentCount();
}
-
+
public RevCommit [] getParents() {
return commit.getParents();
}
@@ -91,7 +91,7 @@ public class RepositoryCommit implements Serializable, Comparable<RepositoryComm
public PersonIdent getCommitterIdent() {
return commit.getCommitterIdent();
}
-
+
@Override
public boolean equals(Object o) {
if (o instanceof RepositoryCommit) {
@@ -116,14 +116,14 @@ public class RepositoryCommit implements Serializable, Comparable<RepositoryComm
}
return 0;
}
-
+
public RepositoryCommit clone(String withRef) {
return new RepositoryCommit(repository, withRef, commit);
}
-
+
@Override
public String toString() {
- return MessageFormat.format("{0} {1} {2,date,yyyy-MM-dd HH:mm} {3} {4}",
+ return MessageFormat.format("{0} {1} {2,date,yyyy-MM-dd HH:mm} {3} {4}",
getShortName(), branch, getCommitterIdent().getWhen(), getAuthorIdent().getName(),
getShortMessage());
}
diff --git a/src/main/java/com/gitblit/models/RepositoryModel.java b/src/main/java/com/gitblit/models/RepositoryModel.java
index f0354b9a..42331c4e 100644
--- a/src/main/java/com/gitblit/models/RepositoryModel.java
+++ b/src/main/java/com/gitblit/models/RepositoryModel.java
@@ -35,9 +35,9 @@ import com.gitblit.utils.StringUtils;
/**
* RepositoryModel is a serializable model class that represents a Gitblit
* repository including its configuration settings and access restriction.
- *
+ *
* @author James Moger
- *
+ *
*/
public class RepositoryModel implements Serializable, Comparable<RepositoryModel> {
@@ -84,14 +84,14 @@ public class RepositoryModel implements Serializable, Comparable<RepositoryModel
public boolean verifyCommitter;
public String gcThreshold;
public int gcPeriod;
- public int maxActivityCommits;
+ public int maxActivityCommits;
public List<String> metricAuthorExclusions;
public CommitMessageRenderer commitMessageRenderer;
-
+
public transient boolean isCollectingGarbage;
public Date lastGC;
public String sparkleshareId;
-
+
public RepositoryModel() {
this("", "", "", new Date(0));
}
@@ -103,14 +103,14 @@ public class RepositoryModel implements Serializable, Comparable<RepositoryModel
this.accessRestriction = AccessRestrictionType.NONE;
this.authorizationControl = AuthorizationControl.NAMED;
this.federationSets = new ArrayList<String>();
- this.federationStrategy = FederationStrategy.FEDERATE_THIS;
+ this.federationStrategy = FederationStrategy.FEDERATE_THIS;
this.projectPath = StringUtils.getFirstPathElement(name);
this.owners = new ArrayList<String>();
this.isBare = true;
-
+
addOwner(owner);
}
-
+
public List<String> getLocalBranches() {
if (ArrayUtils.isEmpty(availableRefs)) {
return new ArrayList<String>();
@@ -123,30 +123,30 @@ public class RepositoryModel implements Serializable, Comparable<RepositoryModel
}
return localBranches;
}
-
+
public void addFork(String repository) {
if (forks == null) {
forks = new TreeSet<String>();
}
forks.add(repository);
}
-
+
public void removeFork(String repository) {
if (forks == null) {
return;
}
forks.remove(repository);
}
-
+
public void resetDisplayName() {
displayName = null;
}
-
+
@Override
public int hashCode() {
return name.hashCode();
}
-
+
@Override
public boolean equals(Object o) {
if (o instanceof RepositoryModel) {
@@ -167,38 +167,38 @@ public class RepositoryModel implements Serializable, Comparable<RepositoryModel
public int compareTo(RepositoryModel o) {
return StringUtils.compareRepositoryNames(name, o.name);
}
-
+
public boolean isFork() {
return !StringUtils.isEmpty(originRepository);
}
-
+
public boolean isOwner(String username) {
if (StringUtils.isEmpty(username) || ArrayUtils.isEmpty(owners)) {
return false;
}
return owners.contains(username.toLowerCase());
}
-
+
public boolean isPersonalRepository() {
return !StringUtils.isEmpty(projectPath) && ModelUtils.isPersonalRepository(projectPath);
}
-
+
public boolean isUsersPersonalRepository(String username) {
return !StringUtils.isEmpty(projectPath) && ModelUtils.isUsersPersonalRepository(username, projectPath);
}
-
+
public boolean allowAnonymousView() {
return !accessRestriction.atLeast(AccessRestrictionType.VIEW);
}
-
+
public boolean isShowActivity() {
return maxActivityCommits > -1;
}
-
+
public boolean isSparkleshared() {
return !StringUtils.isEmpty(sparkleshareId);
}
-
+
public RepositoryModel cloneAs(String cloneName) {
RepositoryModel clone = new RepositoryModel();
clone.originRepository = name;
@@ -216,7 +216,7 @@ public class RepositoryModel implements Serializable, Comparable<RepositoryModel
clone.useTickets = useTickets;
clone.skipSizeCalculation = skipSizeCalculation;
clone.skipSummaryMetrics = skipSummaryMetrics;
- clone.sparkleshareId = sparkleshareId;
+ clone.sparkleshareId = sparkleshareId;
return clone;
}
diff --git a/src/main/java/com/gitblit/models/RepositoryUrl.java b/src/main/java/com/gitblit/models/RepositoryUrl.java
index d72959a2..a24def57 100644
--- a/src/main/java/com/gitblit/models/RepositoryUrl.java
+++ b/src/main/java/com/gitblit/models/RepositoryUrl.java
@@ -22,7 +22,7 @@ import com.gitblit.Constants.AccessPermission;
/**
* Represents a git repository url and it's associated access permission for the
* current user.
- *
+ *
* @author James Moger
*
*/
@@ -37,7 +37,7 @@ public class RepositoryUrl implements Serializable {
this.url = url;
this.permission = permission;
}
-
+
public boolean isExternal() {
return permission == null;
}
diff --git a/src/main/java/com/gitblit/models/SearchResult.java b/src/main/java/com/gitblit/models/SearchResult.java
index ee27a063..32edc2d7 100644
--- a/src/main/java/com/gitblit/models/SearchResult.java
+++ b/src/main/java/com/gitblit/models/SearchResult.java
@@ -8,16 +8,16 @@ import com.gitblit.Constants.SearchObjectType;
/**
* Model class that represents a search result.
- *
+ *
* @author James Moger
- *
+ *
*/
public class SearchResult implements Serializable {
private static final long serialVersionUID = 1L;
-
+
public int hitId;
-
+
public int totalHits;
public float score;
@@ -29,24 +29,24 @@ public class SearchResult implements Serializable {
public String committer;
public String summary;
-
+
public String fragment;
-
+
public String repository;
-
+
public String branch;
public String commitId;
-
+
public String path;
-
+
public List<String> tags;
-
+
public SearchObjectType type;
public SearchResult() {
}
-
+
public String getId() {
switch (type) {
case blob:
diff --git a/src/main/java/com/gitblit/models/ServerSettings.java b/src/main/java/com/gitblit/models/ServerSettings.java
index 27199b41..92d5c311 100644
--- a/src/main/java/com/gitblit/models/ServerSettings.java
+++ b/src/main/java/com/gitblit/models/ServerSettings.java
@@ -26,7 +26,7 @@ import java.util.TreeMap;
* setting metadata such as name, current value, default value, description, and
* directives. It is a model class for serialization and presentation, but not
* for persistence.
- *
+ *
* @author James Moger
*/
public class ServerSettings implements Serializable {
@@ -36,13 +36,13 @@ public class ServerSettings implements Serializable {
private static final long serialVersionUID = 1L;
public List<String> pushScripts;
-
+
public boolean supportsCredentialChanges;
-
+
public boolean supportsDisplayNameChanges;
-
+
public boolean supportsEmailAddressChanges;
-
+
public boolean supportsTeamMembershipChanges;
public ServerSettings() {
@@ -62,7 +62,7 @@ public class ServerSettings implements Serializable {
public SettingModel get(String key) {
return settings.get(key);
}
-
+
public boolean hasKey(String key) {
return settings.containsKey(key);
}
diff --git a/src/main/java/com/gitblit/models/ServerStatus.java b/src/main/java/com/gitblit/models/ServerStatus.java
index 3a1e0306..f8afd00a 100644
--- a/src/main/java/com/gitblit/models/ServerStatus.java
+++ b/src/main/java/com/gitblit/models/ServerStatus.java
@@ -25,9 +25,9 @@ import com.gitblit.Constants;
/**
* ServerStatus encapsulates runtime status information about the server
* including some information about the system environment.
- *
+ *
* @author James Moger
- *
+ *
*/
public class ServerStatus implements Serializable {
diff --git a/src/main/java/com/gitblit/models/SettingModel.java b/src/main/java/com/gitblit/models/SettingModel.java
index a04126e1..ef77e156 100644
--- a/src/main/java/com/gitblit/models/SettingModel.java
+++ b/src/main/java/com/gitblit/models/SettingModel.java
@@ -26,7 +26,7 @@ import com.gitblit.utils.StringUtils;
/**
* SettingModel represents a setting and all its metadata: name, current value,
* default value, description, and directives.
- *
+ *
* @author James Moger
*/
public class SettingModel implements Serializable {
@@ -55,7 +55,7 @@ public class SettingModel implements Serializable {
/**
* Returns true if the current value is the default value.
- *
+ *
* @return true if current value is the default value
*/
public boolean isDefaultValue() {
@@ -66,7 +66,7 @@ public class SettingModel implements Serializable {
/**
* Returns the boolean value for the currentValue. If the currentValue can
* not be interpreted as a boolean, the defaultValue is returned.
- *
+ *
* @param defaultValue
* @return key value or defaultValue
*/
@@ -80,7 +80,7 @@ public class SettingModel implements Serializable {
/**
* Returns the integer value for the currentValue. If the currentValue can
* not be interpreted as an integer, the defaultValue is returned.
- *
+ *
* @param defaultValue
* @return key value or defaultValue
*/
@@ -97,7 +97,7 @@ public class SettingModel implements Serializable {
/**
* Returns the char value for currentValue. If the currentValue can not be
* interpreted as a char, the defaultValue is returned.
- *
+ *
* @param defaultValue
* @return key value or defaultValue
*/
@@ -111,7 +111,7 @@ public class SettingModel implements Serializable {
/**
* Returns the string value for currentValue. If the currentValue is null,
* the defaultValue is returned.
- *
+ *
* @param defaultValue
* @return key value or defaultValue
*/
@@ -124,7 +124,7 @@ public class SettingModel implements Serializable {
/**
* Returns a list of space-separated strings from the specified key.
- *
+ *
* @return list of strings
*/
public List<String> getStrings() {
@@ -134,7 +134,7 @@ public class SettingModel implements Serializable {
/**
* Returns a list of strings from the currentValue using the specified
* string separator.
- *
+ *
* @param separator
* @return list of strings
*/
@@ -143,10 +143,10 @@ public class SettingModel implements Serializable {
strings = StringUtils.getStringsFromValue(currentValue, separator);
return strings;
}
-
+
/**
* Returns a map of strings from the current value.
- *
+ *
* @return map of string, string
*/
public Map<String, String> getMap() {
@@ -154,7 +154,7 @@ public class SettingModel implements Serializable {
for (String string : getStrings()) {
String[] kvp = string.split("=", 2);
String key = kvp[0];
- String value = kvp[1];
+ String value = kvp[1];
map.put(key, value);
}
return map;
diff --git a/src/main/java/com/gitblit/models/SubmoduleModel.java b/src/main/java/com/gitblit/models/SubmoduleModel.java
index 47f84b95..15b69d7c 100644
--- a/src/main/java/com/gitblit/models/SubmoduleModel.java
+++ b/src/main/java/com/gitblit/models/SubmoduleModel.java
@@ -20,9 +20,9 @@ import java.io.Serializable;
/**
* SubmoduleModel is a serializable model class that represents a git submodule
* definition.
- *
+ *
* @author James Moger
- *
+ *
*/
public class SubmoduleModel implements Serializable {
@@ -40,7 +40,8 @@ public class SubmoduleModel implements Serializable {
this.path = path;
this.url = url;
}
-
+
+ @Override
public String toString() {
return path + "=" + url;
}
diff --git a/src/main/java/com/gitblit/models/TeamModel.java b/src/main/java/com/gitblit/models/TeamModel.java
index dfbd45d4..54f194b1 100644
--- a/src/main/java/com/gitblit/models/TeamModel.java
+++ b/src/main/java/com/gitblit/models/TeamModel.java
@@ -35,9 +35,9 @@ import com.gitblit.utils.StringUtils;
/**
* TeamModel is a serializable model class that represents a group of users and
* a list of accessible repositories.
- *
+ *
* @author James Moger
- *
+ *
*/
public class TeamModel implements Serializable, Comparable<TeamModel> {
@@ -77,7 +77,7 @@ public class TeamModel implements Serializable, Comparable<TeamModel> {
public void addRepository(String name) {
addRepositoryPermission(name);
}
-
+
@Deprecated
@Unused
public void addRepositories(Collection<String> names) {
@@ -90,10 +90,10 @@ public class TeamModel implements Serializable, Comparable<TeamModel> {
removeRepositoryPermission(name);
}
-
+
/**
* Returns a list of repository permissions for this team.
- *
+ *
* @return the team's list of permissions
*/
public List<RegistrantAccessPermission> getRepositoryPermissions() {
@@ -117,11 +117,11 @@ public class TeamModel implements Serializable, Comparable<TeamModel> {
Collections.sort(list);
return list;
}
-
+
/**
* Returns true if the team has any type of specified access permission for
* this repository.
- *
+ *
* @param name
* @return true if team has a specified access permission for the repository
*/
@@ -143,11 +143,11 @@ public class TeamModel implements Serializable, Comparable<TeamModel> {
}
return false;
}
-
+
/**
* Returns true if the team has an explicitly specified access permission for
* this repository.
- *
+ *
* @param name
* @return if the team has an explicitly specified access permission
*/
@@ -155,7 +155,7 @@ public class TeamModel implements Serializable, Comparable<TeamModel> {
String repository = AccessPermission.repositoryFromRole(name).toLowerCase();
return permissions.containsKey(repository);
}
-
+
/**
* Adds a repository permission to the team.
* <p>
@@ -178,13 +178,13 @@ public class TeamModel implements Serializable, Comparable<TeamModel> {
addRepositoryPermission(role);
}
}
-
+
public AccessPermission removeRepositoryPermission(String name) {
String repository = AccessPermission.repositoryFromRole(name).toLowerCase();
repositories.remove(repository);
return permissions.remove(repository);
}
-
+
public void setRepositoryPermission(String repository, AccessPermission permission) {
if (permission == null) {
// remove the permission
@@ -196,16 +196,16 @@ public class TeamModel implements Serializable, Comparable<TeamModel> {
repositories.add(repository.toLowerCase());
}
}
-
+
public RegistrantAccessPermission getRepositoryPermission(RepositoryModel repository) {
RegistrantAccessPermission ap = new RegistrantAccessPermission();
ap.registrant = name;
ap.registrantType = RegistrantType.TEAM;
ap.permission = AccessPermission.NONE;
ap.mutable = false;
-
+
// determine maximum permission for the repository
- final AccessPermission maxPermission =
+ final AccessPermission maxPermission =
(repository.isFrozen || !repository.isBare) ?
AccessPermission.CLONE : AccessPermission.REWIND;
@@ -219,7 +219,7 @@ public class TeamModel implements Serializable, Comparable<TeamModel> {
}
return ap;
}
-
+
if (canAdmin) {
ap.permissionType = PermissionType.ADMINISTRATOR;
if (AccessPermission.REWIND.atMost(maxPermission)) {
@@ -229,7 +229,7 @@ public class TeamModel implements Serializable, Comparable<TeamModel> {
}
return ap;
}
-
+
if (permissions.containsKey(repository.name.toLowerCase())) {
// exact repository permission specified
AccessPermission p = permissions.get(repository.name.toLowerCase());
@@ -262,7 +262,7 @@ public class TeamModel implements Serializable, Comparable<TeamModel> {
}
}
}
-
+
// still no explicit or regex, check for implicit permissions
if (AccessPermission.NONE == ap.permission) {
switch (repository.accessRestriction) {
@@ -289,7 +289,7 @@ public class TeamModel implements Serializable, Comparable<TeamModel> {
return ap;
}
-
+
protected boolean canAccess(RepositoryModel repository, AccessRestrictionType ifRestriction, AccessPermission requirePermission) {
if (repository.accessRestriction.atLeast(ifRestriction)) {
RegistrantAccessPermission ap = getRepositoryPermission(repository);
@@ -297,7 +297,7 @@ public class TeamModel implements Serializable, Comparable<TeamModel> {
}
return true;
}
-
+
public boolean canView(RepositoryModel repository) {
return canAccess(repository, AccessRestrictionType.VIEW, AccessPermission.VIEW);
}
diff --git a/src/main/java/com/gitblit/models/UserModel.java b/src/main/java/com/gitblit/models/UserModel.java
index d785ae9e..b4fdb66f 100644
--- a/src/main/java/com/gitblit/models/UserModel.java
+++ b/src/main/java/com/gitblit/models/UserModel.java
@@ -42,16 +42,16 @@ import com.gitblit.utils.StringUtils;
* UserModel is a serializable model class that represents a user and the user's
* restricted repository memberships. Instances of UserModels are also used as
* servlet user principals.
- *
+ *
* @author James Moger
- *
+ *
*/
public class UserModel implements Principal, Serializable, Comparable<UserModel> {
private static final long serialVersionUID = 1L;
public static final UserModel ANONYMOUS = new UserModel();
-
+
// field names are reflectively mapped in EditUser page
public String username;
public String password;
@@ -78,7 +78,7 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
public AccountType accountType;
public UserPreferences userPreferences;
-
+
public UserModel(String username) {
this.username = username;
this.isAuthenticated = true;
@@ -92,7 +92,7 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
this.accountType = AccountType.LOCAL;
this.userPreferences = new UserPreferences(this.username);
}
-
+
public boolean isLocalAccount() {
return accountType.isLocal();
}
@@ -100,7 +100,7 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
/**
* This method does not take into consideration Ownership where the
* administrator has not explicitly granted access to the owner.
- *
+ *
* @param repositoryName
* @return
*/
@@ -129,7 +129,7 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
}
return false;
}
-
+
@Deprecated
@Unused
public boolean hasRepository(String name) {
@@ -147,11 +147,11 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
public void removeRepository(String name) {
removeRepositoryPermission(name);
}
-
+
/**
* Returns a list of repository permissions for this user exclusive of
* permissions inherited from team memberships.
- *
+ *
* @return the user's list of permissions
*/
public List<RegistrantAccessPermission> getRepositoryPermissions() {
@@ -178,7 +178,7 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
list.add(new RegistrantAccessPermission(registrant, ap, pType, RegistrantType.REPOSITORY, source, mutable));
}
Collections.sort(list);
-
+
// include immutable team permissions, being careful to preserve order
Set<RegistrantAccessPermission> set = new LinkedHashSet<RegistrantAccessPermission>(list);
for (TeamModel team : teams) {
@@ -193,11 +193,11 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
}
return new ArrayList<RegistrantAccessPermission>(set);
}
-
+
/**
* Returns true if the user has any type of specified access permission for
* this repository.
- *
+ *
* @param name
* @return true if user has a specified access permission for the repository
*/
@@ -219,11 +219,11 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
}
return false;
}
-
+
/**
* Returns true if the user has an explicitly specified access permission for
* this repository.
- *
+ *
* @param name
* @return if the user has an explicitly specified access permission
*/
@@ -231,11 +231,11 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
String repository = AccessPermission.repositoryFromRole(name).toLowerCase();
return permissions.containsKey(repository);
}
-
+
/**
* Returns true if the user's team memberships specify an access permission for
* this repository.
- *
+ *
* @param name
* @return if the user's team memberships specifi an access permission
*/
@@ -249,7 +249,7 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
}
return false;
}
-
+
/**
* Adds a repository permission to the team.
* <p>
@@ -266,13 +266,13 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
repositories.add(repository);
permissions.put(repository, permission);
}
-
+
public AccessPermission removeRepositoryPermission(String name) {
String repository = AccessPermission.repositoryFromRole(name).toLowerCase();
repositories.remove(repository);
return permissions.remove(repository);
}
-
+
public void setRepositoryPermission(String repository, AccessPermission permission) {
if (permission == null) {
// remove the permission
@@ -289,9 +289,9 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
ap.registrantType = RegistrantType.USER;
ap.permission = AccessPermission.NONE;
ap.mutable = false;
-
+
// determine maximum permission for the repository
- final AccessPermission maxPermission =
+ final AccessPermission maxPermission =
(repository.isFrozen || !repository.isBare) ?
AccessPermission.CLONE : AccessPermission.REWIND;
@@ -325,7 +325,7 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
}
return ap;
}
-
+
// repository owner - either specified owner or personal repository
if (repository.isOwner(username) || repository.isUsersPersonalRepository(username)) {
ap.permissionType = PermissionType.OWNER;
@@ -336,7 +336,7 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
}
return ap;
}
-
+
if (AuthorizationControl.AUTHENTICATED.equals(repository.authorizationControl) && isAuthenticated) {
// AUTHENTICATED is a shortcut for authorizing all logged-in users RW+ access
if (AccessPermission.REWIND.atMost(maxPermission)) {
@@ -346,7 +346,7 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
}
return ap;
}
-
+
// explicit user permission OR user regex match is used
// if that fails, then the best team permission is used
if (permissions.containsKey(repository.name.toLowerCase())) {
@@ -381,7 +381,7 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
}
}
}
-
+
// try to find a team match
for (TeamModel team : teams) {
RegistrantAccessPermission p = team.getRepositoryPermission(repository);
@@ -392,7 +392,7 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
ap.permissionType = PermissionType.TEAM;
}
}
-
+
// still no explicit, regex, or team match, check for implicit permissions
if (AccessPermission.NONE == ap.permission) {
switch (repository.accessRestriction) {
@@ -416,10 +416,10 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
break;
}
}
-
+
return ap;
}
-
+
protected boolean canAccess(RepositoryModel repository, AccessRestrictionType ifRestriction, AccessPermission requirePermission) {
if (repository.accessRestriction.atLeast(ifRestriction)) {
RegistrantAccessPermission ap = getRepositoryPermission(repository);
@@ -427,11 +427,11 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
}
return true;
}
-
+
public boolean canView(RepositoryModel repository) {
return canAccess(repository, AccessRestrictionType.VIEW, AccessPermission.VIEW);
}
-
+
public boolean canView(RepositoryModel repository, String ref) {
// Default UserModel doesn't implement ref-level security.
// Other Realms (i.e. Gerrit) may override this method.
@@ -486,19 +486,19 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
}
return canClone(repository);
}
-
+
public boolean canDelete(RepositoryModel model) {
return canAdmin() || model.isUsersPersonalRepository(username);
}
-
+
public boolean canEdit(RepositoryModel model) {
return canAdmin() || model.isUsersPersonalRepository(username) || model.isOwner(username);
}
-
+
/**
* This returns true if the user has fork privileges or the user has fork
* privileges because of a team membership.
- *
+ *
* @return true if the user can fork
*/
public boolean canFork() {
@@ -518,7 +518,7 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
/**
* This returns true if the user has admin privileges or the user has admin
* privileges because of a team membership.
- *
+ *
* @return true if the user can admin
*/
public boolean canAdmin() {
@@ -538,7 +538,7 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
/**
* This returns true if the user has create privileges or the user has create
* privileges because of a team membership.
- *
+ *
* @return true if the user can admin
*/
public boolean canCreate() {
@@ -554,10 +554,10 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
}
return false;
}
-
+
/**
* Returns true if the user is allowed to create the specified repository.
- *
+ *
* @param repository
* @return true if the user can create the repository
*/
@@ -601,27 +601,27 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
public String getName() {
return username;
}
-
+
public String getDisplayName() {
if (StringUtils.isEmpty(displayName)) {
return username;
}
return displayName;
}
-
+
public String getPersonalPath() {
return ModelUtils.getPersonalPath(username);
}
-
+
public UserPreferences getPreferences() {
return userPreferences;
}
-
+
@Override
public int hashCode() {
return username.hashCode();
}
-
+
@Override
public boolean equals(Object o) {
if (o instanceof UserModel) {
@@ -639,10 +639,10 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
public int compareTo(UserModel o) {
return username.compareTo(o.username);
}
-
+
/**
* Returns true if the name/email pair match this user account.
- *
+ *
* @param name
* @param email
* @return true, if the name and email address match this account
@@ -667,13 +667,13 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
}
return nameVerified && emailVerified;
}
-
+
@Deprecated
public boolean hasBranchPermission(String repositoryName, String branch) {
// Default UserModel doesn't implement branch-level security. Other Realms (i.e. Gerrit) may override this method.
return hasRepositoryPermission(repositoryName) || hasTeamRepositoryPermission(repositoryName);
}
-
+
public boolean isMyPersonalRepository(String repository) {
String projectPath = StringUtils.getFirstPathElement(repository);
return !StringUtils.isEmpty(projectPath) && projectPath.equalsIgnoreCase(getPersonalPath());
diff --git a/src/main/java/com/gitblit/models/UserPreferences.java b/src/main/java/com/gitblit/models/UserPreferences.java
index e6baa289..baab0719 100644
--- a/src/main/java/com/gitblit/models/UserPreferences.java
+++ b/src/main/java/com/gitblit/models/UserPreferences.java
@@ -27,7 +27,7 @@ import com.gitblit.utils.StringUtils;
/**
* User preferences.
- *
+ *
* @author James Moger
*
*/
@@ -38,20 +38,20 @@ public class UserPreferences implements Serializable {
public final String username;
public String locale;
-
+
private final Map<String, UserRepositoryPreferences> repositoryPreferences = new TreeMap<String, UserRepositoryPreferences>();
public UserPreferences(String username) {
this.username = username;
}
-
+
public Locale getLocale() {
if (StringUtils.isEmpty(locale)) {
return null;
}
return new Locale(locale);
}
-
+
public UserRepositoryPreferences getRepositoryPreferences(String repositoryName) {
String key = repositoryName.toLowerCase();
if (!repositoryPreferences.containsKey(key)) {
@@ -63,11 +63,11 @@ public class UserPreferences implements Serializable {
}
return repositoryPreferences.get(key);
}
-
+
public void setRepositoryPreferences(UserRepositoryPreferences pref) {
repositoryPreferences.put(pref.repositoryName.toLowerCase(), pref);
}
-
+
public boolean isStarredRepository(String repository) {
if (repositoryPreferences == null) {
return false;
@@ -79,7 +79,7 @@ public class UserPreferences implements Serializable {
}
return false;
}
-
+
public List<String> getStarredRepositories() {
List<String> list = new ArrayList<String>();
for (UserRepositoryPreferences prefs : repositoryPreferences.values()) {
diff --git a/src/main/java/com/gitblit/models/UserRepositoryPreferences.java b/src/main/java/com/gitblit/models/UserRepositoryPreferences.java
index bc3a1845..80b71f3e 100644
--- a/src/main/java/com/gitblit/models/UserRepositoryPreferences.java
+++ b/src/main/java/com/gitblit/models/UserRepositoryPreferences.java
@@ -19,7 +19,7 @@ import java.io.Serializable;
/**
* User repository preferences.
- *
+ *
* @author James Moger
*
*/
@@ -28,11 +28,11 @@ public class UserRepositoryPreferences implements Serializable {
private static final long serialVersionUID = 1L;
public String username;
-
+
public String repositoryName;
-
+
public boolean starred;
-
+
@Override
public String toString() {
return username + ":" + repositoryName;
diff --git a/src/main/java/com/gitblit/utils/ActivityUtils.java b/src/main/java/com/gitblit/utils/ActivityUtils.java
index c4e95879..ddd7e371 100644
--- a/src/main/java/com/gitblit/utils/ActivityUtils.java
+++ b/src/main/java/com/gitblit/utils/ActivityUtils.java
@@ -45,16 +45,16 @@ import com.google.gson.reflect.TypeToken;
/**
* Utility class for building activity information from repositories.
- *
+ *
* @author James Moger
- *
+ *
*/
public class ActivityUtils {
/**
* Gets the recent activity from the repositories for the last daysBack days
* on the specified branch.
- *
+ *
* @param models
* the list of repositories to query
* @param daysBack
@@ -79,7 +79,7 @@ public class ActivityUtils {
df.setTimeZone(timezone);
Calendar cal = Calendar.getInstance();
cal.setTimeZone(timezone);
-
+
// aggregate author exclusions
Set<String> authorExclusions = new TreeSet<String>();
authorExclusions.addAll(GitBlit.getStrings(Keys.web.metricAuthorExclusions));
@@ -125,7 +125,7 @@ public class ActivityUtils {
// trim commits to maximum count
commits = commits.subList(0, model.maxActivityCommits);
}
- for (RepositoryCommit commit : commits) {
+ for (RepositoryCommit commit : commits) {
Date date = commit.getCommitDate();
String dateStr = df.format(date);
if (!activity.containsKey(dateStr)) {
@@ -142,7 +142,7 @@ public class ActivityUtils {
activity.get(dateStr).addCommit(commit);
}
}
-
+
// close the repository
repository.close();
}
@@ -155,7 +155,7 @@ public class ActivityUtils {
/**
* Returns the Gravatar profile, if available, for the specified email
* address.
- *
+ *
* @param emailaddress
* @return a Gravatar Profile
* @throws IOException
@@ -167,7 +167,7 @@ public class ActivityUtils {
/**
* Creates a Gravatar thumbnail url from the specified email address.
- *
+ *
* @param email
* address to query Gravatar
* @param width
@@ -183,10 +183,10 @@ public class ActivityUtils {
"https://www.gravatar.com/avatar/{0}?s={1,number,0}&d=identicon", emailHash, width);
return url;
}
-
+
/**
* Creates a Gravatar thumbnail url from the specified email address.
- *
+ *
* @param email
* address to query Gravatar
* @param width
@@ -206,7 +206,7 @@ public class ActivityUtils {
/**
* Returns the Gravatar profile, if available, for the specified hashcode.
* address.
- *
+ *
* @param hash
* the hash of the email address
* @return a Gravatar Profile
diff --git a/src/main/java/com/gitblit/utils/ArrayUtils.java b/src/main/java/com/gitblit/utils/ArrayUtils.java
index 65834673..8387ef73 100644
--- a/src/main/java/com/gitblit/utils/ArrayUtils.java
+++ b/src/main/java/com/gitblit/utils/ArrayUtils.java
@@ -22,9 +22,9 @@ import java.util.List;
/**
* Utility class for arrays and collections.
- *
+ *
* @author James Moger
- *
+ *
*/
public class ArrayUtils {
@@ -39,11 +39,11 @@ public class ArrayUtils {
public static boolean isEmpty(Object [] array) {
return array == null || array.length == 0;
}
-
+
public static boolean isEmpty(Collection<?> collection) {
return collection == null || collection.size() == 0;
}
-
+
public static String toString(Collection<?> collection) {
if (isEmpty(collection)) {
return "";
@@ -56,7 +56,7 @@ public class ArrayUtils {
sb.setLength(sb.length() - 2);
return sb.toString();
}
-
+
public static Collection<String> fromString(String value) {
if (StringUtils.isEmpty(value)) {
value = "";
diff --git a/src/main/java/com/gitblit/utils/Base64.java b/src/main/java/com/gitblit/utils/Base64.java
index 6fd2daf1..735cbc28 100644
--- a/src/main/java/com/gitblit/utils/Base64.java
+++ b/src/main/java/com/gitblit/utils/Base64.java
@@ -19,7 +19,7 @@ import java.util.Arrays;
* href="http://iharder.net/base64">http://iharder.net/base64</a> periodically
* to check for updates or to contribute improvements.
* </p>
- *
+ *
* @author Robert Harder
* @author rob@iharder.net
* @version 2.1, stripped to minimum feature set used by JGit.
@@ -89,7 +89,7 @@ public class Base64 {
* <var>destOffset</var> + 4 for the <var>destination</var> array. The
* actual number of significant bytes in your array is given by
* <var>numSigBytes</var>.
- *
+ *
* @param source
* the array to convert
* @param srcOffset
@@ -146,7 +146,7 @@ public class Base64 {
/**
* Encodes a byte array into Base64 notation.
- *
+ *
* @param source
* The data to convert
* @return encoded base64 representation of source.
@@ -157,7 +157,7 @@ public class Base64 {
/**
* Encodes a byte array into Base64 notation.
- *
+ *
* @param source
* The data to convert
* @param off
@@ -199,7 +199,7 @@ public class Base64 {
* <var>destOffset</var> + 3 for the <var>destination</var> array. This
* method returns the actual number of bytes that were converted from the
* Base64 encoding.
- *
+ *
* @param source
* the array to convert
* @param srcOffset
@@ -246,7 +246,7 @@ public class Base64 {
/**
* Low-level decoding ASCII characters from a byte array.
- *
+ *
* @param source
* The Base64 encoded data
* @param off
@@ -294,7 +294,7 @@ public class Base64 {
/**
* Decodes data from Base64 notation.
- *
+ *
* @param s
* the string to decode
* @return the decoded data
diff --git a/src/main/java/com/gitblit/utils/ByteFormat.java b/src/main/java/com/gitblit/utils/ByteFormat.java
index cb7da885..d11ce9dc 100644
--- a/src/main/java/com/gitblit/utils/ByteFormat.java
+++ b/src/main/java/com/gitblit/utils/ByteFormat.java
@@ -23,9 +23,9 @@ import java.text.ParsePosition;
/**
* ByteFormat is a formatter which takes numbers and returns filesizes in bytes,
* kilobytes, megabytes, or gigabytes.
- *
+ *
* @author James Moger
- *
+ *
*/
public class ByteFormat extends Format {
@@ -38,6 +38,7 @@ public class ByteFormat extends Format {
return format(Long.valueOf(value));
}
+ @Override
public StringBuffer format(Object obj, StringBuffer buf, FieldPosition pos) {
if (obj instanceof Number) {
long numBytes = ((Number) obj).longValue();
@@ -46,19 +47,20 @@ public class ByteFormat extends Format {
buf.append(formatter.format((double) numBytes)).append(" b");
} else if (numBytes < 1024 * 1024) {
DecimalFormat formatter = new DecimalFormat("#,##0");
- buf.append(formatter.format((double) numBytes / 1024.0)).append(" KB");
+ buf.append(formatter.format(numBytes / 1024.0)).append(" KB");
} else if (numBytes < 1024 * 1024 * 1024) {
DecimalFormat formatter = new DecimalFormat("#,##0.0");
- buf.append(formatter.format((double) numBytes / (1024.0 * 1024.0))).append(" MB");
+ buf.append(formatter.format(numBytes / (1024.0 * 1024.0))).append(" MB");
} else {
DecimalFormat formatter = new DecimalFormat("#,##0.0");
- buf.append(formatter.format((double) numBytes / (1024.0 * 1024.0 * 1024.0)))
+ buf.append(formatter.format(numBytes / (1024.0 * 1024.0 * 1024.0)))
.append(" GB");
}
}
return buf;
}
+ @Override
public Object parseObject(String source, ParsePosition pos) {
return null;
}
diff --git a/src/main/java/com/gitblit/utils/ClientLogger.java b/src/main/java/com/gitblit/utils/ClientLogger.java
index 7d18f3d6..3570cbe9 100644
--- a/src/main/java/com/gitblit/utils/ClientLogger.java
+++ b/src/main/java/com/gitblit/utils/ClientLogger.java
@@ -26,9 +26,9 @@ import org.slf4j.LoggerFactory;
/**
* Class to log messages to the pushing Git client. Intended to be used by the
* Groovy Hooks.
- *
+ *
* @author John Crygier
- *
+ *
*/
public class ClientLogger {
@@ -41,7 +41,7 @@ public class ClientLogger {
/**
* Sends an info/warning message to the git client.
- *
+ *
* @param message
*/
public void info(String message) {
@@ -50,7 +50,7 @@ public class ClientLogger {
/**
* Sends an error message to the git client.
- *
+ *
* @param message
*/
public void error(String message) {
@@ -59,7 +59,7 @@ public class ClientLogger {
/**
* Sends an error message to the git client with an exception.
- *
+ *
* @param message
* @param t
* an exception
diff --git a/src/main/java/com/gitblit/utils/CommitCache.java b/src/main/java/com/gitblit/utils/CommitCache.java
index e84506ea..fd3a6597 100644
--- a/src/main/java/com/gitblit/utils/CommitCache.java
+++ b/src/main/java/com/gitblit/utils/CommitCache.java
@@ -35,36 +35,36 @@ import com.gitblit.models.RepositoryCommit;
/**
* Caches repository commits for re-use in the dashboard and activity pages.
- *
+ *
* @author James Moger
*
*/
public class CommitCache {
-
+
private static final CommitCache instance;
-
+
protected final Logger logger = LoggerFactory.getLogger(getClass());
-
+
protected final Map<String, ObjectCache<List<RepositoryCommit>>> cache;
-
+
protected int cacheDays = -1;
-
+
public static CommitCache instance() {
return instance;
}
-
+
static {
instance = new CommitCache();
}
-
+
protected CommitCache() {
cache = new ConcurrentHashMap<String, ObjectCache<List<RepositoryCommit>>>();
}
-
+
/**
* Returns the cutoff date for the cache. Commits after this date are cached.
* Commits before this date are not cached.
- *
+ *
* @return
*/
public Date getCutoffDate() {
@@ -77,28 +77,28 @@ public class CommitCache {
cal.add(Calendar.DATE, -1*cacheDays);
return cal.getTime();
}
-
+
/**
* Sets the number of days to cache.
- *
+ *
* @param days
*/
public synchronized void setCacheDays(int days) {
this.cacheDays = days;
clear();
}
-
+
/**
* Clears the entire commit cache.
- *
+ *
*/
public void clear() {
cache.clear();
}
-
+
/**
* Clears the commit cache for a specific repository.
- *
+ *
* @param repositoryName
*/
public void clear(String repositoryName) {
@@ -108,10 +108,10 @@ public class CommitCache {
logger.info(MessageFormat.format("{0} commit cache cleared", repositoryName));
}
}
-
+
/**
* Clears the commit cache for a specific branch of a specific repository.
- *
+ *
* @param repositoryName
* @param branch
*/
@@ -125,10 +125,10 @@ public class CommitCache {
}
}
}
-
+
/**
* Get all commits for the specified repository:branch that are in the cache.
- *
+ *
* @param repositoryName
* @param repository
* @param branch
@@ -137,12 +137,12 @@ public class CommitCache {
public List<RepositoryCommit> getCommits(String repositoryName, Repository repository, String branch) {
return getCommits(repositoryName, repository, branch, getCutoffDate());
}
-
+
/**
* Get all commits for the specified repository:branch since a specific date.
* These commits may be retrieved from the cache if the sinceDate is after
* the cacheCutoffDate.
- *
+ *
* @param repositoryName
* @param repository
* @param branch
@@ -159,13 +159,13 @@ public class CommitCache {
if (!cache.containsKey(repoKey)) {
cache.put(repoKey, new ObjectCache<List<RepositoryCommit>>());
}
-
+
ObjectCache<List<RepositoryCommit>> repoCache = cache.get(repoKey);
String branchKey = branch.toLowerCase();
-
+
RevCommit tip = JGitUtils.getCommit(repository, branch);
Date tipDate = JGitUtils.getCommitDate(tip);
-
+
List<RepositoryCommit> commits;
if (!repoCache.hasCurrent(branchKey, tipDate)) {
commits = repoCache.getObject(branchKey);
@@ -193,7 +193,7 @@ public class CommitCache {
// update cache
repoCache.updateObject(branchKey, tipDate, commits);
}
-
+
if (sinceDate.equals(cacheCutoffDate)) {
list = commits;
} else {
@@ -210,10 +210,10 @@ public class CommitCache {
}
return list;
}
-
+
/**
- * Returns a list of commits for the specified repository branch.
- *
+ * Returns a list of commits for the specified repository branch.
+ *
* @param repositoryName
* @param repository
* @param branch
@@ -230,10 +230,10 @@ public class CommitCache {
}
return commits;
}
-
+
/**
- * Returns a list of commits for the specified repository branch since the specified commit.
- *
+ * Returns a list of commits for the specified repository branch since the specified commit.
+ *
* @param repositoryName
* @param repository
* @param branch
@@ -250,10 +250,10 @@ public class CommitCache {
}
return commits;
}
-
+
/**
* Reduces the list of commits to those since the specified date.
- *
+ *
* @param commits
* @param sinceDate
* @return a list of commits
diff --git a/src/main/java/com/gitblit/utils/CompressionUtils.java b/src/main/java/com/gitblit/utils/CompressionUtils.java
index a8dcdd8f..2bf1f130 100644
--- a/src/main/java/com/gitblit/utils/CompressionUtils.java
+++ b/src/main/java/com/gitblit/utils/CompressionUtils.java
@@ -43,9 +43,9 @@ import org.slf4j.LoggerFactory;
/**
* Collection of static methods for retrieving information from a repository.
- *
+ *
* @author James Moger
- *
+ *
*/
public class CompressionUtils {
@@ -53,7 +53,7 @@ public class CompressionUtils {
/**
* Log an error message and exception.
- *
+ *
* @param t
* @param repository
* if repository is not null it MUST be the {0} parameter in the
@@ -77,7 +77,7 @@ public class CompressionUtils {
/**
* Zips the contents of the tree at the (optionally) specified revision and
* the (optionally) specified basepath to the supplied outputstream.
- *
+ *
* @param repository
* @param basePath
* if unspecified, entire repository is assumed.
@@ -137,11 +137,11 @@ public class CompressionUtils {
}
return success;
}
-
+
/**
* tar the contents of the tree at the (optionally) specified revision and
* the (optionally) specified basepath to the supplied outputstream.
- *
+ *
* @param repository
* @param basePath
* if unspecified, entire repository is assumed.
@@ -155,11 +155,11 @@ public class CompressionUtils {
OutputStream os) {
return tar(null, repository, basePath, objectId, os);
}
-
+
/**
* tar.gz the contents of the tree at the (optionally) specified revision and
* the (optionally) specified basepath to the supplied outputstream.
- *
+ *
* @param repository
* @param basePath
* if unspecified, entire repository is assumed.
@@ -173,11 +173,11 @@ public class CompressionUtils {
OutputStream os) {
return tar(CompressorStreamFactory.GZIP, repository, basePath, objectId, os);
}
-
+
/**
* tar.xz the contents of the tree at the (optionally) specified revision and
* the (optionally) specified basepath to the supplied outputstream.
- *
+ *
* @param repository
* @param basePath
* if unspecified, entire repository is assumed.
@@ -191,11 +191,11 @@ public class CompressionUtils {
OutputStream os) {
return tar(CompressorStreamFactory.XZ, repository, basePath, objectId, os);
}
-
+
/**
* tar.bzip2 the contents of the tree at the (optionally) specified revision and
* the (optionally) specified basepath to the supplied outputstream.
- *
+ *
* @param repository
* @param basePath
* if unspecified, entire repository is assumed.
@@ -207,15 +207,15 @@ public class CompressionUtils {
*/
public static boolean bzip2(Repository repository, String basePath, String objectId,
OutputStream os) {
-
+
return tar(CompressorStreamFactory.BZIP2, repository, basePath, objectId, os);
}
-
+
/**
* Compresses/archives the contents of the tree at the (optionally)
* specified revision and the (optionally) specified basepath to the
* supplied outputstream.
- *
+ *
* @param algorithm
* compression algorithm for tar (optional)
* @param repository
@@ -233,7 +233,7 @@ public class CompressionUtils {
if (commit == null) {
return false;
}
-
+
OutputStream cos = os;
if (!StringUtils.isEmpty(algorithm)) {
try {
@@ -264,7 +264,7 @@ public class CompressionUtils {
continue;
}
tw.getObjectId(id, 0);
-
+
ObjectLoader loader = repository.open(id);
if (FileMode.SYMLINK == mode) {
TarArchiveEntry entry = new TarArchiveEntry(tw.getPathString(),TarArchiveEntry.LF_SYMLINK);
@@ -279,7 +279,7 @@ public class CompressionUtils {
entry.setMode(mode.getBits());
entry.setModTime(modified);
entry.setSize(loader.getSize());
- tos.putArchiveEntry(entry);
+ tos.putArchiveEntry(entry);
loader.copyTo(tos);
tos.closeArchiveEntry();
}
diff --git a/src/main/java/com/gitblit/utils/ConnectionUtils.java b/src/main/java/com/gitblit/utils/ConnectionUtils.java
index feeedd21..b2bd0601 100644
--- a/src/main/java/com/gitblit/utils/ConnectionUtils.java
+++ b/src/main/java/com/gitblit/utils/ConnectionUtils.java
@@ -38,9 +38,9 @@ import javax.net.ssl.X509TrustManager;
/**
* Utility class for establishing HTTP/HTTPS connections.
- *
+ *
* @author James Moger
- *
+ *
*/
public class ConnectionUtils {
@@ -61,7 +61,7 @@ public class ConnectionUtils {
SSL_CONTEXT = context;
HOSTNAME_VERIFIER = new DummyHostnameVerifier();
CHARSET = "UTF-8";
-
+
// Disable Java 7 SNI checks
// http://stackoverflow.com/questions/7615645/ssl-handshake-alert-unrecognized-name-error-since-upgrade-to-java-1-7-0
System.setProperty("jsse.enableSNIExtension", "false");
@@ -97,7 +97,7 @@ public class ConnectionUtils {
}
return conn;
}
-
+
// Copyright (C) 2009 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -183,7 +183,7 @@ public class ConnectionUtils {
/**
* DummyTrustManager trusts all certificates.
- *
+ *
* @author James Moger
*/
private static class DummyTrustManager implements X509TrustManager {
@@ -206,7 +206,7 @@ public class ConnectionUtils {
/**
* Trusts all hostnames from a certificate, including self-signed certs.
- *
+ *
* @author James Moger
*/
private static class DummyHostnameVerifier implements HostnameVerifier {
diff --git a/src/main/java/com/gitblit/utils/ContainerUtils.java b/src/main/java/com/gitblit/utils/ContainerUtils.java
index 919f99d6..613bf97a 100644
--- a/src/main/java/com/gitblit/utils/ContainerUtils.java
+++ b/src/main/java/com/gitblit/utils/ContainerUtils.java
@@ -27,7 +27,7 @@ import com.gitblit.Keys;
/**
* This is the support class for all container specific code.
- *
+ *
* @author jpyeron
*/
public class ContainerUtils
@@ -37,7 +37,7 @@ public class ContainerUtils
/**
* The support class for managing and evaluating the environment with
* regards to CVE-2007-0405.
- *
+ *
* @see http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2007-0450
* @author jpyeron
*/
@@ -80,7 +80,7 @@ public class ContainerUtils
* blocked from use in certain URL s. It will emit a warning to the
* logger if the configuration of Tomcat causes the URL processing to
* fail on %2F.
- *
+ *
* @return true if it recognizes Tomcat, false if it does not recognize
* Tomcat
*/
@@ -96,7 +96,7 @@ public class ContainerUtils
// mb.setBytes(test, 0, test.length);
Method mByteChunck_setBytes = cByteChunk.getMethod("setBytes", byte[].class, int.class, int.class);
- mByteChunck_setBytes.invoke(mb, test, (int) 0, test.length);
+ mByteChunck_setBytes.invoke(mb, test, 0, test.length);
// UDecoder ud=new UDecoder();
Class<?> cUDecoder = Class.forName("org.apache.tomcat.util.buf.UDecoder");
diff --git a/src/main/java/com/gitblit/utils/DeepCopier.java b/src/main/java/com/gitblit/utils/DeepCopier.java
index 5df30623..5d89606c 100644
--- a/src/main/java/com/gitblit/utils/DeepCopier.java
+++ b/src/main/java/com/gitblit/utils/DeepCopier.java
@@ -57,7 +57,7 @@ public class DeepCopier {
* very large objects. The current thread is used for serializing the
* original object in order to respect any synchronization the caller may
* have around it, and a new thread is used for deserializing the copy.
- *
+ *
*/
public static <T> T copyParallel(T original) {
try {
@@ -88,6 +88,7 @@ public class DeepCopier {
start();
}
+ @Override
@SuppressWarnings("unchecked")
public void run() {
diff --git a/src/main/java/com/gitblit/utils/DiffUtils.java b/src/main/java/com/gitblit/utils/DiffUtils.java
index 3c52cb03..107f6ab3 100644
--- a/src/main/java/com/gitblit/utils/DiffUtils.java
+++ b/src/main/java/com/gitblit/utils/DiffUtils.java
@@ -66,23 +66,23 @@ public class DiffUtils {
return null;
}
}
-
+
/**
- * Encapsulates the output of a diff.
+ * Encapsulates the output of a diff.
*/
public static class DiffOutput implements Serializable {
private static final long serialVersionUID = 1L;
-
+
public final DiffOutputType type;
public final String content;
public final DiffStat stat;
-
+
DiffOutput(DiffOutputType type, String content, DiffStat stat) {
this.type = type;
this.content = content;
this.stat = stat;
}
-
+
public PathChangeModel getPath(String path) {
if (stat == null) {
return null;
@@ -98,15 +98,15 @@ public class DiffUtils {
public static class DiffStat implements Serializable {
private static final long serialVersionUID = 1L;
-
+
public final List<PathChangeModel> paths = new ArrayList<PathChangeModel>();
-
+
private final String commitId;
-
+
public DiffStat(String commitId) {
this.commitId = commitId;
}
-
+
public PathChangeModel addPath(DiffEntry entry) {
PathChangeModel pcm = PathChangeModel.from(entry, commitId);
paths.add(pcm);
@@ -128,7 +128,7 @@ public class DiffUtils {
}
return val;
}
-
+
public PathChangeModel getPath(String path) {
PathChangeModel stat = null;
for (PathChangeModel p : paths) {
@@ -138,7 +138,7 @@ public class DiffUtils {
}
}
return stat;
- }
+ }
@Override
public String toString() {
@@ -150,15 +150,15 @@ public class DiffUtils {
return sb.toString();
}
}
-
+
public static class NormalizedDiffStat implements Serializable {
-
+
private static final long serialVersionUID = 1L;
-
+
public final int insertions;
public final int deletions;
public final int blanks;
-
+
NormalizedDiffStat(int insertions, int deletions, int blanks) {
this.insertions = insertions;
this.deletions = deletions;
@@ -282,7 +282,7 @@ public class DiffUtils {
} catch (Throwable t) {
LOGGER.error("failed to generate commit diff!", t);
}
-
+
return new DiffOutput(outputType, diff, stat);
}
@@ -442,10 +442,10 @@ public class DiffUtils {
}
return lines;
}
-
+
/**
* Normalizes a diffstat to an N-segment display.
- *
+ *
* @params segments
* @param insertions
* @param deletions
@@ -482,7 +482,7 @@ public class DiffUtils {
sd = segments - si;
sb = 0;
}
-
+
return new NormalizedDiffStat(si, sd, sb);
}
}
diff --git a/src/main/java/com/gitblit/utils/FederationUtils.java b/src/main/java/com/gitblit/utils/FederationUtils.java
index 4d6060dd..e1a3d008 100644
--- a/src/main/java/com/gitblit/utils/FederationUtils.java
+++ b/src/main/java/com/gitblit/utils/FederationUtils.java
@@ -44,9 +44,9 @@ import com.google.gson.reflect.TypeToken;
/**
* Utility methods for federation functions.
- *
+ *
* @author James Moger
- *
+ *
*/
public class FederationUtils {
@@ -66,7 +66,7 @@ public class FederationUtils {
/**
* Returns an url to this servlet for the specified parameters.
- *
+ *
* @param sourceURL
* the url of the source gitblit instance
* @param token
@@ -79,7 +79,7 @@ public class FederationUtils {
}
/**
- *
+ *
* @param remoteURL
* the url of the remote gitblit instance
* @param tokenType
@@ -109,7 +109,7 @@ public class FederationUtils {
/**
* Returns the list of federated gitblit instances that this instance will
* try to pull.
- *
+ *
* @return list of registered gitblit instances
*/
public static List<FederationModel> getFederationRegistrations(IStoredSettings settings) {
@@ -194,7 +194,7 @@ public class FederationUtils {
* sent by an pulling Gitblit instance to an origin Gitblit instance as part
* of the proposal process. This is to ensure that the pulling Gitblit
* instance has an IP route to the origin instance.
- *
+ *
* @param remoteUrl
* the remote Gitblit instance to send a federation proposal to
* @param proposal
@@ -210,7 +210,7 @@ public class FederationUtils {
/**
* Sends a federation proposal to the Gitblit instance at remoteUrl
- *
+ *
* @param remoteUrl
* the remote Gitblit instance to send a federation proposal to
* @param proposal
@@ -246,7 +246,7 @@ public class FederationUtils {
/**
* Retrieves a map of the repositories at the remote gitblit instance keyed
* by the repository clone url.
- *
+ *
* @param registration
* @param checkExclusions
* should returned repositories remove registration exclusions
@@ -272,7 +272,7 @@ public class FederationUtils {
/**
* Tries to pull the gitblit user accounts from the remote gitblit instance.
- *
+ *
* @param registration
* @return a collection of UserModel objects
* @throws Exception
@@ -287,7 +287,7 @@ public class FederationUtils {
/**
* Tries to pull the gitblit team definitions from the remote gitblit
* instance.
- *
+ *
* @param registration
* @return a collection of TeamModel objects
* @throws Exception
@@ -302,7 +302,7 @@ public class FederationUtils {
/**
* Tries to pull the gitblit server settings from the remote gitblit
* instance.
- *
+ *
* @param registration
* @return a map of the remote gitblit settings
* @throws Exception
@@ -315,7 +315,7 @@ public class FederationUtils {
/**
* Tries to pull the referenced scripts from the remote gitblit instance.
- *
+ *
* @param registration
* @return a map of the remote gitblit scripts by script name
* @throws Exception
@@ -328,7 +328,7 @@ public class FederationUtils {
/**
* Send an status acknowledgment to the remote Gitblit server.
- *
+ *
* @param identification
* identification of this pulling instance
* @param registration
diff --git a/src/main/java/com/gitblit/utils/FileUtils.java b/src/main/java/com/gitblit/utils/FileUtils.java
index f3a25987..a1eb5bba 100644
--- a/src/main/java/com/gitblit/utils/FileUtils.java
+++ b/src/main/java/com/gitblit/utils/FileUtils.java
@@ -29,12 +29,12 @@ import java.nio.charset.Charset;
/**
* Common file utilities.
- *
+ *
* @author James Moger
- *
+ *
*/
public class FileUtils {
-
+
/** 1024 (number of bytes in one kilobyte) */
public static final int KB = 1024;
@@ -47,7 +47,7 @@ public class FileUtils {
/**
* Returns an int from a string representation of a file size.
* e.g. 50m = 50 megabytes
- *
+ *
* @param aString
* @param defaultValue
* @return an int value or the defaultValue if aString can not be parsed
@@ -55,24 +55,24 @@ public class FileUtils {
public static int convertSizeToInt(String aString, int defaultValue) {
return (int) convertSizeToLong(aString, defaultValue);
}
-
+
/**
* Returns a long from a string representation of a file size.
* e.g. 50m = 50 megabytes
- *
+ *
* @param aString
* @param defaultValue
* @return a long value or the defaultValue if aString can not be parsed
*/
public static long convertSizeToLong(String aString, long defaultValue) {
- // trim string and remove all spaces
+ // trim string and remove all spaces
aString = aString.toLowerCase().trim();
StringBuilder sb = new StringBuilder();
for (String a : aString.split(" ")) {
sb.append(a);
}
aString = sb.toString();
-
+
// identify value and unit
int idx = 0;
int len = aString.length();
@@ -99,10 +99,10 @@ public class FileUtils {
}
return defaultValue;
}
-
+
/**
* Returns the byte [] content of the specified file.
- *
+ *
* @param file
* @return the byte content of the file
*/
@@ -130,7 +130,7 @@ public class FileUtils {
/**
* Returns the string content of the specified file.
- *
+ *
* @param file
* @param lineEnding
* @return the string content of the file
@@ -166,7 +166,7 @@ public class FileUtils {
/**
* Writes the string content to the file.
- *
+ *
* @param file
* @param content
*/
@@ -195,14 +195,14 @@ public class FileUtils {
/**
* Recursively traverses a folder and its subfolders to calculate the total
* size in bytes.
- *
+ *
* @param directory
* @return folder size in bytes
*/
public static long folderSize(File directory) {
if (directory == null || !directory.exists()) {
return -1;
- }
+ }
if (directory.isDirectory()) {
long length = 0;
for (File file : directory.listFiles()) {
@@ -241,7 +241,7 @@ public class FileUtils {
/**
* Copies a file or folder (recursively) to a destination folder.
- *
+ *
* @param destinationFolder
* @param filesOrFolders
* @return
@@ -281,11 +281,11 @@ public class FileUtils {
}
}
}
-
+
/**
* Determine the relative path between two files. Takes into account
* canonical paths, if possible.
- *
+ *
* @param basePath
* @param path
* @return a relative path from basePath to path
@@ -309,11 +309,11 @@ public class FileUtils {
// no relative relationship
return null;
}
-
+
/**
* Returns the exact path for a file. This path will be the canonical path
* unless an exception is thrown in which case it will be the absolute path.
- *
+ *
* @param path
* @return the exact file
*/
@@ -327,7 +327,7 @@ public class FileUtils {
public static File resolveParameter(String parameter, File aFolder, String path) {
if (aFolder == null) {
- // strip any parameter reference
+ // strip any parameter reference
path = path.replace(parameter, "").trim();
if (path.length() > 0 && path.charAt(0) == '/') {
// strip leading /
diff --git a/src/main/java/com/gitblit/utils/GitBlitDiffFormatter.java b/src/main/java/com/gitblit/utils/GitBlitDiffFormatter.java
index 8ca42854..47ff143a 100644
--- a/src/main/java/com/gitblit/utils/GitBlitDiffFormatter.java
+++ b/src/main/java/com/gitblit/utils/GitBlitDiffFormatter.java
@@ -34,9 +34,9 @@ import com.gitblit.utils.DiffUtils.DiffStat;
/**
* Generates an html snippet of a diff in Gitblit's style, tracks changed paths,
* and calculates diff stats.
- *
+ *
* @author James Moger
- *
+ *
*/
public class GitBlitDiffFormatter extends DiffFormatter {
@@ -47,22 +47,22 @@ public class GitBlitDiffFormatter extends DiffFormatter {
private PathChangeModel currentPath;
private int left, right;
-
+
public GitBlitDiffFormatter(OutputStream os, String commitId) {
super(os);
this.os = os;
this.diffStat = new DiffStat(commitId);
}
-
+
@Override
public void format(DiffEntry ent) throws IOException {
currentPath = diffStat.addPath(ent);
super.format(ent);
}
-
+
/**
* Output a hunk header
- *
+ *
* @param aStartLine
* within first source
* @param aEndLine
@@ -88,7 +88,7 @@ public class GitBlitDiffFormatter extends DiffFormatter {
left = aStartLine + 1;
right = bStartLine + 1;
}
-
+
protected void writeRange(final char prefix, final int begin, final int cnt) throws IOException {
os.write(' ');
os.write(prefix);
@@ -127,7 +127,7 @@ public class GitBlitDiffFormatter extends DiffFormatter {
throws IOException {
// update entry diffstat
currentPath.update(prefix);
-
+
// output diff
os.write("<tr>".getBytes());
switch (prefix) {
@@ -162,7 +162,7 @@ public class GitBlitDiffFormatter extends DiffFormatter {
/**
* Workaround function for complex private methods in DiffFormatter. This
* sets the html for the diff headers.
- *
+ *
* @return
*/
public String getHtml() {
@@ -191,10 +191,10 @@ public class GitBlitDiffFormatter extends DiffFormatter {
} else {
// use a
line = line.substring("diff --git ".length()).trim();
- line = line.substring(line.startsWith("\"a/") ? 3 : 2);
+ line = line.substring(line.startsWith("\"a/") ? 3 : 2);
line = line.substring(0, line.indexOf(" b/") > -1 ? line.indexOf(" b/") : line.indexOf("\"b/")).trim();
}
-
+
if (line.charAt(0) == '"') {
line = line.substring(1);
}
@@ -205,7 +205,7 @@ public class GitBlitDiffFormatter extends DiffFormatter {
sb.append("</tbody></table></div>\n");
inFile = false;
}
-
+
sb.append(MessageFormat.format("<div class='header'><div class=\"diffHeader\" id=\"{0}\"><i class=\"icon-file\"></i> ", line)).append(line).append("</div></div>");
sb.append("<div class=\"diff\">");
sb.append("<table><tbody>");
@@ -229,7 +229,7 @@ public class GitBlitDiffFormatter extends DiffFormatter {
sb.append("</table></div>");
return sb.toString();
}
-
+
public DiffStat getDiffStat() {
return diffStat;
}
diff --git a/src/main/java/com/gitblit/utils/HttpUtils.java b/src/main/java/com/gitblit/utils/HttpUtils.java
index 86f53cfe..ffea81cd 100644
--- a/src/main/java/com/gitblit/utils/HttpUtils.java
+++ b/src/main/java/com/gitblit/utils/HttpUtils.java
@@ -30,15 +30,15 @@ import com.gitblit.utils.X509Utils.X509Metadata;
/**
* Collection of utility methods for http requests.
- *
+ *
* @author James Moger
- *
+ *
*/
public class HttpUtils {
/**
* Returns the Gitblit URL based on the request.
- *
+ *
* @param request
* @return the host url
*/
@@ -59,7 +59,7 @@ public class HttpUtils {
} catch (Throwable t) {
}
}
-
+
// try to use reverse-proxy server's scheme
String forwardedScheme = request.getHeader("X-Forwarded-Proto");
if (StringUtils.isEmpty(forwardedScheme)) {
@@ -68,7 +68,7 @@ public class HttpUtils {
if (!StringUtils.isEmpty(forwardedScheme)) {
// reverse-proxy server has supplied the original scheme
scheme = forwardedScheme;
-
+
if ("https".equals(scheme) && port == 80) {
// proxy server is https, inside server is 80
// this is likely because the proxy server has not supplied
@@ -77,7 +77,7 @@ public class HttpUtils {
port = 443;
}
}
-
+
String context = request.getContextPath();
String forwardedContext = request.getHeader("X-Forwarded-Context");
if (forwardedContext != null) {
@@ -86,12 +86,12 @@ public class HttpUtils {
if (!StringUtils.isEmpty(forwardedContext)) {
context = forwardedContext;
}
-
+
// trim any trailing slash
if (context.length() > 0 && context.charAt(context.length() - 1) == '/') {
context = context.substring(1);
}
-
+
StringBuilder sb = new StringBuilder();
sb.append(scheme);
sb.append("://");
@@ -103,11 +103,11 @@ public class HttpUtils {
sb.append(context);
return sb.toString();
}
-
+
/**
* Returns a user model object built from attributes in the SSL certificate.
* This model is not retrieved from the user service.
- *
+ *
* @param httpRequest
* @param checkValidity ensure certificate can be used now
* @param usernameOIDs if unspecified, CN is used as the username
@@ -136,7 +136,7 @@ public class HttpUtils {
}
return null;
}
-
+
/**
* Creates a UserModel from a certificate
* @param cert
@@ -145,16 +145,16 @@ public class HttpUtils {
*/
public static UserModel getUserModelFromCertificate(X509Certificate cert, String... usernameOIDs) {
X509Metadata metadata = X509Utils.getMetadata(cert);
-
+
UserModel user = new UserModel(metadata.commonName);
user.emailAddress = metadata.emailAddress;
user.isAuthenticated = false;
-
+
if (usernameOIDs == null || usernameOIDs.length == 0) {
// use default usename<->CN mapping
usernameOIDs = new String [] { "CN" };
}
-
+
// determine username from OID fingerprint
StringBuilder an = new StringBuilder();
for (String oid : usernameOIDs) {
@@ -163,10 +163,10 @@ public class HttpUtils {
an.append(val).append(' ');
}
}
- user.username = an.toString().trim();
+ user.username = an.toString().trim();
return user;
}
-
+
public static X509Metadata getCertificateMetadata(HttpServletRequest httpRequest) {
if (httpRequest.getAttribute("javax.servlet.request.X509Certificate") != null) {
X509Certificate[] certChain = (X509Certificate[]) httpRequest
@@ -178,7 +178,7 @@ public class HttpUtils {
}
return null;
}
-
+
public static boolean isIpAddress(String address) {
if (StringUtils.isEmpty(address)) {
return false;
diff --git a/src/main/java/com/gitblit/utils/JGitUtils.java b/src/main/java/com/gitblit/utils/JGitUtils.java
index c494ccc3..75a44058 100644
--- a/src/main/java/com/gitblit/utils/JGitUtils.java
+++ b/src/main/java/com/gitblit/utils/JGitUtils.java
@@ -92,9 +92,9 @@ import com.gitblit.models.SubmoduleModel;
/**
* Collection of static methods for retrieving information from a repository.
- *
+ *
* @author James Moger
- *
+ *
*/
public class JGitUtils {
@@ -102,7 +102,7 @@ public class JGitUtils {
/**
* Log an error message and exception.
- *
+ *
* @param t
* @param repository
* if repository is not null it MUST be the {0} parameter in the
@@ -126,7 +126,7 @@ public class JGitUtils {
/**
* Returns the displayable name of the person in the form "Real Name <email
* address>". If the email address is empty, just "Real Name" is returned.
- *
+ *
* @param person
* @return "Real Name <email address>" or "Real Name"
*/
@@ -155,7 +155,7 @@ public class JGitUtils {
* Clone or Fetch a repository. If the local repository does not exist,
* clone is called. If the repository does exist, fetch is called. By
* default the clone/fetch retrieves the remote heads, tags, and notes.
- *
+ *
* @param repositoriesFolder
* @param name
* @param fromUrl
@@ -171,7 +171,7 @@ public class JGitUtils {
* Clone or Fetch a repository. If the local repository does not exist,
* clone is called. If the repository does exist, fetch is called. By
* default the clone/fetch retrieves the remote heads, tags, and notes.
- *
+ *
* @param repositoriesFolder
* @param name
* @param fromUrl
@@ -212,7 +212,7 @@ public class JGitUtils {
clone.setCredentialsProvider(credentialsProvider);
}
Repository repository = clone.call().getRepository();
-
+
// Now we have to fetch because CloneCommand doesn't fetch
// refs/notes nor does it allow manual RefSpec.
result.createdRepository = true;
@@ -225,7 +225,7 @@ public class JGitUtils {
/**
* Fetch updates from the remote repository. If refSpecs is unspecifed,
* remote heads, tags, and notes are retrieved.
- *
+ *
* @param credentialsProvider
* @param repository
* @param refSpecs
@@ -254,7 +254,7 @@ public class JGitUtils {
/**
* Creates a bare repository.
- *
+ *
* @param repositoriesFolder
* @param name
* @return Repository
@@ -444,7 +444,7 @@ public class JGitUtils {
/**
* Returns a list of repository names in the specified folder.
- *
+ *
* @param repositoriesFolder
* @param onlyBare
* if true, only bare repositories repositories are listed. If
@@ -478,7 +478,7 @@ public class JGitUtils {
/**
* Recursive function to find git repositories.
- *
+ *
* @param basePath
* basePath is stripped from the repository name as repositories
* are relative to this path
@@ -501,7 +501,7 @@ public class JGitUtils {
if (depth == 0) {
return list;
}
-
+
int nextDepth = (depth == -1) ? -1 : depth - 1;
for (File file : searchFolder.listFiles()) {
if (file.isDirectory()) {
@@ -546,7 +546,7 @@ public class JGitUtils {
/**
* Returns the first commit on a branch. If the repository does not exist or
* is empty, null is returned.
- *
+ *
* @param repository
* @param branch
* if unspecified, HEAD is assumed.
@@ -582,7 +582,7 @@ public class JGitUtils {
* Returns the date of the first commit on a branch. If the repository does
* not exist, Date(0) is returned. If the repository does exist bit is
* empty, the last modified date of the repository folder is returned.
- *
+ *
* @param repository
* @param branch
* if unspecified, HEAD is assumed.
@@ -603,7 +603,7 @@ public class JGitUtils {
/**
* Determine if a repository has any commits. This is determined by checking
* the for loose and packed objects.
- *
+ *
* @param repository
* @return true if the repository has commits
*/
@@ -614,18 +614,18 @@ public class JGitUtils {
}
return false;
}
-
+
/**
* Encapsulates the result of cloning or pulling from a repository.
*/
public static class LastChange {
public Date when;
public String who;
-
+
LastChange() {
- when = new Date(0);
+ when = new Date(0);
}
-
+
LastChange(long lastModified) {
this.when = new Date(lastModified);
}
@@ -635,7 +635,7 @@ public class JGitUtils {
* Returns the date and author of the most recent commit on a branch. If the
* repository does not exist Date(0) is returned. If it does exist but is
* empty, the last modified date of the repository folder is returned.
- *
+ *
* @param repository
* @return a LastChange object
*/
@@ -652,7 +652,7 @@ public class JGitUtils {
List<RefModel> branchModels = getLocalBranches(repository, true, -1);
if (branchModels.size() > 0) {
// find most recent branch update
- LastChange lastChange = new LastChange();
+ LastChange lastChange = new LastChange();
for (RefModel branchModel : branchModels) {
if (branchModel.getDate().after(lastChange.when)) {
lastChange.when = branchModel.getDate();
@@ -661,14 +661,14 @@ public class JGitUtils {
}
return lastChange;
}
-
+
// default to the repository folder modification date
return new LastChange(repository.getDirectory().lastModified());
}
/**
* Retrieves a Java Date from a Git commit.
- *
+ *
* @param commit
* @return date of the commit or Date(0) if the commit is null
*/
@@ -681,7 +681,7 @@ public class JGitUtils {
/**
* Retrieves a Java Date from a Git commit.
- *
+ *
* @param commit
* @return date of the commit or Date(0) if the commit is null
*/
@@ -695,7 +695,7 @@ public class JGitUtils {
/**
* Returns the specified commit from the repository. If the repository does
* not exist or is empty, null is returned.
- *
+ *
* @param repository
* @param objectId
* if unspecified, HEAD is assumed.
@@ -726,7 +726,7 @@ public class JGitUtils {
/**
* Retrieves the raw byte content of a file in the specified tree.
- *
+ *
* @param repository
* @param tree
* if null, the RevTree from HEAD is assumed.
@@ -782,7 +782,7 @@ public class JGitUtils {
/**
* Returns the UTF-8 string content of a file in the specified tree.
- *
+ *
* @param repository
* @param tree
* if null, the RevTree from HEAD is assumed.
@@ -800,7 +800,7 @@ public class JGitUtils {
/**
* Gets the raw byte content of the specified blob object.
- *
+ *
* @param repository
* @param objectId
* @return byte [] blob content
@@ -831,7 +831,7 @@ public class JGitUtils {
/**
* Gets the UTF-8 string content of the blob specified by objectId.
- *
+ *
* @param repository
* @param objectId
* @param charsets optional
@@ -849,7 +849,7 @@ public class JGitUtils {
* Returns the list of files in the specified folder at the specified
* commit. If the repository does not exist or is empty, an empty list is
* returned.
- *
+ *
* @param repository
* @param path
* if unspecified, root folder is assumed.
@@ -900,11 +900,11 @@ public class JGitUtils {
Collections.sort(list);
return list;
}
-
+
/**
* Returns the list of files changed in a specified commit. If the
* repository does not exist or is empty, an empty list is returned.
- *
+ *
* @param repository
* @param commit
* if null, HEAD is assumed.
@@ -917,7 +917,7 @@ public class JGitUtils {
/**
* Returns the list of files changed in a specified commit. If the
* repository does not exist or is empty, an empty list is returned.
- *
+ *
* @param repository
* @param commit
* if null, HEAD is assumed.
@@ -958,7 +958,7 @@ public class JGitUtils {
for (DiffEntry diff : diffs) {
// create the path change model
PathChangeModel pcm = PathChangeModel.from(diff, commit.getName());
-
+
if (calculateDiffStat) {
// update file diffstats
df.format(diff);
@@ -982,7 +982,7 @@ public class JGitUtils {
/**
* Returns the list of files changed in a specified commit. If the
* repository does not exist or is empty, an empty list is returned.
- *
+ *
* @param repository
* @param startCommit
* earliest commit
@@ -1005,7 +1005,7 @@ public class JGitUtils {
for (DiffEntry diff : diffEntries) {
PathChangeModel pcm = PathChangeModel.from(diff, null);
list.add(pcm);
- }
+ }
Collections.sort(list);
} catch (Throwable t) {
error(t, repository, "{0} failed to determine files in range {1}..{2}!", startCommit, endCommit);
@@ -1016,7 +1016,7 @@ public class JGitUtils {
* Returns the list of files in the repository on the default branch that
* match one of the specified extensions. This is a CASE-SENSITIVE search.
* If the repository does not exist or is empty, an empty list is returned.
- *
+ *
* @param repository
* @param extensions
* @return list of files in repository with a matching extension
@@ -1029,7 +1029,7 @@ public class JGitUtils {
* Returns the list of files in the repository in the specified commit that
* match one of the specified extensions. This is a CASE-SENSITIVE search.
* If the repository does not exist or is empty, an empty list is returned.
- *
+ *
* @param repository
* @param extensions
* @param objectId
@@ -1078,7 +1078,7 @@ public class JGitUtils {
/**
* Returns a path model of the current file in the treewalk.
- *
+ *
* @param tw
* @param basePath
* @param commit
@@ -1106,7 +1106,7 @@ public class JGitUtils {
/**
* Returns a permissions representation of the mode bits.
- *
+ *
* @param mode
* @return string representation of the mode bits
*/
@@ -1128,7 +1128,7 @@ public class JGitUtils {
/**
* Returns a list of commits since the minimum date starting from the
* specified object id.
- *
+ *
* @param repository
* @param objectId
* if unspecified, HEAD is assumed.
@@ -1166,7 +1166,7 @@ public class JGitUtils {
/**
* Returns a list of commits starting from HEAD and working backwards.
- *
+ *
* @param repository
* @param maxCount
* if < 0, all commits for the repository are returned.
@@ -1181,7 +1181,7 @@ public class JGitUtils {
* offset and maxCount for paging. This is similar to LIMIT n OFFSET p in
* SQL. If the repository does not exist or is empty, an empty list is
* returned.
- *
+ *
* @param repository
* @param objectId
* if unspecified, HEAD is assumed.
@@ -1200,7 +1200,7 @@ public class JGitUtils {
* repository. Caller may specify ending revision with objectId. Caller may
* specify offset and maxCount to achieve pagination of results. If the
* repository does not exist or is empty, an empty list is returned.
- *
+ *
* @param repository
* @param objectId
* if unspecified, HEAD is assumed.
@@ -1245,7 +1245,7 @@ public class JGitUtils {
RevWalk rw = new RevWalk(repository);
rw.markStart(rw.parseCommit(endRange));
if (startRange != null) {
- rw.markUninteresting(rw.parseCommit(startRange));
+ rw.markUninteresting(rw.parseCommit(startRange));
}
if (!StringUtils.isEmpty(path)) {
TreeFilter filter = AndTreeFilter.create(
@@ -1284,7 +1284,7 @@ public class JGitUtils {
* Returns a list of commits for the repository within the range specified
* by startRangeId and endRangeId. If the repository does not exist or is
* empty, an empty list is returned.
- *
+ *
* @param repository
* @param startRangeId
* the first commit (not included in results)
@@ -1329,7 +1329,7 @@ public class JGitUtils {
* Search results require a specified SearchType of AUTHOR, COMMITTER, or
* COMMIT. Results may be paginated using offset and maxCount. If the
* repository does not exist or is empty, an empty list is returned.
- *
+ *
* @param repository
* @param objectId
* if unspecified, HEAD is assumed.
@@ -1429,7 +1429,7 @@ public class JGitUtils {
* Returns the default branch to use for a repository. Normally returns
* whatever branch HEAD points to, but if HEAD points to nothing it returns
* the most recently updated branch.
- *
+ *
* @param repository
* @return the objectid of a branch
* @throws Exception
@@ -1492,7 +1492,7 @@ public class JGitUtils {
}
return target;
}
-
+
/**
* Sets the symbolic ref HEAD to the specified target ref. The
* HEAD will be detached if the target ref is not a branch.
@@ -1519,7 +1519,7 @@ public class JGitUtils {
case FORCED:
case NO_CHANGE:
case FAST_FORWARD:
- return true;
+ return true;
default:
LOGGER.error(MessageFormat.format("{0} HEAD update to {1} returned result {2}",
repository.getDirectory().getAbsolutePath(), targetRef, result));
@@ -1529,7 +1529,7 @@ public class JGitUtils {
}
return false;
}
-
+
/**
* Sets the local branch ref to point to the specified commit id.
*
@@ -1554,7 +1554,7 @@ public class JGitUtils {
case FORCED:
case NO_CHANGE:
case FAST_FORWARD:
- return true;
+ return true;
default:
LOGGER.error(MessageFormat.format("{0} {1} update to {2} returned result {3}",
repository.getDirectory().getAbsolutePath(), branchName, commitId, result));
@@ -1564,10 +1564,10 @@ public class JGitUtils {
}
return false;
}
-
+
/**
* Deletes the specified branch ref.
- *
+ *
* @param repository
* @param branch
* @return true if successful
@@ -1587,7 +1587,7 @@ public class JGitUtils {
case FORCED:
case NO_CHANGE:
case FAST_FORWARD:
- return true;
+ return true;
default:
LOGGER.error(MessageFormat.format("{0} failed to delete to {1} returned result {2}",
repository.getDirectory().getAbsolutePath(), branchName, result));
@@ -1597,7 +1597,7 @@ public class JGitUtils {
}
return false;
}
-
+
/**
* Get the full branch and tag ref names for any potential HEAD targets.
*
@@ -1618,17 +1618,17 @@ public class JGitUtils {
/**
* Returns all refs grouped by their associated object id.
- *
+ *
* @param repository
* @return all refs grouped by their referenced object id
*/
public static Map<ObjectId, List<RefModel>> getAllRefs(Repository repository) {
return getAllRefs(repository, true);
}
-
+
/**
* Returns all refs grouped by their associated object id.
- *
+ *
* @param repository
* @param includeRemoteRefs
* @return all refs grouped by their referenced object id
@@ -1652,7 +1652,7 @@ public class JGitUtils {
/**
* Returns the list of tags in the repository. If repository does not exist
* or is empty, an empty list is returned.
- *
+ *
* @param repository
* @param fullName
* if true, /refs/tags/yadayadayada is returned. If false,
@@ -1668,7 +1668,7 @@ public class JGitUtils {
/**
* Returns the list of local branches in the repository. If repository does
* not exist or is empty, an empty list is returned.
- *
+ *
* @param repository
* @param fullName
* if true, /refs/heads/yadayadayada is returned. If false,
@@ -1685,7 +1685,7 @@ public class JGitUtils {
/**
* Returns the list of remote branches in the repository. If repository does
* not exist or is empty, an empty list is returned.
- *
+ *
* @param repository
* @param fullName
* if true, /refs/remotes/yadayadayada is returned. If false,
@@ -1702,7 +1702,7 @@ public class JGitUtils {
/**
* Returns the list of note branches. If repository does not exist or is
* empty, an empty list is returned.
- *
+ *
* @param repository
* @param fullName
* if true, /refs/notes/yadayadayada is returned. If false,
@@ -1715,11 +1715,11 @@ public class JGitUtils {
int maxCount) {
return getRefs(repository, Constants.R_NOTES, fullName, maxCount);
}
-
+
/**
- * Returns the list of refs in the specified base ref. If repository does
+ * Returns the list of refs in the specified base ref. If repository does
* not exist or is empty, an empty list is returned.
- *
+ *
* @param repository
* @param fullName
* if true, /refs/yadayadayada is returned. If false,
@@ -1733,7 +1733,7 @@ public class JGitUtils {
/**
* Returns a list of references in the repository matching "refs". If the
* repository is null or empty, an empty list is returned.
- *
+ *
* @param repository
* @param refs
* if unspecified, all refs are returned
@@ -1780,7 +1780,7 @@ public class JGitUtils {
/**
* Returns a RefModel for the gh-pages branch in the repository. If the
* branch can not be found, null is returned.
- *
+ *
* @param repository
* @return a refmodel for the gh-pages branch or null
*/
@@ -1791,7 +1791,7 @@ public class JGitUtils {
/**
* Returns a RefModel for a specific branch name in the repository. If the
* branch can not be found, null is returned.
- *
+ *
* @param repository
* @return a refmodel for the branch or null
*/
@@ -1820,10 +1820,10 @@ public class JGitUtils {
}
return branch;
}
-
+
/**
* Returns the list of submodules for this repository.
- *
+ *
* @param repository
* @param commit
* @return list of submodules
@@ -1832,10 +1832,10 @@ public class JGitUtils {
RevCommit commit = getCommit(repository, commitId);
return getSubmodules(repository, commit.getTree());
}
-
+
/**
* Returns the list of submodules for this repository.
- *
+ *
* @param repository
* @param commit
* @return list of submodules
@@ -1858,11 +1858,11 @@ public class JGitUtils {
}
return list;
}
-
+
/**
* Returns the submodule definition for the specified path at the specified
* commit. If no module is defined for the path, null is returned.
- *
+ *
* @param repository
* @param commit
* @param path
@@ -1876,7 +1876,7 @@ public class JGitUtils {
}
return null;
}
-
+
public static String getSubmoduleCommitId(Repository repository, String path, RevCommit commit) {
String commitId = null;
RevWalk rw = new RevWalk(repository);
@@ -1907,7 +1907,7 @@ public class JGitUtils {
* Returns the list of notes entered about the commit from the refs/notes
* namespace. If the repository does not exist or is empty, an empty list is
* returned.
- *
+ *
* @param repository
* @param commit
* @return list of notes
@@ -1931,7 +1931,7 @@ public class JGitUtils {
list.add(gitNote);
continue;
}
-
+
// folder structure
StringBuilder sb = new StringBuilder(commit.getName());
sb.insert(2, '/');
@@ -1951,7 +1951,7 @@ public class JGitUtils {
/**
* this method creates an incremental revision number as a tag according to
* the amount of already existing tags, which start with a defined prefix.
- *
+ *
* @param repository
* @param objectId
* @param tagger
@@ -1985,7 +1985,7 @@ public class JGitUtils {
/**
* creates a tag in a repository
- *
+ *
* @param repository
* @param objectId, the ref the tag points towards
* @param tagger, the person tagging the object
@@ -1994,7 +1994,7 @@ public class JGitUtils {
* @return boolean, true if operation was successful, otherwise false
*/
public static boolean createTag(Repository repository, String objectId, PersonIdent tagger, String tag, String message) {
- try {
+ try {
Git gitClient = Git.open(repository.getDirectory());
TagCommand tagCommand = gitClient.tag();
tagCommand.setTagger(tagger);
@@ -2004,17 +2004,17 @@ public class JGitUtils {
tagCommand.setObjectId(revObj);
}
tagCommand.setName(tag);
- Ref call = tagCommand.call();
+ Ref call = tagCommand.call();
return call != null ? true : false;
} catch (Exception e) {
error(e, repository, "Failed to create tag {1} in repository {0}", objectId, tag);
}
return false;
}
-
+
/**
* Create an orphaned branch in a repository.
- *
+ *
* @param repository
* @param branchName
* @param author
@@ -2082,10 +2082,10 @@ public class JGitUtils {
}
return success;
}
-
+
/**
* Reads the sparkleshare id, if present, from the repository.
- *
+ *
* @param repository
* @return an id or null
*/
diff --git a/src/main/java/com/gitblit/utils/JnaUtils.java b/src/main/java/com/gitblit/utils/JnaUtils.java
index 4009342a..2b807196 100644
--- a/src/main/java/com/gitblit/utils/JnaUtils.java
+++ b/src/main/java/com/gitblit/utils/JnaUtils.java
@@ -15,9 +15,6 @@
*/
package com.gitblit.utils;
-import com.sun.jna.Library;
-import com.sun.jna.Native;
-
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
@@ -28,6 +25,9 @@ import java.util.regex.Pattern;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.sun.jna.Library;
+import com.sun.jna.Native;
+
/**
* Collection of static methods to access native OS library functionality.
*
diff --git a/src/main/java/com/gitblit/utils/JsonUtils.java b/src/main/java/com/gitblit/utils/JsonUtils.java
index e9241827..fdf68e52 100644
--- a/src/main/java/com/gitblit/utils/JsonUtils.java
+++ b/src/main/java/com/gitblit/utils/JsonUtils.java
@@ -54,9 +54,9 @@ import com.google.gson.reflect.TypeToken;
/**
* Utility methods for json calls to a Gitblit server.
- *
+ *
* @author James Moger
- *
+ *
*/
public class JsonUtils {
@@ -68,7 +68,7 @@ public class JsonUtils {
/**
* Creates JSON from the specified object.
- *
+ *
* @param o
* @return json
*/
@@ -79,7 +79,7 @@ public class JsonUtils {
/**
* Convert a json string to an object of the specified type.
- *
+ *
* @param json
* @param clazz
* @return an object
@@ -90,7 +90,7 @@ public class JsonUtils {
/**
* Convert a json string to an object of the specified type.
- *
+ *
* @param json
* @param clazz
* @return an object
@@ -101,7 +101,7 @@ public class JsonUtils {
/**
* Reads a gson object from the specified url.
- *
+ *
* @param url
* @param type
* @return the deserialized object
@@ -114,7 +114,7 @@ public class JsonUtils {
/**
* Reads a gson object from the specified url.
- *
+ *
* @param url
* @param type
* @return the deserialized object
@@ -127,7 +127,7 @@ public class JsonUtils {
/**
* Reads a gson object from the specified url.
- *
+ *
* @param url
* @param type
* @param username
@@ -146,7 +146,7 @@ public class JsonUtils {
/**
* Reads a gson object from the specified url.
- *
+ *
* @param url
* @param clazz
* @param username
@@ -165,7 +165,7 @@ public class JsonUtils {
/**
* Retrieves a JSON message.
- *
+ *
* @param url
* @return the JSON message as a string
* @throws {@link IOException}
@@ -205,7 +205,7 @@ public class JsonUtils {
/**
* Sends a JSON message.
- *
+ *
* @param url
* the url to write to
* @param json
@@ -219,7 +219,7 @@ public class JsonUtils {
/**
* Sends a JSON message.
- *
+ *
* @param url
* the url to write to
* @param json
@@ -296,7 +296,7 @@ public class JsonUtils {
JsonDeserializationContext jsonDeserializationContext) {
try {
synchronized (dateFormat) {
- Date date = dateFormat.parse(jsonElement.getAsString());
+ Date date = dateFormat.parse(jsonElement.getAsString());
return new Date((date.getTime() / 1000) * 1000);
}
} catch (ParseException e) {
@@ -304,7 +304,7 @@ public class JsonUtils {
}
}
}
-
+
private static class AccessPermissionTypeAdapter implements JsonSerializer<AccessPermission>, JsonDeserializer<AccessPermission> {
private AccessPermissionTypeAdapter() {
@@ -319,7 +319,7 @@ public class JsonUtils {
@Override
public synchronized AccessPermission deserialize(JsonElement jsonElement, Type type,
JsonDeserializationContext jsonDeserializationContext) {
- return AccessPermission.fromCode(jsonElement.getAsString());
+ return AccessPermission.fromCode(jsonElement.getAsString());
}
}
@@ -334,10 +334,12 @@ public class JsonUtils {
this.fieldName = fqfn.substring(fqfn.lastIndexOf(".") + 1);
}
+ @Override
public boolean shouldSkipClass(Class<?> arg0) {
return false;
}
+ @Override
public boolean shouldSkipField(FieldAttributes f) {
return (f.getDeclaringClass() == c && f.getName().equals(fieldName));
}
diff --git a/src/main/java/com/gitblit/utils/MarkdownUtils.java b/src/main/java/com/gitblit/utils/MarkdownUtils.java
index 0b8c9c57..15242364 100644
--- a/src/main/java/com/gitblit/utils/MarkdownUtils.java
+++ b/src/main/java/com/gitblit/utils/MarkdownUtils.java
@@ -26,15 +26,15 @@ import org.tautua.markdownpapers.parser.ParseException;
/**
* Utility methods for transforming raw markdown text to html.
- *
+ *
* @author James Moger
- *
+ *
*/
public class MarkdownUtils {
/**
* Returns the html version of the markdown source text.
- *
+ *
* @param markdown
* @return html version of markdown text
* @throws java.text.ParseException
@@ -55,7 +55,7 @@ public class MarkdownUtils {
/**
* Returns the html version of the markdown source reader. The reader is
* closed regardless of success or failure.
- *
+ *
* @param markdownReader
* @return html version of the markdown text
* @throws java.text.ParseException
diff --git a/src/main/java/com/gitblit/utils/MetricUtils.java b/src/main/java/com/gitblit/utils/MetricUtils.java
index 26e4581c..47031021 100644
--- a/src/main/java/com/gitblit/utils/MetricUtils.java
+++ b/src/main/java/com/gitblit/utils/MetricUtils.java
@@ -39,9 +39,9 @@ import com.gitblit.models.RefModel;
/**
* Utility class for collecting metrics on a branch, tag, or other ref within
* the repository.
- *
+ *
* @author James Moger
- *
+ *
*/
public class MetricUtils {
@@ -49,7 +49,7 @@ public class MetricUtils {
/**
* Log an error message and exception.
- *
+ *
* @param t
* @param repository
* if repository is not null it MUST be the {0} parameter in the
@@ -74,12 +74,12 @@ public class MetricUtils {
* Returns the list of metrics for the specified commit reference, branch,
* or tag within the repository. If includeTotal is true, the total of all
* the metrics will be included as the first element in the returned list.
- *
+ *
* If the dateformat is unspecified an attempt is made to determine an
* appropriate date format by determining the time difference between the
* first commit on the branch and the most recent commit. This assumes that
* the commits are linear.
- *
+ *
* @param repository
* @param objectId
* if null or empty, HEAD is assumed.
@@ -172,7 +172,7 @@ public class MetricUtils {
/**
* Returns a list of author metrics for the specified repository.
- *
+ *
* @param repository
* @param objectId
* if null or empty, HEAD is assumed.
diff --git a/src/main/java/com/gitblit/utils/ModelUtils.java b/src/main/java/com/gitblit/utils/ModelUtils.java
index d053db65..6fb4c0ac 100644
--- a/src/main/java/com/gitblit/utils/ModelUtils.java
+++ b/src/main/java/com/gitblit/utils/ModelUtils.java
@@ -38,7 +38,7 @@ public class ModelUtils
userRepoPrefix = Constants.DEFAULT_USER_REPOSITORY_PREFIX;
return;
}
-
+
String newPrefix = prefix.replace('\\', '/');
if (prefix.charAt(0) == '/') {
newPrefix = prefix.substring(1);
diff --git a/src/main/java/com/gitblit/utils/ObjectCache.java b/src/main/java/com/gitblit/utils/ObjectCache.java
index 692669f4..48a9668d 100644
--- a/src/main/java/com/gitblit/utils/ObjectCache.java
+++ b/src/main/java/com/gitblit/utils/ObjectCache.java
@@ -25,9 +25,9 @@ import java.util.concurrent.ConcurrentHashMap;
* milliseconds and in fast, concurrent systems this cache is too simplistic.
* However, for the cases where its being used in Gitblit this cache technique
* is just fine.
- *
+ *
* @author James Moger
- *
+ *
*/
public class ObjectCache<X> implements Serializable {
@@ -91,7 +91,7 @@ public class ObjectCache<X> implements Serializable {
}
return null;
}
-
+
public int size() {
return cache.size();
}
diff --git a/src/main/java/com/gitblit/utils/PatchFormatter.java b/src/main/java/com/gitblit/utils/PatchFormatter.java
index 90b3fb16..c7d2cef4 100644
--- a/src/main/java/com/gitblit/utils/PatchFormatter.java
+++ b/src/main/java/com/gitblit/utils/PatchFormatter.java
@@ -32,9 +32,9 @@ import com.gitblit.Constants;
/**
* A diff formatter that outputs standard patch content.
- *
+ *
* @author James Moger
- *
+ *
*/
public class PatchFormatter extends DiffFormatter {
@@ -49,6 +49,7 @@ public class PatchFormatter extends DiffFormatter {
this.os = os;
}
+ @Override
public void format(DiffEntry entry) throws IOException {
currentTouple = new PatchTouple();
changes.put(entry.getNewPath(), currentTouple);
diff --git a/src/main/java/com/gitblit/utils/RefLogUtils.java b/src/main/java/com/gitblit/utils/RefLogUtils.java
index df09a76f..af247733 100644
--- a/src/main/java/com/gitblit/utils/RefLogUtils.java
+++ b/src/main/java/com/gitblit/utils/RefLogUtils.java
@@ -66,19 +66,19 @@ import com.gitblit.models.UserModel;
/**
* Utility class for maintaining a reflog within a git repository on an
* orphan branch.
- *
+ *
* @author James Moger
*
*/
public class RefLogUtils {
-
+
private static final String GB_REFLOG = "refs/gitblit/reflog";
private static final Logger LOGGER = LoggerFactory.getLogger(RefLogUtils.class);
/**
* Log an error message and exception.
- *
+ *
* @param t
* @param repository
* if repository is not null it MUST be the {0} parameter in the
@@ -98,10 +98,10 @@ public class RefLogUtils {
}
LOGGER.error(MessageFormat.format(pattern, parameters.toArray()), t);
}
-
+
/**
* Returns true if the repository has a reflog branch.
- *
+ *
* @param repository
* @return true if the repository has a reflog branch
*/
@@ -117,7 +117,7 @@ public class RefLogUtils {
/**
* Returns a RefModel for the reflog branch in the repository. If the
* branch can not be found, null is returned.
- *
+ *
* @param repository
* @return a refmodel for the reflog branch or null
*/
@@ -152,7 +152,7 @@ public class RefLogUtils {
}
return null;
}
-
+
private static UserModel newUserModelFrom(PersonIdent ident) {
String name = ident.getName();
String username;
@@ -165,16 +165,16 @@ public class RefLogUtils {
displayname = name;
username = ident.getEmailAddress();
}
-
+
UserModel user = new UserModel(username);
user.displayName = displayname;
user.emailAddress = ident.getEmailAddress();
return user;
}
-
+
/**
* Logs a ref deletion.
- *
+ *
* @param user
* @param repository
* @param ref
@@ -189,7 +189,7 @@ public class RefLogUtils {
if (reflogBranch == null) {
return false;
}
-
+
List<RevCommit> log = JGitUtils.getRevLog(repository, reflogBranch.getName(), ref.getName(), 0, 1);
if (log.isEmpty()) {
// this ref is not in the reflog branch
@@ -202,10 +202,10 @@ public class RefLogUtils {
}
return false;
}
-
+
/**
* Updates the reflog with the received commands.
- *
+ *
* @param user
* @param repository
* @param commands
@@ -217,10 +217,10 @@ public class RefLogUtils {
if (reflogBranch == null) {
JGitUtils.createOrphanBranch(repository, GB_REFLOG, null);
}
-
+
boolean success = false;
String message = "push";
-
+
try {
ObjectId headId = repository.resolve(GB_REFLOG + "^{commit}");
ObjectInserter odi = repository.newObjectInserter();
@@ -286,17 +286,17 @@ public class RefLogUtils {
}
return success;
}
-
+
/**
* Creates an in-memory index of the push log entry.
- *
+ *
* @param repo
* @param headId
* @param commands
* @return an in-memory index
* @throws IOException
*/
- private static DirCache createIndex(Repository repo, ObjectId headId,
+ private static DirCache createIndex(Repository repo, ObjectId headId,
Collection<ReceiveCommand> commands) throws IOException {
DirCache inCoreIndex = DirCache.newInCore();
@@ -335,7 +335,7 @@ public class RefLogUtils {
continue;
}
String content = change.toString();
-
+
// create an index entry for this attachment
final DirCacheEntry dcEntry = new DirCacheEntry(path);
dcEntry.setLength(content.length());
@@ -386,7 +386,7 @@ public class RefLogUtils {
}
return inCoreIndex;
}
-
+
public static List<RefLogEntry> getRefLog(String repositoryName, Repository repository) {
return getRefLog(repositoryName, repository, null, 0, -1);
}
@@ -402,11 +402,11 @@ public class RefLogUtils {
public static List<RefLogEntry> getRefLog(String repositoryName, Repository repository, Date minimumDate) {
return getRefLog(repositoryName, repository, minimumDate, 0, -1);
}
-
+
/**
* Returns the list of reflog entries as they were recorded by Gitblit.
* Each RefLogEntry may represent multiple ref updates.
- *
+ *
* @param repositoryName
* @param repository
* @param minimumDate
@@ -425,7 +425,7 @@ public class RefLogUtils {
if (maxCount == 0) {
return list;
}
-
+
Map<ObjectId, List<RefModel>> allRefs = JGitUtils.getAllRefs(repository);
List<RevCommit> pushes;
if (minimumDate == null) {
@@ -441,8 +441,8 @@ public class RefLogUtils {
UserModel user = newUserModelFrom(push.getAuthorIdent());
Date date = push.getAuthorIdent().getWhen();
-
- RefLogEntry log = new RefLogEntry(repositoryName, date, user);
+
+ RefLogEntry log = new RefLogEntry(repositoryName, date, user);
List<PathChangeModel> changedRefs = JGitUtils.getFilesInCommit(repository, push);
if (changedRefs.isEmpty()) {
// skip empty commits
@@ -483,7 +483,7 @@ public class RefLogUtils {
/**
* Returns the list of pushes separated by ref (e.g. each ref has it's own
* PushLogEntry object).
- *
+ *
* @param repositoryName
* @param repository
* @param maxCount
@@ -492,11 +492,11 @@ public class RefLogUtils {
public static List<RefLogEntry> getLogByRef(String repositoryName, Repository repository, int maxCount) {
return getLogByRef(repositoryName, repository, 0, maxCount);
}
-
+
/**
* Returns the list of pushes separated by ref (e.g. each ref has it's own
* PushLogEntry object).
- *
+ *
* @param repositoryName
* @param repository
* @param offset
@@ -513,7 +513,7 @@ public class RefLogUtils {
if (!refMap.containsKey(ref)) {
refMap.put(ref, new ArrayList<RefLogEntry>());
}
-
+
// construct new ref-specific ref change entry
RefLogEntry refChange;
if (entry instanceof DailyLogEntry) {
@@ -528,23 +528,23 @@ public class RefLogUtils {
refMap.get(ref).add(refChange);
}
}
-
+
// merge individual ref changes into master list
List<RefLogEntry> mergedRefLog = new ArrayList<RefLogEntry>();
for (List<RefLogEntry> refPush : refMap.values()) {
mergedRefLog.addAll(refPush);
}
-
+
// sort ref log
Collections.sort(mergedRefLog);
-
+
return mergedRefLog;
}
-
+
/**
* Returns the list of ref changes separated by ref (e.g. each ref has it's own
* RefLogEntry object).
- *
+ *
* @param repositoryName
* @param repository
* @param minimumDate
@@ -567,16 +567,16 @@ public class RefLogUtils {
refMap.get(ref).add(refPush);
}
}
-
+
// merge individual ref pushes into master list
List<RefLogEntry> refPushLog = new ArrayList<RefLogEntry>();
for (List<RefLogEntry> refPush : refMap.values()) {
refPushLog.addAll(refPush);
}
-
+
// sort ref push log
Collections.sort(refPushLog);
-
+
return refPushLog;
}
@@ -631,12 +631,12 @@ public class RefLogUtils {
linearParent = commit.getParents()[0].getId().getName();
digest.updateRef(branch, ReceiveCommand.Type.UPDATE, linearParent, commit.getName());
}
-
+
RepositoryCommit repoCommit = digest.addCommit(commit);
if (repoCommit != null) {
List<RefModel> matchedRefs = allRefs.get(commit.getId());
repoCommit.setRefs(matchedRefs);
-
+
if (!ArrayUtils.isEmpty(matchedRefs)) {
for (RefModel ref : matchedRefs) {
if (ref.getName().startsWith(Constants.R_TAGS)) {
diff --git a/src/main/java/com/gitblit/utils/RpcUtils.java b/src/main/java/com/gitblit/utils/RpcUtils.java
index 290be49e..24e07dcd 100644
--- a/src/main/java/com/gitblit/utils/RpcUtils.java
+++ b/src/main/java/com/gitblit/utils/RpcUtils.java
@@ -39,9 +39,9 @@ import com.google.gson.reflect.TypeToken;
/**
* Utility methods for rpc calls.
- *
+ *
* @author James Moger
- *
+ *
*/
public class RpcUtils {
@@ -76,7 +76,7 @@ public class RpcUtils {
}.getType();
/**
- *
+ *
* @param remoteURL
* the url of the remote gitblit instance
* @param req
@@ -88,7 +88,7 @@ public class RpcUtils {
}
/**
- *
+ *
* @param remoteURL
* the url of the remote gitblit instance
* @param req
@@ -110,7 +110,7 @@ public class RpcUtils {
/**
* Returns the version of the RPC protocol on the server.
- *
+ *
* @param serverUrl
* @param account
* @param password
@@ -124,7 +124,7 @@ public class RpcUtils {
try {
protocol = JsonUtils.retrieveJson(url, Integer.class, account, password);
} catch (UnknownRequestException e) {
- // v0.7.0 (protocol 1) did not have this request type
+ // v0.7.0 (protocol 1) did not have this request type
}
return protocol;
}
@@ -132,7 +132,7 @@ public class RpcUtils {
/**
* Retrieves a map of the repositories at the remote gitblit instance keyed
* by the repository clone url.
- *
+ *
* @param serverUrl
* @param account
* @param password
@@ -149,7 +149,7 @@ public class RpcUtils {
/**
* Tries to pull the gitblit user accounts from the remote gitblit instance.
- *
+ *
* @param serverUrl
* @param account
* @param password
@@ -167,7 +167,7 @@ public class RpcUtils {
/**
* Tries to pull the gitblit team definitions from the remote gitblit
* instance.
- *
+ *
* @param serverUrl
* @param account
* @param password
@@ -184,7 +184,7 @@ public class RpcUtils {
/**
* Create a repository on the Gitblit server.
- *
+ *
* @param repository
* @param serverUrl
* @param account
@@ -205,7 +205,7 @@ public class RpcUtils {
/**
* Send a revised version of the repository model to the Gitblit server.
- *
+ *
* @param repository
* @param serverUrl
* @param account
@@ -221,7 +221,7 @@ public class RpcUtils {
/**
* Delete a repository from the Gitblit server.
- *
+ *
* @param repository
* @param serverUrl
* @param account
@@ -235,17 +235,17 @@ public class RpcUtils {
password);
}
-
+
/**
* Clears the repository cache on the Gitblit server.
- *
+ *
* @param serverUrl
* @param account
* @param password
* @return true if the action succeeded
* @throws IOException
*/
- public static boolean clearRepositoryCache(String serverUrl, String account,
+ public static boolean clearRepositoryCache(String serverUrl, String account,
char[] password) throws IOException {
return doAction(RpcRequest.CLEAR_REPOSITORY_CACHE, null, null, serverUrl, account,
password);
@@ -253,7 +253,7 @@ public class RpcUtils {
/**
* Create a user on the Gitblit server.
- *
+ *
* @param user
* @param serverUrl
* @param account
@@ -269,7 +269,7 @@ public class RpcUtils {
/**
* Send a revised version of the user model to the Gitblit server.
- *
+ *
* @param user
* @param serverUrl
* @param account
@@ -285,7 +285,7 @@ public class RpcUtils {
/**
* Deletes a user from the Gitblit server.
- *
+ *
* @param user
* @param serverUrl
* @param account
@@ -297,11 +297,11 @@ public class RpcUtils {
char[] password) throws IOException {
return doAction(RpcRequest.DELETE_USER, null, user, serverUrl, account, password);
}
-
+
/**
* Tries to get the specified gitblit user account from the remote gitblit instance.
* If the username is null or empty, the current user is returned.
- *
+ *
* @param username
* @param serverUrl
* @param account
@@ -318,7 +318,7 @@ public class RpcUtils {
/**
* Create a team on the Gitblit server.
- *
+ *
* @param team
* @param serverUrl
* @param account
@@ -334,7 +334,7 @@ public class RpcUtils {
/**
* Send a revised version of the team model to the Gitblit server.
- *
+ *
* @param team
* @param serverUrl
* @param account
@@ -350,7 +350,7 @@ public class RpcUtils {
/**
* Deletes a team from the Gitblit server.
- *
+ *
* @param team
* @param serverUrl
* @param account
@@ -365,7 +365,7 @@ public class RpcUtils {
/**
* Retrieves the list of users that can access the specified repository.
- *
+ *
* @param repository
* @param serverUrl
* @param account
@@ -379,10 +379,10 @@ public class RpcUtils {
Collection<String> list = JsonUtils.retrieveJson(url, NAMES_TYPE, account, password);
return new ArrayList<String>(list);
}
-
+
/**
* Retrieves the list of user access permissions for the specified repository.
- *
+ *
* @param repository
* @param serverUrl
* @param account
@@ -390,7 +390,7 @@ public class RpcUtils {
* @return list of User-AccessPermission tuples
* @throws IOException
*/
- public static List<RegistrantAccessPermission> getRepositoryMemberPermissions(RepositoryModel repository,
+ public static List<RegistrantAccessPermission> getRepositoryMemberPermissions(RepositoryModel repository,
String serverUrl, String account, char [] password) throws IOException {
String url = asLink(serverUrl, RpcRequest.LIST_REPOSITORY_MEMBER_PERMISSIONS, repository.name);
Collection<RegistrantAccessPermission> list = JsonUtils.retrieveJson(url, REGISTRANT_PERMISSIONS_TYPE, account, password);
@@ -399,7 +399,7 @@ public class RpcUtils {
/**
* Sets the repository user access permissions
- *
+ *
* @param repository
* @param permissions
* @param serverUrl
@@ -414,10 +414,10 @@ public class RpcUtils {
return doAction(RpcRequest.SET_REPOSITORY_MEMBER_PERMISSIONS, repository.name, permissions, serverUrl,
account, password);
}
-
+
/**
* Retrieves the list of teams that can access the specified repository.
- *
+ *
* @param repository
* @param serverUrl
* @param account
@@ -431,10 +431,10 @@ public class RpcUtils {
Collection<String> list = JsonUtils.retrieveJson(url, NAMES_TYPE, account, password);
return new ArrayList<String>(list);
}
-
+
/**
* Retrieves the list of team access permissions for the specified repository.
- *
+ *
* @param repository
* @param serverUrl
* @param account
@@ -442,7 +442,7 @@ public class RpcUtils {
* @return list of Team-AccessPermission tuples
* @throws IOException
*/
- public static List<RegistrantAccessPermission> getRepositoryTeamPermissions(RepositoryModel repository,
+ public static List<RegistrantAccessPermission> getRepositoryTeamPermissions(RepositoryModel repository,
String serverUrl, String account, char [] password) throws IOException {
String url = asLink(serverUrl, RpcRequest.LIST_REPOSITORY_TEAM_PERMISSIONS, repository.name);
Collection<RegistrantAccessPermission> list = JsonUtils.retrieveJson(url, REGISTRANT_PERMISSIONS_TYPE, account, password);
@@ -451,7 +451,7 @@ public class RpcUtils {
/**
* Sets the repository team access permissions
- *
+ *
* @param repository
* @param permissions
* @param serverUrl
@@ -466,11 +466,11 @@ public class RpcUtils {
return doAction(RpcRequest.SET_REPOSITORY_TEAM_PERMISSIONS, repository.name, permissions, serverUrl,
account, password);
}
-
+
/**
* Retrieves the list of federation registrations. These are the list of
* registrations that this Gitblit instance is pulling from.
- *
+ *
* @param serverUrl
* @param account
* @param password
@@ -489,7 +489,7 @@ public class RpcUtils {
/**
* Retrieves the list of federation result registrations. These are the
* results reported back to this Gitblit instance from a federation client.
- *
+ *
* @param serverUrl
* @param account
* @param password
@@ -507,7 +507,7 @@ public class RpcUtils {
/**
* Retrieves the list of federation proposals.
- *
+ *
* @param serverUrl
* @param account
* @param password
@@ -525,7 +525,7 @@ public class RpcUtils {
/**
* Retrieves the list of federation repository sets.
- *
+ *
* @param serverUrl
* @param account
* @param password
@@ -542,7 +542,7 @@ public class RpcUtils {
/**
* Retrieves the settings of the Gitblit server.
- *
+ *
* @param serverUrl
* @param account
* @param password
@@ -559,7 +559,7 @@ public class RpcUtils {
/**
* Update the settings on the Gitblit server.
- *
+ *
* @param settings
* the settings to update
* @param serverUrl
@@ -576,7 +576,7 @@ public class RpcUtils {
/**
* Retrieves the server status object.
- *
+ *
* @param serverUrl
* @param account
* @param password
@@ -593,7 +593,7 @@ public class RpcUtils {
/**
* Retrieves a map of local branches in the Gitblit server keyed by
* repository.
- *
+ *
* @param serverUrl
* @param account
* @param password
@@ -610,7 +610,7 @@ public class RpcUtils {
/**
* Retrieves a list of available branch feeds in the Gitblit server.
- *
+ *
* @param serverUrl
* @param account
* @param password
@@ -634,7 +634,7 @@ public class RpcUtils {
/**
* Do the specified administrative action on the Gitblit server.
- *
+ *
* @param request
* @param name
* the name of the object (may be null)
diff --git a/src/main/java/com/gitblit/utils/StringUtils.java b/src/main/java/com/gitblit/utils/StringUtils.java
index cff3577d..5e627781 100644
--- a/src/main/java/com/gitblit/utils/StringUtils.java
+++ b/src/main/java/com/gitblit/utils/StringUtils.java
@@ -40,9 +40,9 @@ import java.util.regex.PatternSyntaxException;
/**
* Utility class of string functions.
- *
+ *
* @author James Moger
- *
+ *
*/
public class StringUtils {
@@ -52,7 +52,7 @@ public class StringUtils {
/**
* Returns true if the string is null or empty.
- *
+ *
* @param value
* @return true if string is null or empty
*/
@@ -62,7 +62,7 @@ public class StringUtils {
/**
* Replaces carriage returns and line feeds with html line breaks.
- *
+ *
* @param string
* @return plain text with html line breaks
*/
@@ -73,7 +73,7 @@ public class StringUtils {
/**
* Prepare text for html presentation. Replace sensitive characters with
* html entities.
- *
+ *
* @param inStr
* @param changeSpace
* @return plain text escaped for html
@@ -104,7 +104,7 @@ public class StringUtils {
/**
* Decode html entities back into plain text characters.
- *
+ *
* @param inStr
* @return returns plain text from html
*/
@@ -115,7 +115,7 @@ public class StringUtils {
/**
* Encodes a url parameter by escaping troublesome characters.
- *
+ *
* @param inStr
* @return properly escaped url
*/
@@ -137,7 +137,7 @@ public class StringUtils {
/**
* Flatten the list of strings into a single string with a space separator.
- *
+ *
* @param values
* @return flattened list
*/
@@ -148,7 +148,7 @@ public class StringUtils {
/**
* Flatten the list of strings into a single string with the specified
* separator.
- *
+ *
* @param values
* @param separator
* @return flattened list
@@ -169,7 +169,7 @@ public class StringUtils {
* Returns a string trimmed to a maximum length with trailing ellipses. If
* the string length is shorter than the max, the original string is
* returned.
- *
+ *
* @param value
* @param max
* @return trimmed string
@@ -184,7 +184,7 @@ public class StringUtils {
/**
* Left pad a string with the specified character, if the string length is
* less than the specified length.
- *
+ *
* @param input
* @param length
* @param pad
@@ -205,7 +205,7 @@ public class StringUtils {
/**
* Right pad a string with the specified character, if the string length is
* less then the specified length.
- *
+ *
* @param input
* @param length
* @param pad
@@ -225,7 +225,7 @@ public class StringUtils {
/**
* Calculates the SHA1 of the string.
- *
+ *
* @param text
* @return sha1 of the string
*/
@@ -240,7 +240,7 @@ public class StringUtils {
/**
* Calculates the SHA1 of the byte array.
- *
+ *
* @param bytes
* @return sha1 of the byte array
*/
@@ -257,7 +257,7 @@ public class StringUtils {
/**
* Calculates the MD5 of the string.
- *
+ *
* @param string
* @return md5 of the string
*/
@@ -268,10 +268,10 @@ public class StringUtils {
throw new RuntimeException(u);
}
}
-
+
/**
* Calculates the MD5 of the string.
- *
+ *
* @param string
* @return md5 of the string
*/
@@ -289,17 +289,17 @@ public class StringUtils {
/**
* Returns the hex representation of the byte array.
- *
+ *
* @param bytes
* @return byte array as hex string
*/
private static String toHex(byte[] bytes) {
StringBuilder sb = new StringBuilder(bytes.length * 2);
for (int i = 0; i < bytes.length; i++) {
- if (((int) bytes[i] & 0xff) < 0x10) {
+ if ((bytes[i] & 0xff) < 0x10) {
sb.append('0');
}
- sb.append(Long.toString((int) bytes[i] & 0xff, 16));
+ sb.append(Long.toString(bytes[i] & 0xff, 16));
}
return sb.toString();
}
@@ -307,7 +307,7 @@ public class StringUtils {
/**
* Returns the root path of the specified path. Returns a blank string if
* there is no root path.
- *
+ *
* @param path
* @return root path or blank
*/
@@ -321,7 +321,7 @@ public class StringUtils {
/**
* Returns the path remainder after subtracting the basePath from the
* fullPath.
- *
+ *
* @param basePath
* @param fullPath
* @return the relative path
@@ -341,7 +341,7 @@ public class StringUtils {
/**
* Splits the space-separated string into a list of strings.
- *
+ *
* @param value
* @return list of strings
*/
@@ -351,7 +351,7 @@ public class StringUtils {
/**
* Splits the string into a list of string by the specified separator.
- *
+ *
* @param value
* @param separator
* @return list of strings
@@ -359,7 +359,7 @@ public class StringUtils {
public static List<String> getStringsFromValue(String value, String separator) {
List<String> strings = new ArrayList<String>();
try {
- String[] chunks = value.split(separator + "(?=([^\"]*\"[^\"]*\")*[^\"]*$)");
+ String[] chunks = value.split(separator + "(?=([^\"]*\"[^\"]*\")*[^\"]*$)");
for (String chunk : chunks) {
chunk = chunk.trim();
if (chunk.length() > 0) {
@@ -379,7 +379,7 @@ public class StringUtils {
/**
* Validates that a name is composed of letters, digits, or limited other
* characters.
- *
+ *
* @param name
* @return the first invalid character found or null if string is acceptable
*/
@@ -402,7 +402,7 @@ public class StringUtils {
/**
* Simple fuzzy string comparison. This is a case-insensitive check. A
* single wildcard * value is supported.
- *
+ *
* @param value
* @param pattern
* @return true if the value matches the pattern
@@ -431,7 +431,7 @@ public class StringUtils {
/**
* Compare two repository names for proper group sorting.
- *
+ *
* @param r1
* @param r2
* @return
@@ -459,7 +459,7 @@ public class StringUtils {
/**
* Sort grouped repository names.
- *
+ *
* @param list
*/
public static void sortRepositorynames(List<String> list) {
@@ -476,7 +476,7 @@ public class StringUtils {
for (char c : getMD5(value.toLowerCase()).toCharArray()) {
cs += c;
}
- int n = (cs % 360);
+ int n = (cs % 360);
float hue = ((float) n) / 360;
return hsvToRgb(hue, 0.90f, 0.65f);
}
@@ -514,10 +514,10 @@ public class StringUtils {
String bs = Integer.toHexString((int) (b * 256));
return "#" + rs + gs + bs;
}
-
+
/**
* Strips a trailing ".git" from the value.
- *
+ *
* @param value
* @return a stripped value or the original value if .git is not found
*/
@@ -527,10 +527,10 @@ public class StringUtils {
}
return value;
}
-
+
/**
* Count the number of lines in a string.
- *
+ *
* @param value
* @return the line count
*/
@@ -540,10 +540,10 @@ public class StringUtils {
}
return value.split("\n").length;
}
-
+
/**
* Returns the file extension of a path.
- *
+ *
* @param path
* @return a blank string or a file extension
*/
@@ -554,13 +554,13 @@ public class StringUtils {
}
return "";
}
-
+
/**
* Replace all occurences of a substring within a string with
* another string.
- *
+ *
* From Spring StringUtils.
- *
+ *
* @param inString String to examine
* @param oldPattern String to replace
* @param newPattern String to insert
@@ -582,12 +582,12 @@ public class StringUtils {
// remember to append any characters to the right of a match
return sb.toString();
}
-
+
/**
* Decodes a string by trying several charsets until one does not throw a
* coding exception. Last resort is to interpret as UTF-8 with illegal
* character substitution.
- *
+ *
* @param content
* @param charsets optional
* @return a string
@@ -620,12 +620,12 @@ public class StringUtils {
}
return value;
}
-
+
/**
* Attempt to extract a repository name from a given url using regular
* expressions. If no match is made, then return whatever trails after
* the final / character.
- *
+ *
* @param regexUrls
* @return a repository path
*/
@@ -644,7 +644,7 @@ public class StringUtils {
}
return url;
}
-
+
/**
* Converts a string with \nnn sequences into a UTF-8 encoded string.
* @param input
@@ -662,7 +662,7 @@ public class StringUtils {
// strip leading \ character
String oct = m.group().substring(1);
bytes.write(Integer.parseInt(oct, 8));
- i = m.end();
+ i = m.end();
}
if (bytes.size() == 0) {
// no octal matches
@@ -679,11 +679,11 @@ public class StringUtils {
}
return input;
}
-
+
/**
* Returns the first path element of a path string. If no path separator is
- * found in the path, an empty string is returned.
- *
+ * found in the path, an empty string is returned.
+ *
* @param path
* @return the first element in the path
*/
@@ -693,10 +693,10 @@ public class StringUtils {
}
return "";
}
-
+
/**
* Returns the last path element of a path string
- *
+ *
* @param path
* @return the last element in the path
*/
@@ -706,10 +706,10 @@ public class StringUtils {
}
return path;
}
-
+
/**
* Variation of String.matches() which disregards case issues.
- *
+ *
* @param regex
* @param input
* @return true if the pattern matches
@@ -719,11 +719,11 @@ public class StringUtils {
Matcher m = p.matcher(input);
return m.matches();
}
-
+
/**
* Removes new line and carriage return chars from a string.
* If input value is null an empty string is returned.
- *
+ *
* @param input
* @return a sanitized or empty string
*/
diff --git a/src/main/java/com/gitblit/utils/SyndicationUtils.java b/src/main/java/com/gitblit/utils/SyndicationUtils.java
index d01d4691..2ee1cf69 100644
--- a/src/main/java/com/gitblit/utils/SyndicationUtils.java
+++ b/src/main/java/com/gitblit/utils/SyndicationUtils.java
@@ -43,15 +43,15 @@ import com.sun.syndication.io.XmlReader;
/**
* Utility class for RSS feeds.
- *
+ *
* @author James Moger
- *
+ *
*/
public class SyndicationUtils {
/**
* Outputs an RSS feed of the list of entries to the outputstream.
- *
+ *
* @param hostUrl
* @param feedLink
* @param title
@@ -118,7 +118,7 @@ public class SyndicationUtils {
/**
* Reads a Gitblit RSS feed.
- *
+ *
* @param url
* the url of the Gitblit server
* @param repository
@@ -153,7 +153,7 @@ public class SyndicationUtils {
/**
* Reads a Gitblit RSS search feed.
- *
+ *
* @param url
* the url of the Gitblit server
* @param repository
@@ -195,7 +195,7 @@ public class SyndicationUtils {
/**
* Reads a Gitblit RSS feed.
- *
+ *
* @param url
* the url of the Gitblit server
* @param parameters
diff --git a/src/main/java/com/gitblit/utils/TimeUtils.java b/src/main/java/com/gitblit/utils/TimeUtils.java
index 9b5927c0..4b113be2 100644
--- a/src/main/java/com/gitblit/utils/TimeUtils.java
+++ b/src/main/java/com/gitblit/utils/TimeUtils.java
@@ -24,9 +24,9 @@ import java.util.TimeZone;
/**
* Utility class of time functions.
- *
+ *
* @author James Moger
- *
+ *
*/
public class TimeUtils {
public static final long MIN = 1000 * 60L;
@@ -38,15 +38,15 @@ public class TimeUtils {
public static final long ONEDAY = ONEHOUR * 24L;
public static final long ONEYEAR = ONEDAY * 365L;
-
+
private final ResourceBundle translation;
-
+
private final TimeZone timezone;
-
+
public TimeUtils() {
this(null, null);
}
-
+
public TimeUtils(ResourceBundle translation, TimeZone timezone) {
this.translation = translation;
this.timezone = timezone;
@@ -54,7 +54,7 @@ public class TimeUtils {
/**
* Returns true if date is today.
- *
+ *
* @param date
* @return true if date is today
*/
@@ -69,7 +69,7 @@ public class TimeUtils {
/**
* Returns true if date is yesterday.
- *
+ *
* @param date
* @return true if date is yesterday
*/
@@ -87,7 +87,7 @@ public class TimeUtils {
/**
* Returns the string representation of the duration as days, months and/or
* years.
- *
+ *
* @param days
* @return duration as string in days, months, and/or years
*/
@@ -123,7 +123,7 @@ public class TimeUtils {
/**
* Returns the number of minutes ago between the start time and the end
* time.
- *
+ *
* @param date
* @param endTime
* @param roundup
@@ -140,7 +140,7 @@ public class TimeUtils {
/**
* Return the difference in minutes between now and the date.
- *
+ *
* @param date
* @param roundup
* @return minutes ago
@@ -151,7 +151,7 @@ public class TimeUtils {
/**
* Return the difference in hours between now and the date.
- *
+ *
* @param date
* @param roundup
* @return hours ago
@@ -167,7 +167,7 @@ public class TimeUtils {
/**
* Return the difference in days between now and the date.
- *
+ *
* @param date
* @return days ago
*/
@@ -190,7 +190,7 @@ public class TimeUtils {
/**
* Returns the string representation of the duration between now and the
* date.
- *
+ *
* @param date
* @return duration as a string
*/
@@ -200,7 +200,7 @@ public class TimeUtils {
/**
* Returns the CSS class for the date based on its age from Now.
- *
+ *
* @param date
* @return the css class
*/
@@ -211,7 +211,7 @@ public class TimeUtils {
/**
* Returns the string representation of the duration OR the css class for
* the duration.
- *
+ *
* @param date
* @param css
* @return the string representation of the duration OR the css class
@@ -279,7 +279,7 @@ public class TimeUtils {
}
}
}
-
+
public String inFuture(Date date) {
long diff = date.getTime() - System.currentTimeMillis();
if (diff > ONEDAY) {
@@ -295,7 +295,7 @@ public class TimeUtils {
}
}
}
-
+
private String translate(String key, String defaultValue) {
String value = defaultValue;
if (translation != null && translation.containsKey(key)) {
@@ -306,7 +306,7 @@ public class TimeUtils {
}
return value;
}
-
+
private String translate(int val, String key, String defaultPattern) {
String pattern = defaultPattern;
if (translation != null && translation.containsKey(key)) {
@@ -320,7 +320,7 @@ public class TimeUtils {
/**
* Convert a frequency string into minutes.
- *
+ *
* @param frequency
* @return minutes
*/
diff --git a/src/main/java/com/gitblit/utils/X509Utils.java b/src/main/java/com/gitblit/utils/X509Utils.java
index 237c8dad..d3d5b46f 100644
--- a/src/main/java/com/gitblit/utils/X509Utils.java
+++ b/src/main/java/com/gitblit/utils/X509Utils.java
@@ -89,43 +89,43 @@ import com.gitblit.Constants;
/**
* Utility class to generate X509 certificates, keystores, and truststores.
- *
+ *
* @author James Moger
- *
+ *
*/
public class X509Utils {
-
+
public static final String SERVER_KEY_STORE = "serverKeyStore.jks";
-
+
public static final String SERVER_TRUST_STORE = "serverTrustStore.jks";
public static final String CERTS = "certs";
-
+
public static final String CA_KEY_STORE = "certs/caKeyStore.p12";
public static final String CA_REVOCATION_LIST = "certs/caRevocationList.crl";
-
+
public static final String CA_CONFIG = "certs/authority.conf";
public static final String CA_CN = "Gitblit Certificate Authority";
-
+
public static final String CA_ALIAS = CA_CN;
private static final String BC = org.bouncycastle.jce.provider.BouncyCastleProvider.PROVIDER_NAME;
-
+
private static final int KEY_LENGTH = 2048;
-
+
private static final String KEY_ALGORITHM = "RSA";
-
+
private static final String SIGNING_ALGORITHM = "SHA512withRSA";
-
+
public static final boolean unlimitedStrength;
-
+
private static final Logger logger = LoggerFactory.getLogger(X509Utils.class);
-
+
static {
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
-
+
// check for JCE Unlimited Strength
int maxKeyLen = 0;
try {
@@ -140,28 +140,28 @@ public class X509Utils {
logger.info("Using JCE Standard Encryption Policy files, encryption key lengths will be limited");
}
}
-
+
public static enum RevocationReason {
// https://en.wikipedia.org/wiki/Revocation_list
unspecified, keyCompromise, caCompromise, affiliationChanged, superseded,
cessationOfOperation, certificateHold, unused, removeFromCRL, privilegeWithdrawn,
ACompromise;
-
+
public static RevocationReason [] reasons = {
- unspecified, keyCompromise, caCompromise,
- affiliationChanged, superseded, cessationOfOperation,
+ unspecified, keyCompromise, caCompromise,
+ affiliationChanged, superseded, cessationOfOperation,
privilegeWithdrawn };
-
+
@Override
public String toString() {
return name() + " (" + ordinal() + ")";
}
}
-
+
public interface X509Log {
void log(String message);
}
-
+
public static class X509Metadata {
// map for distinguished name OIDs
@@ -169,10 +169,10 @@ public class X509Utils {
// CN in distingiushed name
public final String commonName;
-
+
// password for store
public final String password;
-
+
// password hint for README in bundle
public String passwordHint;
@@ -181,13 +181,13 @@ public class X509Utils {
// start date of generated certificate
public Date notBefore;
-
+
// expiraiton date of generated certificate
public Date notAfter;
-
+
// hostname of server for which certificate is generated
public String serverHostname;
-
+
// displayname of user for README in bundle
public String userDisplayname;
@@ -213,7 +213,7 @@ public class X509Utils {
notAfter = c.getTime();
oids = new HashMap<String, String>();
}
-
+
public X509Metadata clone(String commonName, String password) {
X509Metadata clone = new X509Metadata(commonName, password);
clone.emailAddress = emailAddress;
@@ -225,14 +225,14 @@ public class X509Utils {
clone.userDisplayname = userDisplayname;
return clone;
}
-
+
public String getOID(String oid, String defaultValue) {
if (oids.containsKey(oid)) {
return oids.get(oid);
}
return defaultValue;
}
-
+
public void setOID(String oid, String value) {
if (StringUtils.isEmpty(value)) {
oids.remove(oid);
@@ -241,10 +241,10 @@ public class X509Utils {
}
}
}
-
+
/**
* Prepare all the certificates and stores necessary for a Gitblit GO server.
- *
+ *
* @param metadata
* @param folder
* @param x509log
@@ -252,9 +252,9 @@ public class X509Utils {
public static void prepareX509Infrastructure(X509Metadata metadata, File folder, X509Log x509log) {
// make the specified folder, if necessary
folder.mkdirs();
-
+
// Gitblit CA certificate
- File caKeyStore = new File(folder, CA_KEY_STORE);
+ File caKeyStore = new File(folder, CA_KEY_STORE);
if (!caKeyStore.exists()) {
logger.info(MessageFormat.format("Generating {0} ({1})", CA_CN, caKeyStore.getAbsolutePath()));
X509Certificate caCert = newCertificateAuthority(metadata, caKeyStore, x509log);
@@ -262,7 +262,7 @@ public class X509Utils {
}
// Gitblit CRL
- File caRevocationList = new File(folder, CA_REVOCATION_LIST);
+ File caRevocationList = new File(folder, CA_REVOCATION_LIST);
if (!caRevocationList.exists()) {
logger.info(MessageFormat.format("Generating {0} CRL ({1})", CA_CN, caRevocationList.getAbsolutePath()));
newCertificateRevocationList(caRevocationList, caKeyStore, metadata.password);
@@ -273,7 +273,7 @@ public class X509Utils {
File oldKeyStore = new File(folder, "keystore");
if (oldKeyStore.exists()) {
oldKeyStore.renameTo(new File(folder, SERVER_KEY_STORE));
- logger.info(MessageFormat.format("Renaming {0} to {1}", oldKeyStore.getName(), SERVER_KEY_STORE));
+ logger.info(MessageFormat.format("Renaming {0} to {1}", oldKeyStore.getName(), SERVER_KEY_STORE));
}
// create web SSL certificate signed by CA
@@ -282,7 +282,7 @@ public class X509Utils {
logger.info(MessageFormat.format("Generating SSL certificate for {0} signed by {1} ({2})", metadata.commonName, CA_CN, serverKeyStore.getAbsolutePath()));
PrivateKey caPrivateKey = getPrivateKey(CA_ALIAS, caKeyStore, metadata.password);
X509Certificate caCert = getCertificate(CA_ALIAS, caKeyStore, metadata.password);
- newSSLCertificate(metadata, caPrivateKey, caCert, serverKeyStore, x509log);
+ newSSLCertificate(metadata, caPrivateKey, caCert, serverKeyStore, x509log);
}
// server certificate trust store holds trusted public certificates
@@ -293,11 +293,11 @@ public class X509Utils {
addTrustedCertificate(CA_ALIAS, caCert, serverTrustStore, metadata.password);
}
}
-
+
/**
* Open a keystore. Store type is determined by file extension of name. If
* undetermined, JKS is assumed. The keystore does not need to exist.
- *
+ *
* @param storeFile
* @param storePassword
* @return a KeyStore
@@ -336,10 +336,10 @@ public class X509Utils {
throw new RuntimeException("Could not open keystore " + storeFile, e);
}
}
-
+
/**
* Saves the keystore to the specified file.
- *
+ *
* @param targetStoreFile
* @param store
* @param password
@@ -376,17 +376,17 @@ public class X509Utils {
} catch (IOException e) {
}
}
-
+
if (tmpFile.exists()) {
tmpFile.delete();
}
}
- }
+ }
/**
* Retrieves the X509 certificate with the specified alias from the certificate
* store.
- *
+ *
* @param alias
* @param storeFile
* @param storePassword
@@ -401,11 +401,11 @@ public class X509Utils {
throw new RuntimeException(e);
}
}
-
+
/**
* Retrieves the private key for the specified alias from the certificate
* store.
- *
+ *
* @param alias
* @param storeFile
* @param storePassword
@@ -425,7 +425,7 @@ public class X509Utils {
* Saves the certificate to the file system. If the destination filename
* ends with the pem extension, the certificate is written in the PEM format,
* otherwise the certificate is written in the DER format.
- *
+ *
* @param cert
* @param targetFile
*/
@@ -443,7 +443,7 @@ public class X509Utils {
try {
pemWriter = new PEMWriter(new FileWriter(tmpFile));
pemWriter.writeObject(cert);
- pemWriter.flush();
+ pemWriter.flush();
} finally {
if (pemWriter != null) {
pemWriter.close();
@@ -462,9 +462,9 @@ public class X509Utils {
}
}
}
-
+
// rename tmp file to target
- if (targetFile.exists()) {
+ if (targetFile.exists()) {
targetFile.delete();
}
tmpFile.renameTo(targetFile);
@@ -475,10 +475,10 @@ public class X509Utils {
throw new RuntimeException("Failed to save certificate " + cert.getSubjectX500Principal().getName(), e);
}
}
-
+
/**
* Generate a new keypair.
- *
+ *
* @return a keypair
* @throws Exception
*/
@@ -487,10 +487,10 @@ public class X509Utils {
kpGen.initialize(KEY_LENGTH, new SecureRandom());
return kpGen.generateKeyPair();
}
-
+
/**
* Builds a distinguished name from the X509Metadata.
- *
+ *
* @return a DN
*/
private static X500Name buildDistinguishedName(X509Metadata metadata) {
@@ -501,14 +501,14 @@ public class X509Utils {
setOID(dnBuilder, metadata, "O", Constants.NAME);
setOID(dnBuilder, metadata, "OU", Constants.NAME);
setOID(dnBuilder, metadata, "E", metadata.emailAddress);
- setOID(dnBuilder, metadata, "CN", metadata.commonName);
+ setOID(dnBuilder, metadata, "CN", metadata.commonName);
X500Name dn = dnBuilder.build();
return dn;
}
-
+
private static void setOID(X500NameBuilder dnBuilder, X509Metadata metadata,
String oid, String defaultValue) {
-
+
String value = null;
if (metadata.oids != null && metadata.oids.containsKey(oid)) {
value = metadata.oids.get(oid);
@@ -516,7 +516,7 @@ public class X509Utils {
if (StringUtils.isEmpty(value)) {
value = defaultValue;
}
-
+
if (!StringUtils.isEmpty(value)) {
try {
Field field = BCStyle.class.getField(oid);
@@ -531,7 +531,7 @@ public class X509Utils {
/**
* Creates a new SSL certificate signed by the CA private key and stored in
* keyStore.
- *
+ *
* @param sslMetadata
* @param caPrivateKey
* @param caCert
@@ -544,15 +544,15 @@ public class X509Utils {
X500Name webDN = buildDistinguishedName(sslMetadata);
X500Name issuerDN = new X500Name(PrincipalUtil.getIssuerX509Principal(caCert).getName());
-
+
X509v3CertificateBuilder certBuilder = new JcaX509v3CertificateBuilder(
issuerDN,
- BigInteger.valueOf(System.currentTimeMillis()),
+ BigInteger.valueOf(System.currentTimeMillis()),
sslMetadata.notBefore,
sslMetadata.notAfter,
webDN,
pair.getPublic());
-
+
JcaX509ExtensionUtils extUtils = new JcaX509ExtensionUtils();
certBuilder.addExtension(X509Extension.subjectKeyIdentifier, false, extUtils.createSubjectKeyIdentifier(pair.getPublic()));
certBuilder.addExtension(X509Extension.basicConstraints, false, new BasicConstraints(false));
@@ -561,7 +561,7 @@ public class X509Utils {
// support alternateSubjectNames for SSL certificates
List<GeneralName> altNames = new ArrayList<GeneralName>();
if (HttpUtils.isIpAddress(sslMetadata.commonName)) {
- altNames.add(new GeneralName(GeneralName.iPAddress, sslMetadata.commonName));
+ altNames.add(new GeneralName(GeneralName.iPAddress, sslMetadata.commonName));
}
if (altNames.size() > 0) {
GeneralNames subjectAltName = new GeneralNames(altNames.toArray(new GeneralName [altNames.size()]));
@@ -572,7 +572,7 @@ public class X509Utils {
.setProvider(BC).build(caPrivateKey);
X509Certificate cert = new JcaX509CertificateConverter().setProvider(BC)
.getCertificate(certBuilder.build(caSigner));
-
+
cert.checkValidity(new Date());
cert.verify(caCert.getPublicKey());
@@ -581,9 +581,9 @@ public class X509Utils {
serverStore.setKeyEntry(sslMetadata.commonName, pair.getPrivate(), sslMetadata.password.toCharArray(),
new Certificate[] { cert, caCert });
saveKeyStore(targetStoreFile, serverStore, sslMetadata.password);
-
+
x509log.log(MessageFormat.format("New SSL certificate {0,number,0} [{1}]", cert.getSerialNumber(), cert.getSubjectDN().getName()));
-
+
// update serial number in metadata object
sslMetadata.serialNumber = cert.getSerialNumber().toString();
@@ -596,7 +596,7 @@ public class X509Utils {
/**
* Creates a new certificate authority PKCS#12 store. This function will
* destroy any existing CA store.
- *
+ *
* @param metadata
* @param storeFile
* @param keystorePassword
@@ -606,13 +606,13 @@ public class X509Utils {
public static X509Certificate newCertificateAuthority(X509Metadata metadata, File storeFile, X509Log x509log) {
try {
KeyPair caPair = newKeyPair();
-
+
ContentSigner caSigner = new JcaContentSignerBuilder(SIGNING_ALGORITHM).setProvider(BC).build(caPair.getPrivate());
-
+
// clone metadata
X509Metadata caMetadata = metadata.clone(CA_CN, metadata.password);
X500Name issuerDN = buildDistinguishedName(caMetadata);
-
+
// Generate self-signed certificate
X509v3CertificateBuilder caBuilder = new JcaX509v3CertificateBuilder(
issuerDN,
@@ -621,16 +621,16 @@ public class X509Utils {
caMetadata.notAfter,
issuerDN,
caPair.getPublic());
-
+
JcaX509ExtensionUtils extUtils = new JcaX509ExtensionUtils();
caBuilder.addExtension(X509Extension.subjectKeyIdentifier, false, extUtils.createSubjectKeyIdentifier(caPair.getPublic()));
caBuilder.addExtension(X509Extension.authorityKeyIdentifier, false, extUtils.createAuthorityKeyIdentifier(caPair.getPublic()));
caBuilder.addExtension(X509Extension.basicConstraints, false, new BasicConstraints(true));
caBuilder.addExtension(X509Extension.keyUsage, true, new KeyUsage(KeyUsage.digitalSignature | KeyUsage.keyCertSign | KeyUsage.cRLSign));
-
+
JcaX509CertificateConverter converter = new JcaX509CertificateConverter().setProvider(BC);
X509Certificate cert = converter.getCertificate(caBuilder.build(caSigner));
-
+
// confirm the validity of the CA certificate
cert.checkValidity(new Date());
cert.verify(cert.getPublicKey());
@@ -639,13 +639,13 @@ public class X509Utils {
if (storeFile.exists()) {
storeFile.delete();
}
-
+
// Save private key and certificate to new keystore
KeyStore store = openKeyStore(storeFile, caMetadata.password);
store.setKeyEntry(CA_ALIAS, caPair.getPrivate(), caMetadata.password.toCharArray(),
new Certificate[] { cert });
saveKeyStore(storeFile, store, caMetadata.password);
-
+
x509log.log(MessageFormat.format("New CA certificate {0,number,0} [{1}]", cert.getSerialNumber(), cert.getIssuerDN().getName()));
// update serial number in metadata object
@@ -656,11 +656,11 @@ public class X509Utils {
throw new RuntimeException("Failed to generate Gitblit CA certificate!", t);
}
}
-
+
/**
* Creates a new certificate revocation list (CRL). This function will
* destroy any existing CRL file.
- *
+ *
* @param caRevocationList
* @param storeFile
* @param keystorePassword
@@ -675,7 +675,7 @@ public class X509Utils {
X500Name issuerDN = new X500Name(PrincipalUtil.getIssuerX509Principal(caCert).getName());
X509v2CRLBuilder crlBuilder = new X509v2CRLBuilder(issuerDN, new Date());
-
+
// build and sign CRL with CA private key
ContentSigner signer = new JcaContentSignerBuilder(SIGNING_ALGORITHM).setProvider(BC).build(caPrivateKey);
X509CRLHolder crl = crlBuilder.build(signer);
@@ -703,10 +703,10 @@ public class X509Utils {
throw new RuntimeException("Failed to create new certificate revocation list " + caRevocationList, e);
}
}
-
+
/**
* Imports a certificate into the trust store.
- *
+ *
* @param alias
* @param cert
* @param storeFile
@@ -716,33 +716,33 @@ public class X509Utils {
try {
KeyStore store = openKeyStore(storeFile, storePassword);
store.setCertificateEntry(alias, cert);
- saveKeyStore(storeFile, store, storePassword);
+ saveKeyStore(storeFile, store, storePassword);
} catch (Exception e) {
throw new RuntimeException("Failed to import certificate into trust store " + storeFile, e);
}
}
-
+
/**
* Creates a new client certificate PKCS#12 and PEM store. Any existing
* stores are destroyed. After generation, the certificates are bundled
* into a zip file with a personalized README file.
- *
- * The zip file reference is returned.
- *
+ *
+ * The zip file reference is returned.
+ *
* @param clientMetadata a container for dynamic parameters needed for generation
* @param caKeystoreFile
* @param caKeystorePassword
* @param x509log
* @return a zip file containing the P12, PEM, and personalized README
*/
- public static File newClientBundle(X509Metadata clientMetadata, File caKeystoreFile,
+ public static File newClientBundle(X509Metadata clientMetadata, File caKeystoreFile,
String caKeystorePassword, X509Log x509log) {
try {
// read the Gitblit CA key and certificate
KeyStore store = openKeyStore(caKeystoreFile, caKeystorePassword);
PrivateKey caPrivateKey = (PrivateKey) store.getKey(CA_ALIAS, caKeystorePassword.toCharArray());
X509Certificate caCert = (X509Certificate) store.getCertificate(CA_ALIAS);
-
+
// generate the P12 and PEM files
File targetFolder = new File(caKeystoreFile.getParentFile(), clientMetadata.commonName);
X509Certificate cert = newClientCertificate(clientMetadata, caPrivateKey, caCert, targetFolder);
@@ -750,7 +750,7 @@ public class X509Utils {
// process template message
String readme = processTemplate(new File(caKeystoreFile.getParentFile(), "instructions.tmpl"), clientMetadata);
-
+
// Create a zip bundle with the p12, pem, and a personalized readme
File zipFile = new File(targetFolder, clientMetadata.commonName + ".zip");
if (zipFile.exists()) {
@@ -764,24 +764,24 @@ public class X509Utils {
zos.putNextEntry(new ZipEntry(p12File.getName()));
zos.write(FileUtils.readContent(p12File));
zos.closeEntry();
- }
+ }
File pemFile = new File(targetFolder, clientMetadata.commonName + ".pem");
if (pemFile.exists()) {
zos.putNextEntry(new ZipEntry(pemFile.getName()));
zos.write(FileUtils.readContent(pemFile));
zos.closeEntry();
}
-
+
// include user's public certificate
zos.putNextEntry(new ZipEntry(clientMetadata.commonName + ".cer"));
zos.write(cert.getEncoded());
zos.closeEntry();
-
+
// include CA public certificate
zos.putNextEntry(new ZipEntry("ca.cer"));
zos.write(caCert.getEncoded());
zos.closeEntry();
-
+
if (readme != null) {
zos.putNextEntry(new ZipEntry("README.TXT"));
zos.write(readme.getBytes("UTF-8"));
@@ -793,17 +793,17 @@ public class X509Utils {
zos.close();
}
}
-
+
return zipFile;
} catch (Throwable t) {
throw new RuntimeException("Failed to generate client bundle!", t);
}
}
-
+
/**
* Creates a new client certificate PKCS#12 and PEM store. Any existing
* stores are destroyed.
- *
+ *
* @param clientMetadata a container for dynamic parameters needed for generation
* @param caKeystoreFile
* @param caKeystorePassword
@@ -814,10 +814,10 @@ public class X509Utils {
PrivateKey caPrivateKey, X509Certificate caCert, File targetFolder) {
try {
KeyPair pair = newKeyPair();
-
- X500Name userDN = buildDistinguishedName(clientMetadata);
+
+ X500Name userDN = buildDistinguishedName(clientMetadata);
X500Name issuerDN = new X500Name(PrincipalUtil.getIssuerX509Principal(caCert).getName());
-
+
// create a new certificate signed by the Gitblit CA certificate
X509v3CertificateBuilder certBuilder = new JcaX509v3CertificateBuilder(
issuerDN,
@@ -826,7 +826,7 @@ public class X509Utils {
clientMetadata.notAfter,
userDN,
pair.getPublic());
-
+
JcaX509ExtensionUtils extUtils = new JcaX509ExtensionUtils();
certBuilder.addExtension(X509Extension.subjectKeyIdentifier, false, extUtils.createSubjectKeyIdentifier(pair.getPublic()));
certBuilder.addExtension(X509Extension.basicConstraints, false, new BasicConstraints(false));
@@ -844,7 +844,7 @@ public class X509Utils {
PKCS12BagAttributeCarrier bagAttr = (PKCS12BagAttributeCarrier)pair.getPrivate();
bagAttr.setBagAttribute(PKCSObjectIdentifiers.pkcs_9_at_localKeyId,
extUtils.createSubjectKeyIdentifier(pair.getPublic()));
-
+
// confirm the validity of the user certificate
userCert.checkValidity();
userCert.verify(caCert.getPublicKey());
@@ -854,7 +854,7 @@ public class X509Utils {
verifyChain(userCert, caCert);
targetFolder.mkdirs();
-
+
// save certificate, stamped with unique name
String date = new SimpleDateFormat("yyyyMMdd").format(new Date());
String id = date;
@@ -865,7 +865,7 @@ public class X509Utils {
certFile = new File(targetFolder, id + ".cer");
count++;
}
-
+
// save user private key, user certificate and CA certificate to a PKCS#12 store
File p12File = new File(targetFolder, clientMetadata.commonName + ".p12");
if (p12File.exists()) {
@@ -873,9 +873,9 @@ public class X509Utils {
}
KeyStore userStore = openKeyStore(p12File, clientMetadata.password);
userStore.setKeyEntry(MessageFormat.format("Gitblit ({0}) {1} {2}", clientMetadata.serverHostname, clientMetadata.userDisplayname, id), pair.getPrivate(), null, new Certificate [] { userCert });
- userStore.setCertificateEntry(MessageFormat.format("Gitblit ({0}) Certificate Authority", clientMetadata.serverHostname), caCert);
+ userStore.setCertificateEntry(MessageFormat.format("Gitblit ({0}) Certificate Authority", clientMetadata.serverHostname), caCert);
saveKeyStore(p12File, userStore, clientMetadata.password);
-
+
// save user private key, user certificate, and CA certificate to a PEM store
File pemFile = new File(targetFolder, clientMetadata.commonName + ".pem");
if (pemFile.exists()) {
@@ -887,22 +887,22 @@ public class X509Utils {
pemWriter.writeObject(caCert);
pemWriter.flush();
pemWriter.close();
-
+
// save certificate after successfully creating the key stores
saveCertificate(userCert, certFile);
-
+
// update serial number in metadata object
clientMetadata.serialNumber = userCert.getSerialNumber().toString();
-
+
return userCert;
} catch (Throwable t) {
throw new RuntimeException("Failed to generate client certificate!", t);
}
}
-
+
/**
* Verifies a certificate's chain to ensure that it will function properly.
- *
+ *
* @param testCert
* @param additionalCerts
* @return
@@ -913,19 +913,19 @@ public class X509Utils {
if (isSelfSigned(testCert)) {
throw new RuntimeException("The certificate is self-signed. Nothing to verify.");
}
-
+
// Prepare a set of all certificates
// chain builder must have all certs, including cert to validate
// http://stackoverflow.com/a/10788392
Set<X509Certificate> certs = new HashSet<X509Certificate>();
certs.add(testCert);
certs.addAll(Arrays.asList(additionalCerts));
-
+
// Attempt to build the certification chain and verify it
// Create the selector that specifies the starting certificate
- X509CertSelector selector = new X509CertSelector();
+ X509CertSelector selector = new X509CertSelector();
selector.setCertificate(testCert);
-
+
// Create the trust anchors (set of root CA certificates)
Set<TrustAnchor> trustAnchors = new HashSet<TrustAnchor>();
for (X509Certificate cert : additionalCerts) {
@@ -933,16 +933,16 @@ public class X509Utils {
trustAnchors.add(new TrustAnchor(cert, null));
}
}
-
+
// Configure the PKIX certificate builder
PKIXBuilderParameters pkixParams = new PKIXBuilderParameters(trustAnchors, selector);
pkixParams.setRevocationEnabled(false);
pkixParams.addCertStore(CertStore.getInstance("Collection", new CollectionCertStoreParameters(certs), BC));
-
+
// Build and verify the certification chain
CertPathBuilder builder = CertPathBuilder.getInstance("PKIX", BC);
PKIXCertPathBuilderResult verifiedCertChain = (PKIXCertPathBuilderResult) builder.build(pkixParams);
-
+
// The chain is built and verified
return verifiedCertChain;
} catch (CertPathBuilderException e) {
@@ -951,10 +951,10 @@ public class X509Utils {
throw new RuntimeException("Error verifying the certificate: " + testCert.getSubjectX500Principal(), e);
}
}
-
+
/**
* Checks whether given X.509 certificate is self-signed.
- *
+ *
* @param cert
* @return true if the certificate is self-signed
*/
@@ -970,7 +970,7 @@ public class X509Utils {
throw new RuntimeException(e);
}
}
-
+
public static String processTemplate(File template, X509Metadata metadata) {
String content = null;
if (template.exists()) {
@@ -993,10 +993,10 @@ public class X509Utils {
}
return content;
}
-
+
/**
* Revoke a certificate.
- *
+ *
* @param cert
* @param reason
* @param caRevocationList
@@ -1019,10 +1019,10 @@ public class X509Utils {
}
return false;
}
-
+
/**
* Revoke a certificate.
- *
+ *
* @param cert
* @param reason
* @param caRevocationList
@@ -1036,16 +1036,16 @@ public class X509Utils {
X500Name issuerDN = new X500Name(PrincipalUtil.getIssuerX509Principal(cert).getName());
X509v2CRLBuilder crlBuilder = new X509v2CRLBuilder(issuerDN, new Date());
if (caRevocationList.exists()) {
- byte [] data = FileUtils.readContent(caRevocationList);
+ byte [] data = FileUtils.readContent(caRevocationList);
X509CRLHolder crl = new X509CRLHolder(data);
crlBuilder.addCRL(crl);
}
crlBuilder.addCRLEntry(cert.getSerialNumber(), new Date(), reason.ordinal());
-
+
// build and sign CRL with CA private key
ContentSigner signer = new JcaContentSignerBuilder("SHA1WithRSA").setProvider(BC).build(caPrivateKey);
X509CRLHolder crl = crlBuilder.build(signer);
-
+
File tmpFile = new File(caRevocationList.getParentFile(), Long.toHexString(System.currentTimeMillis()) + ".tmp");
FileOutputStream fos = null;
try {
@@ -1057,7 +1057,7 @@ public class X509Utils {
caRevocationList.delete();
}
tmpFile.renameTo(caRevocationList);
-
+
} finally {
if (fos != null) {
fos.close();
@@ -1066,7 +1066,7 @@ public class X509Utils {
tmpFile.delete();
}
}
-
+
x509log.log(MessageFormat.format("Revoked certificate {0,number,0} reason: {1} [{2}]",
cert.getSerialNumber(), reason.toString(), cert.getSubjectDN().getName()));
return true;
@@ -1076,10 +1076,10 @@ public class X509Utils {
}
return false;
}
-
+
/**
* Returns true if the certificate has been revoked.
- *
+ *
* @param cert
* @param caRevocationList
* @return true if the certificate is revoked
@@ -1107,7 +1107,7 @@ public class X509Utils {
}
return false;
}
-
+
public static X509Metadata getMetadata(X509Certificate cert) {
// manually split DN into OID components
// this is instead of parsing with LdapName which:
@@ -1121,7 +1121,7 @@ public class X509Utils {
String data = val[1].trim();
oids.put(oid, data);
}
-
+
X509Metadata metadata = new X509Metadata(oids.get("CN"), "whocares");
metadata.oids.putAll(oids);
metadata.serialNumber = cert.getSerialNumber().toString();
diff --git a/src/main/java/com/gitblit/wicket/AuthorizationStrategy.java b/src/main/java/com/gitblit/wicket/AuthorizationStrategy.java
index e36a50e8..e3774d82 100644
--- a/src/main/java/com/gitblit/wicket/AuthorizationStrategy.java
+++ b/src/main/java/com/gitblit/wicket/AuthorizationStrategy.java
@@ -77,7 +77,7 @@ public class AuthorizationStrategy extends AbstractPageAuthorizationStrategy imp
@Override
public void onUnauthorizedInstantiation(Component component) {
-
+
if (component instanceof BasePage) {
throw new RestartResponseException(GitBlitWebApp.HOME_PAGE_CLASS);
}
diff --git a/src/main/java/com/gitblit/wicket/CacheControl.java b/src/main/java/com/gitblit/wicket/CacheControl.java
index f72fe3ae..567fb09f 100644
--- a/src/main/java/com/gitblit/wicket/CacheControl.java
+++ b/src/main/java/com/gitblit/wicket/CacheControl.java
@@ -21,20 +21,20 @@ import java.lang.annotation.RetentionPolicy;
/**
* Page attribute to control what date as last-modified for the browser cache.
- *
+ *
* http://betterexplained.com/articles/how-to-optimize-your-site-with-http-caching
* https://developers.google.com/speed/docs/best-practices/caching
- *
+ *
* @author James Moger
*
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
public @interface CacheControl {
-
+
public static enum LastModified {
BOOT, ACTIVITY, PROJECT, REPOSITORY, COMMIT, NONE
}
-
+
LastModified value() default LastModified.NONE;
} \ No newline at end of file
diff --git a/src/main/java/com/gitblit/wicket/ExternalImage.java b/src/main/java/com/gitblit/wicket/ExternalImage.java
index 33257740..34adb1ec 100644
--- a/src/main/java/com/gitblit/wicket/ExternalImage.java
+++ b/src/main/java/com/gitblit/wicket/ExternalImage.java
@@ -27,6 +27,7 @@ public class ExternalImage extends WebComponent {
super(id, new Model<String>(url));
}
+ @Override
protected void onComponentTag(ComponentTag tag) {
super.onComponentTag(tag);
checkComponentTag(tag, "img");
diff --git a/src/main/java/com/gitblit/wicket/GitBlitWebSession.java b/src/main/java/com/gitblit/wicket/GitBlitWebSession.java
index f25bcf9b..b26a1118 100644
--- a/src/main/java/com/gitblit/wicket/GitBlitWebSession.java
+++ b/src/main/java/com/gitblit/wicket/GitBlitWebSession.java
@@ -42,27 +42,28 @@ public final class GitBlitWebSession extends WebSession {
private UserModel user;
private String errorMessage;
-
+
private String requestUrl;
-
+
private AtomicBoolean isForking;
-
+
public AuthenticationType authenticationType;
-
+
public GitBlitWebSession(Request request) {
super(request);
isForking = new AtomicBoolean();
authenticationType = AuthenticationType.CREDENTIALS;
}
+ @Override
public void invalidate() {
super.invalidate();
user = null;
}
-
+
/**
* Cache the requested protected resource pending successful authentication.
- *
+ *
* @param pageClass
*/
public void cacheRequest(Class<? extends Page> pageClass) {
@@ -81,14 +82,14 @@ public final class GitBlitWebSession extends WebSession {
bind();
}
}
-
+
/**
* Continue any cached request. This is used when a request for a protected
* resource is aborted/redirected pending proper authentication. Gitblit
* no longer uses Wicket's built-in mechanism for this because of Wicket's
* failure to properly handle parameters with forward-slashes. This is a
* constant source of headaches with Wicket.
- *
+ *
* @return false if there is no cached request to process
*/
public boolean continueRequest() {
@@ -110,7 +111,7 @@ public final class GitBlitWebSession extends WebSession {
}
return user.canAdmin();
}
-
+
public String getUsername() {
return user == null ? "anonymous" : user.username;
}
@@ -150,11 +151,11 @@ public final class GitBlitWebSession extends WebSession {
errorMessage = null;
return msg;
}
-
+
public boolean isForking() {
return isForking.get();
}
-
+
public void isForking(boolean val) {
isForking.set(val);
}
diff --git a/src/main/java/com/gitblit/wicket/GitblitParamUrlCodingStrategy.java b/src/main/java/com/gitblit/wicket/GitblitParamUrlCodingStrategy.java
index fb86fb0e..2d65d37b 100644
--- a/src/main/java/com/gitblit/wicket/GitblitParamUrlCodingStrategy.java
+++ b/src/main/java/com/gitblit/wicket/GitblitParamUrlCodingStrategy.java
@@ -31,12 +31,12 @@ import com.gitblit.Keys;
/**
* Simple subclass of mixed parameter url coding strategy that works around the
* encoded forward-slash issue that is present in some servlet containers.
- *
+ *
* https://issues.apache.org/jira/browse/WICKET-1303
* http://tomcat.apache.org/security-6.html
- *
+ *
* @author James Moger
- *
+ *
*/
public class GitblitParamUrlCodingStrategy extends MixedParamUrlCodingStrategy {
@@ -44,7 +44,7 @@ public class GitblitParamUrlCodingStrategy extends MixedParamUrlCodingStrategy {
/**
* Construct.
- *
+ *
* @param <C>
* @param mountPath
* mount path (not empty)
@@ -60,11 +60,12 @@ public class GitblitParamUrlCodingStrategy extends MixedParamUrlCodingStrategy {
/**
* Url encodes a string that is mean for a URL path (e.g., between slashes)
- *
+ *
* @param string
* string to be encoded
* @return encoded string
*/
+ @Override
protected String urlEncodePathComponent(String string) {
char altChar = GitBlit.getChar(Keys.web.forwardSlashCharacter, '/');
if (altChar != '/') {
@@ -76,10 +77,11 @@ public class GitblitParamUrlCodingStrategy extends MixedParamUrlCodingStrategy {
/**
* Returns a decoded value of the given value (taken from a URL path
* section)
- *
+ *
* @param value
* @return Decodes the value
*/
+ @Override
protected String urlDecodePathComponent(String value) {
char altChar = GitBlit.getChar(Keys.web.forwardSlashCharacter, '/');
if (altChar != '/') {
@@ -90,7 +92,7 @@ public class GitblitParamUrlCodingStrategy extends MixedParamUrlCodingStrategy {
/**
* Gets the decoded request target.
- *
+ *
* @param requestParameters
* the request parameters
* @return the decoded request target
diff --git a/src/main/java/com/gitblit/wicket/GitblitRedirectException.java b/src/main/java/com/gitblit/wicket/GitblitRedirectException.java
index c3df1ac1..4721f0ad 100644
--- a/src/main/java/com/gitblit/wicket/GitblitRedirectException.java
+++ b/src/main/java/com/gitblit/wicket/GitblitRedirectException.java
@@ -26,9 +26,9 @@ import org.apache.wicket.request.target.basic.RedirectRequestTarget;
* This exception bypasses the servlet container rewriting relative redirect
* urls. The container can and does decode the carefully crafted %2F path
* separators on a redirect. :( Bad, bad servlet container.
- *
+ *
* org.eclipse.jetty.server.Response#L447: String path=uri.getDecodedPath();
- *
+ *
* @author James Moger
*/
public class GitblitRedirectException extends AbstractRestartResponseException {
diff --git a/src/main/java/com/gitblit/wicket/GitblitWicketFilter.java b/src/main/java/com/gitblit/wicket/GitblitWicketFilter.java
index f46c51ea..0f639c74 100644
--- a/src/main/java/com/gitblit/wicket/GitblitWicketFilter.java
+++ b/src/main/java/com/gitblit/wicket/GitblitWicketFilter.java
@@ -32,21 +32,22 @@ import com.gitblit.utils.JGitUtils;
import com.gitblit.utils.StringUtils;
/**
- *
+ *
* Customization of the WicketFilter to allow smart browser-side caching of
* some pages.
- *
+ *
* @author James Moger
*
*/
public class GitblitWicketFilter extends WicketFilter {
-
+
/**
* Determines the last-modified date of the requested resource.
- *
+ *
* @param servletRequest
* @return The last modified time stamp
*/
+ @Override
protected long getLastModified(final HttpServletRequest servletRequest) {
final String pathInfo = getRelativePath(servletRequest);
if (Strings.isEmpty(pathInfo))
@@ -55,10 +56,10 @@ public class GitblitWicketFilter extends WicketFilter {
if (lastModified > -1) {
return lastModified;
}
-
+
// try to match request against registered CacheControl pages
String [] paths = pathInfo.split("/");
-
+
String page = paths[0];
String repo = "";
String commitId = "";
@@ -68,14 +69,14 @@ public class GitblitWicketFilter extends WicketFilter {
if (paths.length >= 3) {
commitId = paths[2];
}
-
+
if (!StringUtils.isEmpty(servletRequest.getParameter("r"))) {
repo = servletRequest.getParameter("r");
}
if (!StringUtils.isEmpty(servletRequest.getParameter("h"))) {
commitId = servletRequest.getParameter("h");
}
-
+
repo = repo.replace("%2f", "/").replace("%2F", "/").replace(GitBlit.getChar(Keys.web.forwardSlashCharacter, '/'), '/');
GitBlitWebApp app = (GitBlitWebApp) getWebApplication();
@@ -116,7 +117,7 @@ public class GitblitWicketFilter extends WicketFilter {
// no commit id, use boot date
return bootDate.getTime();
} else {
- // last modified date is the commit date
+ // last modified date is the commit date
Repository r = null;
try {
// return the timestamp of the associated commit
@@ -138,7 +139,7 @@ public class GitblitWicketFilter extends WicketFilter {
default:
break;
}
- }
+ }
return -1;
}
diff --git a/src/main/java/com/gitblit/wicket/PageRegistration.java b/src/main/java/com/gitblit/wicket/PageRegistration.java
index b0cb4705..1b98f2c7 100644
--- a/src/main/java/com/gitblit/wicket/PageRegistration.java
+++ b/src/main/java/com/gitblit/wicket/PageRegistration.java
@@ -26,9 +26,9 @@ import com.gitblit.utils.StringUtils;
/**
* Represents a page link registration for the topbar.
- *
+ *
* @author James Moger
- *
+ *
*/
public class PageRegistration implements Serializable {
private static final long serialVersionUID = 1L;
@@ -46,7 +46,7 @@ public class PageRegistration implements Serializable {
PageParameters params) {
this(translationKey, pageClass, params, false);
}
-
+
public PageRegistration(String translationKey, Class<? extends WebPage> pageClass,
PageParameters params, boolean hiddenPhone) {
this.translationKey = translationKey;
@@ -57,9 +57,9 @@ public class PageRegistration implements Serializable {
/**
* Represents a page link to a non-Wicket page. Might be external.
- *
+ *
* @author James Moger
- *
+ *
*/
public static class OtherPageLink extends PageRegistration {
@@ -71,7 +71,7 @@ public class PageRegistration implements Serializable {
super(translationKey, null);
this.url = url;
}
-
+
public OtherPageLink(String translationKey, String url, boolean hiddenPhone) {
super(translationKey, null, null, hiddenPhone);
this.url = url;
@@ -80,9 +80,9 @@ public class PageRegistration implements Serializable {
/**
* Represents a DropDownMenu for the topbar
- *
+ *
* @author James Moger
- *
+ *
*/
public static class DropDownMenuRegistration extends PageRegistration {
@@ -98,9 +98,9 @@ public class PageRegistration implements Serializable {
/**
* A MenuItem for the DropDownMenu.
- *
+ *
* @author James Moger
- *
+ *
*/
public static class DropDownMenuItem implements Serializable {
@@ -121,7 +121,7 @@ public class PageRegistration implements Serializable {
/**
* Standard Menu Item constructor.
- *
+ *
* @param displayText
* @param parameter
* @param value
@@ -132,7 +132,7 @@ public class PageRegistration implements Serializable {
/**
* Standard Menu Item constructor that preserves aggregate parameters.
- *
+ *
* @param displayText
* @param parameter
* @param value
@@ -219,14 +219,14 @@ public class PageRegistration implements Serializable {
return displayText;
}
}
-
+
public static class DropDownToggleItem extends DropDownMenuItem {
-
+
private static final long serialVersionUID = 1L;
/**
* Toggle Menu Item constructor that preserves aggregate parameters.
- *
+ *
* @param displayText
* @param parameter
* @param value
diff --git a/src/main/java/com/gitblit/wicket/SessionlessForm.java b/src/main/java/com/gitblit/wicket/SessionlessForm.java
index 484e85e3..d228a2e1 100644
--- a/src/main/java/com/gitblit/wicket/SessionlessForm.java
+++ b/src/main/java/com/gitblit/wicket/SessionlessForm.java
@@ -35,35 +35,35 @@ import com.gitblit.wicket.pages.BasePage;
* This class is used to create a stateless form that can POST or GET to a
* bookmarkable page regardless of the pagemap and even after session expiration
* or a server restart.
- *
+ *
* The trick is to embed "wicket:bookmarkablePage" as a hidden field of the form.
* Wicket already has logic to extract this parameter when it is trying
* to determine which page should receive the request.
- *
+ *
* The parameters of the containing page can optionally be included as hidden
- * fields in this form. Note that if a page parameter's name collides with any
+ * fields in this form. Note that if a page parameter's name collides with any
* child's wicket:id in this form then the page parameter is excluded.
- *
+ *
* @author James Moger
*
*/
public class SessionlessForm<T> extends StatelessForm<T> {
-
+
private static final long serialVersionUID = 1L;
private static final String HIDDEN_DIV_START = "<div style=\"width:0px;height:0px;position:absolute;left:-100px;top:-100px;overflow:hidden\">";
-
+
private final Class<? extends BasePage> pageClass;
-
+
private final PageParameters pageParameters;
-
+
private final Logger log = LoggerFactory.getLogger(SessionlessForm.class);
/**
* Sessionless forms must have a bookmarkable page class. A bookmarkable
* page is defined as a page that has only a default and/or a PageParameter
* constructor.
- *
+ *
* @param id
* @param bookmarkablePageClass
*/
@@ -75,7 +75,7 @@ public class SessionlessForm<T> extends StatelessForm<T> {
* Sessionless forms must have a bookmarkable page class. A bookmarkable
* page is defined as a page that has only a default and/or a PageParameter
* constructor.
- *
+ *
* @param id
* @param bookmarkablePageClass
* @param pageParameters
@@ -87,12 +87,12 @@ public class SessionlessForm<T> extends StatelessForm<T> {
this.pageParameters = pageParameters;
}
-
+
/**
* Append an additional hidden input tag that forces Wicket to correctly
* determine the destination page class even after a session expiration or
* a server restart.
- *
+ *
* @param markupStream
* The markup stream
* @param openTag
@@ -133,10 +133,10 @@ public class SessionlessForm<T> extends StatelessForm<T> {
getResponse().write(buffer);
super.onComponentTagBody(markupStream, openTag);
}
-
+
/**
* Take URL-encoded query string value, unencode it and return HTML-escaped version
- *
+ *
* @param s
* value to reencode
* @return reencoded value
diff --git a/src/main/java/com/gitblit/wicket/StringChoiceRenderer.java b/src/main/java/com/gitblit/wicket/StringChoiceRenderer.java
index 58ed4798..cd26965b 100644
--- a/src/main/java/com/gitblit/wicket/StringChoiceRenderer.java
+++ b/src/main/java/com/gitblit/wicket/StringChoiceRenderer.java
@@ -20,14 +20,14 @@ import org.apache.wicket.markup.html.form.ChoiceRenderer;
/**
* Choice renderer for a palette or list of string values. This renderer
* controls the id value of each option such that palettes are case insensitive.
- *
+ *
* @author James Moger
*
*/
public class StringChoiceRenderer extends ChoiceRenderer<String> {
private static final long serialVersionUID = 1L;
-
+
public StringChoiceRenderer() {
super("", "");
}
diff --git a/src/main/java/com/gitblit/wicket/WicketUtils.java b/src/main/java/com/gitblit/wicket/WicketUtils.java
index 48bcbcc9..a2522ef5 100644
--- a/src/main/java/com/gitblit/wicket/WicketUtils.java
+++ b/src/main/java/com/gitblit/wicket/WicketUtils.java
@@ -115,7 +115,7 @@ public class WicketUtils {
default:
setCssClass(container, "badge");
break;
- }
+ }
}
public static void setAlternatingBackground(Component c, int i) {
@@ -232,17 +232,17 @@ public class WicketUtils {
public static Label newIcon(String wicketId, String css) {
Label lbl = new Label(wicketId);
- setCssClass(lbl, css);
+ setCssClass(lbl, css);
return lbl;
}
-
+
public static Label newBlankIcon(String wicketId) {
Label lbl = new Label(wicketId);
setCssClass(lbl, "");
lbl.setRenderBodyOnly(true);
return lbl;
}
-
+
public static ContextRelativeResource getResource(String file) {
return new ContextRelativeResource(file);
}
@@ -257,6 +257,7 @@ public class WicketUtils {
return new HeaderContributor(new IHeaderContributor() {
private static final long serialVersionUID = 1L;
+ @Override
public void renderHead(IHeaderResponse response) {
String contentType = "application/rss+xml";
@@ -509,7 +510,7 @@ public class WicketUtils {
public static Label createDateLabel(String wicketId, Date date, TimeZone timeZone, TimeUtils timeUtils) {
return createDateLabel(wicketId, date, timeZone, timeUtils, true);
}
-
+
public static Label createDateLabel(String wicketId, Date date, TimeZone timeZone, TimeUtils timeUtils, boolean setCss) {
String format = GitBlit.getString(Keys.web.datestampShortFormat, "MM/dd/yy");
DateFormat df = new SimpleDateFormat(format);
@@ -642,6 +643,7 @@ public class WicketUtils {
IChartData data = new AbstractChartData(max) {
private static final long serialVersionUID = 1L;
+ @Override
public double[][] getData() {
return new double[][] { commits, tags };
}
@@ -677,6 +679,7 @@ public class WicketUtils {
IChartData data = new AbstractChartData(max) {
private static final long serialVersionUID = 1L;
+ @Override
public double[][] getData() {
return new double[][] { x, y };
}
diff --git a/src/main/java/com/gitblit/wicket/charting/GoogleChart.java b/src/main/java/com/gitblit/wicket/charting/GoogleChart.java
index 334b870d..a7188352 100644
--- a/src/main/java/com/gitblit/wicket/charting/GoogleChart.java
+++ b/src/main/java/com/gitblit/wicket/charting/GoogleChart.java
@@ -23,9 +23,9 @@ import com.gitblit.utils.StringUtils;
/**
* Abstract parent class for Google Charts built with the Visualization API.
- *
+ *
* @author James Moger
- *
+ *
*/
public abstract class GoogleChart implements Serializable {
@@ -57,7 +57,7 @@ public abstract class GoogleChart implements Serializable {
public void setHeight(int height) {
this.height = height;
}
-
+
public void setShowLegend(boolean val) {
this.showLegend = val;
}
diff --git a/src/main/java/com/gitblit/wicket/charting/GoogleCharts.java b/src/main/java/com/gitblit/wicket/charting/GoogleCharts.java
index 77c522b5..8b727936 100644
--- a/src/main/java/com/gitblit/wicket/charting/GoogleCharts.java
+++ b/src/main/java/com/gitblit/wicket/charting/GoogleCharts.java
@@ -13,7 +13,6 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
-
package com.gitblit.wicket.charting;
import java.util.ArrayList;
@@ -26,9 +25,9 @@ import org.apache.wicket.markup.html.IHeaderResponse;
* The Google Visualization API provides interactive JavaScript based charts and
* graphs. This class implements the JavaScript header necessary to display
* complete graphs and charts.
- *
+ *
* @author James Moger
- *
+ *
*/
public class GoogleCharts implements IHeaderContributor {
diff --git a/src/main/java/com/gitblit/wicket/charting/GoogleLineChart.java b/src/main/java/com/gitblit/wicket/charting/GoogleLineChart.java
index fc0bf837..ca894777 100644
--- a/src/main/java/com/gitblit/wicket/charting/GoogleLineChart.java
+++ b/src/main/java/com/gitblit/wicket/charting/GoogleLineChart.java
@@ -19,9 +19,9 @@ import java.text.MessageFormat;
/**
* Builds an interactive line chart using the Visualization API.
- *
+ *
* @author James Moger
- *
+ *
*/
public class GoogleLineChart extends GoogleChart {
diff --git a/src/main/java/com/gitblit/wicket/charting/GooglePieChart.java b/src/main/java/com/gitblit/wicket/charting/GooglePieChart.java
index 1f5ae706..546a2a9b 100644
--- a/src/main/java/com/gitblit/wicket/charting/GooglePieChart.java
+++ b/src/main/java/com/gitblit/wicket/charting/GooglePieChart.java
@@ -24,9 +24,9 @@ import com.gitblit.utils.StringUtils;
/**
* Builds an interactive pie chart using the Visualization API.
- *
+ *
* @author James Moger
- *
+ *
*/
public class GooglePieChart extends GoogleChart {
@@ -47,15 +47,15 @@ public class GooglePieChart extends GoogleChart {
Collections.sort(values);
List<ChartValue> list = new ArrayList<ChartValue>();
-
+
int maxSlices = 10;
-
+
if (values.size() > maxSlices) {
list.addAll(values.subList(0, maxSlices));
} else {
list.addAll(values);
}
-
+
StringBuilder colors = new StringBuilder("colors:[");
for (int i = 0; i < list.size(); i++) {
ChartValue value = list.get(i);
diff --git a/src/main/java/com/gitblit/wicket/charting/SecureChart.java b/src/main/java/com/gitblit/wicket/charting/SecureChart.java
index 60dae4b4..aba25c40 100644
--- a/src/main/java/com/gitblit/wicket/charting/SecureChart.java
+++ b/src/main/java/com/gitblit/wicket/charting/SecureChart.java
@@ -43,7 +43,7 @@ import org.wicketstuff.googlecharts.Range;
/**
* This is a fork of org.wicketstuff.googlecharts.Chart whose only purpose
* is to build https urls instead of http urls.
- *
+ *
* @author Daniel Spiewak
* @author James Moger
*/
@@ -140,7 +140,7 @@ public class SecureChart extends WebComponent implements Serializable {
url.append(param).append('=').append(value);
}
-
+
private CharSequence convert(ChartDataEncoding encoding, double value, double max) {
switch (encoding) {
case TEXT:
diff --git a/src/main/java/com/gitblit/wicket/charting/SecureChartDataEncoding.java b/src/main/java/com/gitblit/wicket/charting/SecureChartDataEncoding.java
index 90a05964..c5ac4608 100644
--- a/src/main/java/com/gitblit/wicket/charting/SecureChartDataEncoding.java
+++ b/src/main/java/com/gitblit/wicket/charting/SecureChartDataEncoding.java
@@ -19,14 +19,15 @@ package com.gitblit.wicket.charting;
/**
* This class is a pristine fork of org.wicketstuff.googlecharts.ChartDataEncoding
* to bring the package-protected convert methods to SecureChart.
- *
+ *
* @author Daniel Spiewak
*/
public enum SecureChartDataEncoding {
SIMPLE("s", "", ",") {
- CharSequence convert(double value, double max) {
+ @Override
+ CharSequence convert(double value, double max) {
if (value < 0) {
return "_";
}
@@ -42,7 +43,8 @@ public enum SecureChartDataEncoding {
},
TEXT("t", ",", "|") {
- CharSequence convert(double value, double max) {
+ @Override
+ CharSequence convert(double value, double max) {
if (value < 0) {
value = -1;
}
@@ -56,7 +58,8 @@ public enum SecureChartDataEncoding {
},
EXTENDED("e", "", ",") {
- CharSequence convert(double value, double max) {
+ @Override
+ CharSequence convert(double value, double max) {
if (value < 0) {
return "__";
}
diff --git a/src/main/java/com/gitblit/wicket/freemarker/Freemarker.java b/src/main/java/com/gitblit/wicket/freemarker/Freemarker.java
index ad7aa964..a9b827aa 100644
--- a/src/main/java/com/gitblit/wicket/freemarker/Freemarker.java
+++ b/src/main/java/com/gitblit/wicket/freemarker/Freemarker.java
@@ -27,18 +27,18 @@ import freemarker.template.TemplateException;
public class Freemarker {
private static final Configuration fm;
-
+
static {
fm = new Configuration();
fm.setObjectWrapper(new DefaultObjectWrapper());
fm.setOutputEncoding("UTF-8");
fm.setClassForTemplateLoading(Freemarker.class, "templates");
}
-
+
public static Template getTemplate(String name) throws IOException {
return fm.getTemplate(name);
}
-
+
public static void evaluate(Template template, Map<String, Object> values, Writer out) throws TemplateException, IOException {
template.process(values, out);
}
diff --git a/src/main/java/com/gitblit/wicket/freemarker/FreemarkerPanel.java b/src/main/java/com/gitblit/wicket/freemarker/FreemarkerPanel.java
index d57c3a09..aaf1a135 100644
--- a/src/main/java/com/gitblit/wicket/freemarker/FreemarkerPanel.java
+++ b/src/main/java/com/gitblit/wicket/freemarker/FreemarkerPanel.java
@@ -43,9 +43,9 @@ import freemarker.template.TemplateException;
* snippet injector for something like a CMS. There are some cases where Wicket
* is not flexible enough to generate content, especially when you need to generate
* hybrid HTML/JS content outside the scope of Wicket.
- *
+ *
* @author James Moger
- *
+ *
*/
@SuppressWarnings("unchecked")
public class FreemarkerPanel extends Panel
@@ -62,10 +62,10 @@ public class FreemarkerPanel extends Panel
private transient String stackTraceAsString;
private transient String evaluatedTemplate;
-
+
/**
* Construct.
- *
+ *
* @param id
* Component id
* @param template
@@ -77,10 +77,10 @@ public class FreemarkerPanel extends Panel
{
this(id, template, Model.ofMap(values));
}
-
+
/**
* Construct.
- *
+ *
* @param id
* Component id
* @param templateResource
@@ -96,7 +96,7 @@ public class FreemarkerPanel extends Panel
/**
* Gets the Freemarker template.
- *
+ *
* @return the Freemarker template
*/
private Template getTemplate()
@@ -155,7 +155,7 @@ public class FreemarkerPanel extends Panel
/**
* Either print or rethrow the throwable.
- *
+ *
* @param exception
* the cause
* @param markupStream
@@ -179,7 +179,7 @@ public class FreemarkerPanel extends Panel
/**
* Gets whether to escape HTML characters.
- *
+ *
* @return whether to escape HTML characters. The default value is false.
*/
public void setEscapeHtml(boolean value)
@@ -189,7 +189,7 @@ public class FreemarkerPanel extends Panel
/**
* Evaluates the template and returns the result.
- *
+ *
* @param templateReader
* used to read the template
* @return the result of evaluating the velocity template
@@ -237,7 +237,7 @@ public class FreemarkerPanel extends Panel
/**
* Gets whether to parse the resulting Wicket markup.
- *
+ *
* @return whether to parse the resulting Wicket markup. The default is false.
*/
public void setParseGeneratedMarkup(boolean value)
@@ -256,7 +256,7 @@ public class FreemarkerPanel extends Panel
* want them to be able to have them correct them while the rest of the application keeps on
* working.
* </p>
- *
+ *
* @return Whether any Freemarker exceptions should be thrown or trapped. The default is false.
*/
public void setThrowFreemarkerExceptions(boolean value)
@@ -268,6 +268,7 @@ public class FreemarkerPanel extends Panel
* @see org.apache.wicket.markup.IMarkupResourceStreamProvider#getMarkupResourceStream(org.apache
* .wicket.MarkupContainer, java.lang.Class)
*/
+ @Override
public final IResourceStream getMarkupResourceStream(MarkupContainer container,
Class< ? > containerClass)
{
@@ -289,6 +290,7 @@ public class FreemarkerPanel extends Panel
* @see org.apache.wicket.markup.IMarkupCacheKeyProvider#getCacheKey(org.apache.wicket.
* MarkupContainer, java.lang.Class)
*/
+ @Override
public final String getCacheKey(MarkupContainer container, Class< ? > containerClass)
{
// don't cache the evaluated template
diff --git a/src/main/java/com/gitblit/wicket/ng/NgController.java b/src/main/java/com/gitblit/wicket/ng/NgController.java
index 628c0b6e..19e419a0 100644
--- a/src/main/java/com/gitblit/wicket/ng/NgController.java
+++ b/src/main/java/com/gitblit/wicket/ng/NgController.java
@@ -13,7 +13,6 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
-
package com.gitblit.wicket.ng;
import java.text.MessageFormat;
@@ -31,23 +30,23 @@ import com.google.gson.GsonBuilder;
* Simple AngularJS data controller which injects scoped objects as static,
* embedded JSON within the generated page. This allows use of AngularJS
* client-side databinding (magic) with server-generated pages.
- *
+ *
* @author James Moger
- *
+ *
*/
public class NgController implements IHeaderContributor {
private static final long serialVersionUID = 1L;
-
+
final String name;
-
+
final Map<String, Object> variables;
-
+
public NgController(String name) {
this.name = name;
this.variables = new HashMap<String, Object>();
}
-
+
public void addVariable(String name, Object o) {
variables.put(name, o);
}
@@ -69,7 +68,7 @@ public class NgController implements IHeaderContributor {
line(sb, MessageFormat.format("\t$scope.{0} = {1};", var, json));
}
line(sb, "}");
-
+
response.renderJavascript(sb.toString(), null);
}
diff --git a/src/main/java/com/gitblit/wicket/pages/ActivityPage.java b/src/main/java/com/gitblit/wicket/pages/ActivityPage.java
index a436813e..7e347e18 100644
--- a/src/main/java/com/gitblit/wicket/pages/ActivityPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/ActivityPage.java
@@ -51,9 +51,9 @@ import com.gitblit.wicket.panels.ActivityPanel;
/**
* Activity Page shows a list of recent commits across all visible Gitblit
* repositories.
- *
+ *
* @author James Moger
- *
+ *
*/
@CacheControl(LastModified.ACTIVITY)
@@ -72,7 +72,7 @@ public class ActivityPage extends RootPage {
// determine repositories to view and retrieve the activity
List<RepositoryModel> models = getRepositories(params);
- List<Activity> recentActivity = ActivityUtils.getRecentActivity(models,
+ List<Activity> recentActivity = ActivityUtils.getRecentActivity(models,
daysBack, objectId, getTimeZone());
String headerPattern;
@@ -91,7 +91,7 @@ public class ActivityPage extends RootPage {
headerPattern = getString("gb.recentActivityStats");
}
}
-
+
if (recentActivity.size() == 0) {
// no activity, skip graphs and activity panel
add(new Label("subheader", MessageFormat.format(headerPattern,
@@ -157,7 +157,7 @@ public class ActivityPage extends RootPage {
/**
* Creates the daily activity line chart, the active repositories pie chart,
* and the active authors pie chart
- *
+ *
* @param recentActivity
* @return
*/
diff --git a/src/main/java/com/gitblit/wicket/pages/BasePage.java b/src/main/java/com/gitblit/wicket/pages/BasePage.java
index 2bab1183..cb9de9fa 100644
--- a/src/main/java/com/gitblit/wicket/pages/BasePage.java
+++ b/src/main/java/com/gitblit/wicket/pages/BasePage.java
@@ -67,7 +67,7 @@ import com.gitblit.wicket.WicketUtils;
public abstract class BasePage extends SessionPage {
private final Logger logger;
-
+
private transient TimeUtils timeUtils;
public BasePage() {
@@ -81,24 +81,24 @@ public abstract class BasePage extends SessionPage {
logger = LoggerFactory.getLogger(getClass());
customizeHeader();
}
-
+
private void customizeHeader() {
if (GitBlit.getBoolean(Keys.web.useResponsiveLayout, true)) {
add(CSSPackageResource.getHeaderContribution("bootstrap/css/bootstrap-responsive.css"));
}
}
-
+
protected String getLanguageCode() {
return GitBlitWebSession.get().getLocale().getLanguage();
}
-
+
protected String getCountryCode() {
return GitBlitWebSession.get().getLocale().getCountry().toLowerCase();
}
-
+
protected TimeUtils getTimeUtils() {
if (timeUtils == null) {
- ResourceBundle bundle;
+ ResourceBundle bundle;
try {
bundle = ResourceBundle.getBundle("com.gitblit.wicket.GitBlitWebApp", GitBlitWebSession.get().getLocale());
} catch (Throwable t) {
@@ -108,7 +108,7 @@ public abstract class BasePage extends SessionPage {
}
return timeUtils;
}
-
+
@Override
protected void onBeforeRender() {
if (GitBlit.isDebugMode()) {
@@ -126,7 +126,7 @@ public abstract class BasePage extends SessionPage {
}
super.onAfterRender();
}
-
+
@Override
protected void setHeaders(WebResponse response) {
int expires = GitBlit.getInteger(Keys.web.pageCacheExpires, 0);
@@ -140,11 +140,11 @@ public abstract class BasePage extends SessionPage {
super.setHeaders(response);
}
}
-
+
/**
* Sets the last-modified header date, if appropriate, for this page. The
* date used is determined by the CacheControl annotation.
- *
+ *
*/
protected void setLastModified() {
if (getClass().isAnnotationPresent(CacheControl.class)) {
@@ -164,24 +164,24 @@ public abstract class BasePage extends SessionPage {
}
}
}
-
+
/**
* Sets the last-modified header field and the expires field.
- *
+ *
* @param when
*/
protected final void setLastModified(Date when) {
if (when == null) {
return;
}
-
+
if (when.before(GitBlit.getBootDate())) {
// last-modified can not be before the Gitblit boot date
// this helps ensure that pages are properly refreshed after a
// server config change
when = GitBlit.getBootDate();
}
-
+
int expires = GitBlit.getInteger(Keys.web.pageCacheExpires, 0);
WebResponse response = (WebResponse) getResponse();
response.setLastModifiedTime(Time.valueOf(when));
@@ -232,7 +232,7 @@ public abstract class BasePage extends SessionPage {
}
return map;
}
-
+
protected Map<AccessPermission, String> getAccessPermissions() {
Map<AccessPermission, String> map = new LinkedHashMap<AccessPermission, String>();
for (AccessPermission type : AccessPermission.values()) {
@@ -265,7 +265,7 @@ public abstract class BasePage extends SessionPage {
}
return map;
}
-
+
protected Map<FederationStrategy, String> getFederationTypes() {
Map<FederationStrategy, String> map = new LinkedHashMap<FederationStrategy, String>();
for (FederationStrategy type : FederationStrategy.values()) {
@@ -283,7 +283,7 @@ public abstract class BasePage extends SessionPage {
}
return map;
}
-
+
protected Map<AuthorizationControl, String> getAuthorizationControls() {
Map<AuthorizationControl, String> map = new LinkedHashMap<AuthorizationControl, String>();
for (AuthorizationControl type : AuthorizationControl.values()) {
@@ -309,13 +309,13 @@ public abstract class BasePage extends SessionPage {
HttpServletRequest req = servletWebRequest.getHttpServletRequest();
return req.getServerName();
}
-
+
protected List<ProjectModel> getProjectModels() {
final UserModel user = GitBlitWebSession.get().getUser();
List<ProjectModel> projects = GitBlit.self().getProjectModels(user, true);
return projects;
}
-
+
protected List<ProjectModel> getProjects(PageParameters params) {
if (params == null) {
return getProjectModels();
@@ -400,7 +400,7 @@ public abstract class BasePage extends SessionPage {
public void warn(String message, Throwable t) {
logger.warn(message, t);
}
-
+
public void error(String message, boolean redirect) {
error(message, null, redirect ? getApplication().getHomePage() : null);
}
@@ -408,11 +408,11 @@ public abstract class BasePage extends SessionPage {
public void error(String message, Throwable t, boolean redirect) {
error(message, t, getApplication().getHomePage());
}
-
+
public void error(String message, Throwable t, Class<? extends Page> toPage) {
error(message, t, toPage, null);
}
-
+
public void error(String message, Throwable t, Class<? extends Page> toPage, PageParameters params) {
if (t == null) {
logger.error(message + " for " + GitBlitWebSession.get().getUsername());
diff --git a/src/main/java/com/gitblit/wicket/pages/BlamePage.java b/src/main/java/com/gitblit/wicket/pages/BlamePage.java
index 53bd233d..9f00d212 100644
--- a/src/main/java/com/gitblit/wicket/pages/BlamePage.java
+++ b/src/main/java/com/gitblit/wicket/pages/BlamePage.java
@@ -75,7 +75,7 @@ public class BlamePage extends RepositoryPage {
"EEEE, MMMM d, yyyy HH:mm Z");
final DateFormat df = new SimpleDateFormat(format);
df.setTimeZone(getTimeZone());
-
+
PathModel pathModel = null;
List<PathModel> paths = JGitUtils.getFilesInPath(getRepository(), StringUtils.getRootPath(blobPath), commit);
for (PathModel path : paths) {
@@ -84,15 +84,15 @@ public class BlamePage extends RepositoryPage {
break;
}
}
-
+
if (pathModel == null) {
add(new Label("annotation").setVisible(false));
add(new Label("missingBlob", missingBlob(blobPath, commit)).setEscapeModelStrings(false));
return;
}
-
+
add(new Label("missingBlob").setVisible(false));
-
+
List<AnnotatedLine> lines = DiffUtils.blame(getRepository(), blobPath, objectId);
ListDataProvider<AnnotatedLine> blameDp = new ListDataProvider<AnnotatedLine>(lines);
DataView<AnnotatedLine> blameView = new DataView<AnnotatedLine>("annotation", blameDp) {
@@ -102,6 +102,7 @@ public class BlamePage extends RepositoryPage {
private boolean showInitials = true;
private String zeroId = ObjectId.zeroId().getName();
+ @Override
public void populateItem(final Item<AnnotatedLine> item) {
AnnotatedLine entry = item.getModelObject();
item.add(new Label("line", "" + entry.lineNumber));
@@ -157,12 +158,12 @@ public class BlamePage extends RepositoryPage {
protected String getPageName() {
return getString("gb.blame");
}
-
+
@Override
protected Class<? extends BasePage> getRepoNavPageClass() {
return TreePage.class;
}
-
+
protected String missingBlob(String blobPath, RevCommit commit) {
StringBuilder sb = new StringBuilder();
sb.append("<div class=\"alert alert-error\">");
diff --git a/src/main/java/com/gitblit/wicket/pages/BlobDiffPage.java b/src/main/java/com/gitblit/wicket/pages/BlobDiffPage.java
index f8f88188..27678ecd 100644
--- a/src/main/java/com/gitblit/wicket/pages/BlobDiffPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/BlobDiffPage.java
@@ -80,7 +80,7 @@ public class BlobDiffPage extends RepositoryPage {
protected String getPageName() {
return getString("gb.diff");
}
-
+
@Override
protected Class<? extends BasePage> getRepoNavPageClass() {
return TreePage.class;
diff --git a/src/main/java/com/gitblit/wicket/pages/BlobPage.java b/src/main/java/com/gitblit/wicket/pages/BlobPage.java
index b9f64304..0c93d48c 100644
--- a/src/main/java/com/gitblit/wicket/pages/BlobPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/BlobPage.java
@@ -33,9 +33,9 @@ import com.gitblit.Keys;
import com.gitblit.utils.JGitUtils;
import com.gitblit.utils.StringUtils;
import com.gitblit.wicket.CacheControl;
+import com.gitblit.wicket.CacheControl.LastModified;
import com.gitblit.wicket.ExternalImage;
import com.gitblit.wicket.WicketUtils;
-import com.gitblit.wicket.CacheControl.LastModified;
import com.gitblit.wicket.panels.CommitHeaderPanel;
import com.gitblit.wicket.panels.PathBreadcrumbsPanel;
@@ -50,7 +50,7 @@ public class BlobPage extends RepositoryPage {
Repository r = getRepository();
final String blobPath = WicketUtils.getPath(params);
String [] encodings = GitBlit.getEncodings();
-
+
if (StringUtils.isEmpty(blobPath)) {
// blob by objectid
@@ -153,7 +153,7 @@ public class BlobPage extends RepositoryPage {
}
}
}
-
+
protected String missingBlob(String blobPath, RevCommit commit) {
StringBuilder sb = new StringBuilder();
sb.append("<div class=\"alert alert-error\">");
@@ -165,11 +165,11 @@ public class BlobPage extends RepositoryPage {
protected String generateSourceView(String source, String extension, boolean prettyPrint) {
String [] lines = source.split("\n");
-
+
StringBuilder sb = new StringBuilder();
sb.append("<!-- start blob table -->");
sb.append("<table width=\"100%\"><tbody><tr>");
-
+
// nums column
sb.append("<!-- start nums column -->");
sb.append("<td id=\"nums\">");
@@ -181,7 +181,7 @@ public class BlobPage extends RepositoryPage {
sb.append("</pre>");
sb.append("<!-- end nums column -->");
sb.append("</td>");
-
+
sb.append("<!-- start lines column -->");
sb.append("<td id=\"lines\">");
sb.append("<div class=\"sourceview\">");
@@ -191,9 +191,9 @@ public class BlobPage extends RepositoryPage {
sb.append("<pre class=\"plainprint\">");
}
lines = StringUtils.escapeForHtml(source, true).split("\n");
-
+
sb.append("<table width=\"100%\"><tbody>");
-
+
String linePattern = "<tr class=\"{0}\"><td><div><span class=\"line\">{1}</span></div>\r</tr>";
for (int i = 0; i < lines.length; i++) {
String line = lines[i].replace('\r', ' ');
@@ -208,10 +208,10 @@ public class BlobPage extends RepositoryPage {
sb.append("</div>");
sb.append("</td>");
sb.append("<!-- end lines column -->");
-
+
sb.append("</tr></tbody></table>");
sb.append("<!-- end blob table -->");
-
+
return sb.toString();
}
@@ -219,7 +219,7 @@ public class BlobPage extends RepositoryPage {
protected String getPageName() {
return getString("gb.view");
}
-
+
@Override
protected Class<? extends BasePage> getRepoNavPageClass() {
return TreePage.class;
diff --git a/src/main/java/com/gitblit/wicket/pages/ChangePasswordPage.java b/src/main/java/com/gitblit/wicket/pages/ChangePasswordPage.java
index c4014208..302de0da 100644
--- a/src/main/java/com/gitblit/wicket/pages/ChangePasswordPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/ChangePasswordPage.java
@@ -50,13 +50,13 @@ public class ChangePasswordPage extends RootSubPage {
// no authentication enabled
throw new RestartResponseException(getApplication().getHomePage());
}
-
- UserModel user = GitBlitWebSession.get().getUser();
+
+ UserModel user = GitBlitWebSession.get().getUser();
if (!GitBlit.self().supportsCredentialChanges(user)) {
error(MessageFormat.format(getString("gb.userServiceDoesNotPermitPasswordChanges"),
GitBlit.getString(Keys.realm.userService, "${baseFolder}/users.conf")), true);
}
-
+
setupPage(getString("gb.changePassword"), user.username);
StatelessForm<Void> form = new StatelessForm<Void>("passwordForm") {
diff --git a/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java b/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java
index 3bd759dc..7ad6615b 100644
--- a/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java
@@ -99,6 +99,7 @@ public class CommitDiffPage extends RepositoryPage {
DataView<GitNote> notesView = new DataView<GitNote>("notes", notesDp) {
private static final long serialVersionUID = 1L;
+ @Override
public void populateItem(final Item<GitNote> item) {
GitNote entry = item.getModelObject();
item.add(new RefsPanel("refName", repositoryName, Arrays.asList(entry.notesRef)));
@@ -112,7 +113,7 @@ public class CommitDiffPage extends RepositoryPage {
}
};
add(notesView.setVisible(notes.size() > 0));
-
+
// changed paths list
add(new CommitLegendPanel("commitLegend", diff.stat.paths));
ListDataProvider<PathChangeModel> pathsDp = new ListDataProvider<PathChangeModel>(diff.stat.paths);
@@ -120,6 +121,7 @@ public class CommitDiffPage extends RepositoryPage {
private static final long serialVersionUID = 1L;
int counter;
+ @Override
public void populateItem(final Item<PathChangeModel> item) {
final PathChangeModel entry = item.getModelObject();
Label changeType = new Label("changeType", "");
@@ -176,7 +178,7 @@ public class CommitDiffPage extends RepositoryPage {
.newPathParameter(repositoryName, entry.commitId, entry.path))
.setEnabled(!entry.changeType.equals(ChangeType.ADD)));
}
-
+
WicketUtils.setAlternatingBackground(item, counter);
counter++;
}
@@ -189,7 +191,7 @@ public class CommitDiffPage extends RepositoryPage {
protected String getPageName() {
return getString("gb.commitdiff");
}
-
+
@Override
protected Class<? extends BasePage> getRepoNavPageClass() {
return LogPage.class;
diff --git a/src/main/java/com/gitblit/wicket/pages/CommitPage.java b/src/main/java/com/gitblit/wicket/pages/CommitPage.java
index 8e001bc2..517bf78b 100644
--- a/src/main/java/com/gitblit/wicket/pages/CommitPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/CommitPage.java
@@ -56,7 +56,7 @@ public class CommitPage extends RepositoryPage {
Repository r = getRepository();
RevCommit c = getCommit();
-
+
List<String> parents = new ArrayList<String>();
if (c.getParentCount() > 0) {
for (RevCommit parent : c.getParents()) {
@@ -86,7 +86,7 @@ public class CommitPage extends RepositoryPage {
add(createPersonPanel("commitAuthor", c.getAuthorIdent(), Constants.SearchType.AUTHOR));
add(WicketUtils.createTimestampLabel("commitAuthorDate", c.getAuthorIdent().getWhen(),
getTimeZone(), getTimeUtils()));
-
+
// committer
add(createPersonPanel("commitCommitter", c.getCommitterIdent(), Constants.SearchType.COMMITTER));
add(WicketUtils.createTimestampLabel("commitCommitterDate",
@@ -98,7 +98,7 @@ public class CommitPage extends RepositoryPage {
newCommitParameter()));
add(new BookmarkablePageLink<Void>("treeLink", TreePage.class, newCommitParameter()));
final String baseUrl = WicketUtils.getGitblitURL(getRequest());
-
+
add(new CompressedDownloadsPanel("compressedLinks", baseUrl, repositoryName, objectId, null));
// Parent Commits
@@ -106,6 +106,7 @@ public class CommitPage extends RepositoryPage {
DataView<String> parentsView = new DataView<String>("commitParents", parentsDp) {
private static final long serialVersionUID = 1L;
+ @Override
public void populateItem(final Item<String> item) {
String entry = item.getModelObject();
item.add(new LinkPanel("commitParent", "list", entry, CommitPage.class,
@@ -126,6 +127,7 @@ public class CommitPage extends RepositoryPage {
DataView<GitNote> notesView = new DataView<GitNote>("notes", notesDp) {
private static final long serialVersionUID = 1L;
+ @Override
public void populateItem(final Item<GitNote> item) {
GitNote entry = item.getModelObject();
item.add(new RefsPanel("refName", repositoryName, Arrays.asList(entry.notesRef)));
@@ -142,7 +144,7 @@ public class CommitPage extends RepositoryPage {
// changed paths list
List<PathChangeModel> paths = JGitUtils.getFilesInCommit(r, c);
-
+
// add commit diffstat
int insertions = 0;
int deletions = 0;
@@ -151,13 +153,14 @@ public class CommitPage extends RepositoryPage {
deletions += pcm.deletions;
}
add(new DiffStatPanel("diffStat", insertions, deletions));
-
+
add(new CommitLegendPanel("commitLegend", paths));
ListDataProvider<PathChangeModel> pathsDp = new ListDataProvider<PathChangeModel>(paths);
DataView<PathChangeModel> pathsView = new DataView<PathChangeModel>("changedPath", pathsDp) {
private static final long serialVersionUID = 1L;
int counter;
+ @Override
public void populateItem(final Item<PathChangeModel> item) {
final PathChangeModel entry = item.getModelObject();
Label changeType = new Label("changeType", "");
@@ -179,7 +182,7 @@ public class CommitPage extends RepositoryPage {
SubmoduleModel submodule = getSubmodule(entry.path);
submodulePath = submodule.gitblitPath;
hasSubmodule = submodule.hasSubmodule;
-
+
item.add(new LinkPanel("pathName", "list", entry.path + " @ " +
getShortObjectId(submoduleId), TreePage.class,
WicketUtils.newPathParameter(submodulePath, submoduleId, "")).setEnabled(hasSubmodule));
@@ -195,10 +198,10 @@ public class CommitPage extends RepositoryPage {
WicketUtils
.newPathParameter(repositoryName, entry.commitId, path)));
}
-
+
// quick links
if (entry.isSubmodule()) {
- // submodule
+ // submodule
item.add(new BookmarkablePageLink<Void>("diff", BlobDiffPage.class, WicketUtils
.newPathParameter(repositoryName, entry.commitId, entry.path))
.setEnabled(!entry.changeType.equals(ChangeType.ADD)));
@@ -237,7 +240,7 @@ public class CommitPage extends RepositoryPage {
protected String getPageName() {
return getString("gb.commit");
}
-
+
@Override
protected Class<? extends BasePage> getRepoNavPageClass() {
return LogPage.class;
diff --git a/src/main/java/com/gitblit/wicket/pages/ComparePage.java b/src/main/java/com/gitblit/wicket/pages/ComparePage.java
index 1efb9b6b..25b5f5c0 100644
--- a/src/main/java/com/gitblit/wicket/pages/ComparePage.java
+++ b/src/main/java/com/gitblit/wicket/pages/ComparePage.java
@@ -55,7 +55,7 @@ import com.gitblit.wicket.panels.LogPanel;
/**
* The compare page allows you to compare two branches, tags, or hash ids.
- *
+ *
* @author James Moger
*
*/
@@ -71,7 +71,7 @@ public class ComparePage extends RepositoryPage {
super(params);
Repository r = getRepository();
RepositoryModel repository = getRepositoryModel();
-
+
if (StringUtils.isEmpty(objectId)) {
// seleciton form
add(new Label("comparison").setVisible(false));
@@ -79,30 +79,30 @@ public class ComparePage extends RepositoryPage {
// active comparison
Fragment comparison = new Fragment("comparison", "comparisonFragment", this);
add(comparison);
-
+
RevCommit fromCommit;
RevCommit toCommit;
-
+
String[] parts = objectId.split("\\.\\.");
if (parts[0].startsWith("refs/") && parts[1].startsWith("refs/")) {
// set the ref models
fromRefId.setObject(parts[0]);
toRefId.setObject(parts[1]);
-
+
fromCommit = getCommit(r, fromRefId.getObject());
toCommit = getCommit(r, toRefId.getObject());
} else {
// set the id models
fromCommitId.setObject(parts[0]);
toCommitId.setObject(parts[1]);
-
+
fromCommit = getCommit(r, fromCommitId.getObject());
toCommit = getCommit(r, toCommitId.getObject());
}
// prepare submodules
getSubmodules(toCommit);
-
+
final String startId = fromCommit.getId().getName();
final String endId = toCommit.getId().getName();
@@ -135,6 +135,7 @@ public class ComparePage extends RepositoryPage {
private static final long serialVersionUID = 1L;
int counter;
+ @Override
public void populateItem(final Item<PathChangeModel> item) {
final PathChangeModel entry = item.getModelObject();
Label changeType = new Label("changeType", "");
@@ -209,14 +210,14 @@ public class ComparePage extends RepositoryPage {
public void onSubmit() {
String from = ComparePage.this.fromRefId.getObject();
String to = ComparePage.this.toRefId.getObject();
-
+
PageParameters params = WicketUtils.newRangeParameter(repositoryName, from, to);
String relativeUrl = urlFor(ComparePage.class, params).toString();
String absoluteUrl = RequestUtils.toAbsolutePath(relativeUrl);
getRequestCycle().setRequestTarget(new RedirectRequestTarget(absoluteUrl));
}
};
-
+
List<String> refs = new ArrayList<String>();
for (RefModel ref : JGitUtils.getLocalBranches(r, true, -1)) {
refs.add(ref.getName());
@@ -232,7 +233,7 @@ public class ComparePage extends RepositoryPage {
refsForm.add(new DropDownChoice<String>("fromRef", fromRefId, refs).setEnabled(refs.size() > 0));
refsForm.add(new DropDownChoice<String>("toRef", toRefId, refs).setEnabled(refs.size() > 0));
add(refsForm);
-
+
//
// manual ids form
//
@@ -244,23 +245,23 @@ public class ComparePage extends RepositoryPage {
public void onSubmit() {
String from = ComparePage.this.fromCommitId.getObject();
String to = ComparePage.this.toCommitId.getObject();
-
+
PageParameters params = WicketUtils.newRangeParameter(repositoryName, from, to);
String relativeUrl = urlFor(ComparePage.class, params).toString();
String absoluteUrl = RequestUtils.toAbsolutePath(relativeUrl);
getRequestCycle().setRequestTarget(new RedirectRequestTarget(absoluteUrl));
}
};
-
+
TextField<String> fromIdField = new TextField<String>("fromId", fromCommitId);
WicketUtils.setInputPlaceholder(fromIdField, getString("gb.from") + "...");
idsForm.add(fromIdField);
-
+
TextField<String> toIdField = new TextField<String>("toId", toCommitId);
WicketUtils.setInputPlaceholder(toIdField, getString("gb.to") + "...");
idsForm.add(toIdField);
add(idsForm);
-
+
r.close();
}
@@ -268,7 +269,7 @@ public class ComparePage extends RepositoryPage {
protected String getPageName() {
return getString("gb.compare");
}
-
+
@Override
protected Class<? extends BasePage> getRepoNavPageClass() {
return ComparePage.class;
diff --git a/src/main/java/com/gitblit/wicket/pages/DashboardPage.java b/src/main/java/com/gitblit/wicket/pages/DashboardPage.java
index 18add502..5c72b8bd 100644
--- a/src/main/java/com/gitblit/wicket/pages/DashboardPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/DashboardPage.java
@@ -75,7 +75,7 @@ public abstract class DashboardPage extends RootPage {
c.add(Calendar.DATE, -1*daysBack);
Date minimumDate = c.getTime();
TimeZone timezone = getTimeZone();
-
+
// create daily commit digest feed
List<DailyLogEntry> digests = new ArrayList<DailyLogEntry>();
for (RepositoryModel model : repositories) {
@@ -89,7 +89,7 @@ public abstract class DashboardPage extends RootPage {
repository.close();
}
}
-
+
Fragment activityFragment = new Fragment("activity", "activityFragment", this);
add(activityFragment);
activityFragment.add(new Label("feedTitle", feedTitle));
@@ -118,7 +118,7 @@ public abstract class DashboardPage extends RootPage {
DigestsPanel digestsPanel = new DigestsPanel("digests", digests);
activityFragment.add(digestsPanel);
}
-
+
// add the nifty charts
if (!ArrayUtils.isEmpty(digests)) {
// aggregate author exclusions
@@ -140,7 +140,7 @@ public abstract class DashboardPage extends RootPage {
activityFragment.add(new Label("feedheader").setVisible(false));
}
}
-
+
@Override
protected void addDropDownMenus(List<PageRegistration> pages) {
PageParameters params = getPageParameters();
@@ -163,7 +163,7 @@ public abstract class DashboardPage extends RootPage {
/**
* Creates the daily activity line chart, the active repositories pie chart,
* and the active authors pie chart
- *
+ *
* @param recentChanges
* @param authorExclusions
* @param daysBack
@@ -183,7 +183,7 @@ public abstract class DashboardPage extends RootPage {
repositoryMetrics.put(repository, new Metric(repository));
}
repositoryMetrics.get(repository).count += 1;
-
+
for (RepositoryCommit commit : change.getCommits()) {
totalCommits++;
String author = StringUtils.removeNewlines(commit.getAuthorIdent().getName());
@@ -197,7 +197,7 @@ public abstract class DashboardPage extends RootPage {
}
}
}
-
+
String headerPattern;
if (daysBack == 1) {
// today
@@ -239,7 +239,7 @@ public abstract class DashboardPage extends RootPage {
chart.setShowLegend(false);
charts.addChart(chart);
- add(new HeaderContributor(charts));
+ add(new HeaderContributor(charts));
frag.add(new Fragment("charts", "chartsFragment", this));
} else {
frag.add(new Label("charts").setVisible(false));
diff --git a/src/main/java/com/gitblit/wicket/pages/DocsPage.java b/src/main/java/com/gitblit/wicket/pages/DocsPage.java
index 9330316e..eea9595c 100644
--- a/src/main/java/com/gitblit/wicket/pages/DocsPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/DocsPage.java
@@ -31,8 +31,8 @@ import com.gitblit.models.PathModel;
import com.gitblit.utils.ByteFormat;
import com.gitblit.utils.JGitUtils;
import com.gitblit.wicket.CacheControl;
-import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.CacheControl.LastModified;
+import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.panels.LinkPanel;
@CacheControl(LastModified.REPOSITORY)
@@ -55,6 +55,7 @@ public class DocsPage extends RepositoryPage {
private static final long serialVersionUID = 1L;
int counter;
+ @Override
public void populateItem(final Item<PathModel> item) {
PathModel entry = item.getModelObject();
item.add(WicketUtils.newImage("docIcon", "file_world_16x16.png"));
diff --git a/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.java b/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.java
index f2c47f2e..f92a91f3 100644
--- a/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.java
@@ -74,11 +74,11 @@ public class EditRepositoryPage extends RootSubPage {
private final boolean isCreate;
private boolean isAdmin;
-
+
RepositoryModel repositoryModel;
private IModel<String> metricAuthorExclusions;
-
+
private IModel<String> mailingLists;
public EditRepositoryPage() {
@@ -90,7 +90,7 @@ public class EditRepositoryPage extends RootSubPage {
model.accessRestriction = AccessRestrictionType.fromName(restriction);
String authorization = GitBlit.getString(Keys.git.defaultAuthorizationControl, null);
model.authorizationControl = AuthorizationControl.fromName(authorization);
-
+
GitBlitWebSession session = GitBlitWebSession.get();
UserModel user = session.getUser();
if (user != null && user.canCreate() && !user.canAdmin()) {
@@ -102,7 +102,7 @@ public class EditRepositoryPage extends RootSubPage {
model.accessRestriction = AccessRestrictionType.VIEW;
model.authorizationControl = AuthorizationControl.NAMED;
}
-
+
setupPage(model);
setStatelessHint(false);
setOutputMarkupId(true);
@@ -118,12 +118,12 @@ public class EditRepositoryPage extends RootSubPage {
setStatelessHint(false);
setOutputMarkupId(true);
}
-
+
@Override
protected boolean requiresPageMap() {
return true;
}
-
+
@Override
protected Class<? extends BasePage> getRootNavPageClass() {
return RepositoriesPage.class;
@@ -131,7 +131,7 @@ public class EditRepositoryPage extends RootSubPage {
protected void setupPage(RepositoryModel model) {
this.repositoryModel = model;
-
+
// ensure this user can create or edit this repository
checkPermissions(repositoryModel);
@@ -145,7 +145,7 @@ public class EditRepositoryPage extends RootSubPage {
GitBlitWebSession session = GitBlitWebSession.get();
final UserModel user = session.getUser() == null ? UserModel.ANONYMOUS : session.getUser();
final boolean allowEditName = isCreate || isAdmin || repositoryModel.isUsersPersonalRepository(user.username);
-
+
if (isCreate) {
if (user.canAdmin()) {
super.setupPage(getString("gb.newRepository"), "");
@@ -158,7 +158,7 @@ public class EditRepositoryPage extends RootSubPage {
repositoryTeams.addAll(GitBlit.self().getTeamAccessPermissions(repositoryModel));
Collections.sort(repositoryUsers);
Collections.sort(repositoryTeams);
-
+
federationSets.addAll(repositoryModel.federationSets);
if (!ArrayUtils.isEmpty(repositoryModel.indexedBranches)) {
indexedBranches.addAll(repositoryModel.indexedBranches);
@@ -167,9 +167,9 @@ public class EditRepositoryPage extends RootSubPage {
final String oldName = repositoryModel.name;
- final RegistrantPermissionsPanel usersPalette = new RegistrantPermissionsPanel("users",
+ final RegistrantPermissionsPanel usersPalette = new RegistrantPermissionsPanel("users",
RegistrantType.USER, GitBlit.self().getAllUsernames(), repositoryUsers, getAccessPermissions());
- final RegistrantPermissionsPanel teamsPalette = new RegistrantPermissionsPanel("teams",
+ final RegistrantPermissionsPanel teamsPalette = new RegistrantPermissionsPanel("teams",
RegistrantType.TEAM, GitBlit.self().getAllTeamnames(), repositoryTeams, getAccessPermissions());
// owners palette
@@ -177,7 +177,7 @@ public class EditRepositoryPage extends RootSubPage {
List<String> persons = GitBlit.self().getAllUsernames();
final Palette<String> ownersPalette = new Palette<String>("owners", new ListModel<String>(owners), new CollectionModel<String>(
persons), new StringChoiceRenderer(), 12, true);
-
+
// indexed local branches palette
List<String> allLocalBranches = new ArrayList<String>();
allLocalBranches.add(Constants.DEFAULT_BRANCH);
@@ -187,7 +187,7 @@ public class EditRepositoryPage extends RootSubPage {
indexedBranches), new CollectionModel<String>(allLocalBranches),
new StringChoiceRenderer(), 8, false);
indexedBranchesPalette.setEnabled(luceneEnabled);
-
+
// federation sets palette
List<String> sets = GitBlit.getStrings(Keys.federation.sets);
final Palette<String> federationSetsPalette = new Palette<String>("federationSets",
@@ -211,19 +211,19 @@ public class EditRepositoryPage extends RootSubPage {
new ListModel<String>(postReceiveScripts), new CollectionModel<String>(GitBlit
.self().getPostReceiveScriptsUnused(repositoryModel)),
new StringChoiceRenderer(), 12, true);
-
+
// custom fields
final Map<String, String> customFieldsMap = GitBlit.getMap(Keys.groovy.customFields);
List<String> customKeys = new ArrayList<String>(customFieldsMap.keySet());
final ListView<String> customFieldsListView = new ListView<String>("customFieldsListView", customKeys) {
-
+
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(ListItem<String> item) {
String key = item.getModelObject();
item.add(new Label("customFieldLabel", customFieldsMap.get(key)));
-
+
String value = "";
if (repositoryModel.customFields != null && repositoryModel.customFields.containsKey(key)) {
value = repositoryModel.customFields.get(key);
@@ -248,10 +248,10 @@ public class EditRepositoryPage extends RootSubPage {
error(getString("gb.pleaseSetRepositoryName"));
return;
}
-
+
// ensure name is trimmed
repositoryModel.name = repositoryModel.name.trim();
-
+
// automatically convert backslashes to forward slashes
repositoryModel.name = repositoryModel.name.replace('\\', '/');
// Automatically replace // with /
@@ -269,7 +269,7 @@ public class EditRepositoryPage extends RootSubPage {
if (repositoryModel.name.contains("/../")) {
error(getString("gb.illegalRelativeSlash"));
return;
- }
+ }
if (repositoryModel.name.endsWith("/")) {
repositoryModel.name = repositoryModel.name.substring(0, repositoryModel.name.length() - 1);
}
@@ -281,7 +281,7 @@ public class EditRepositoryPage extends RootSubPage {
c));
return;
}
-
+
if (user.canCreate() && !user.canAdmin() && allowEditName) {
// ensure repository name begins with the user's path
if (!repositoryModel.name.startsWith(user.getPersonalPath())) {
@@ -289,7 +289,7 @@ public class EditRepositoryPage extends RootSubPage {
user.getPersonalPath()));
return;
}
-
+
if (repositoryModel.name.equals(user.getPersonalPath())) {
// reset path prefix and show error
repositoryModel.name = user.getPersonalPath() + "/";
@@ -328,7 +328,7 @@ public class EditRepositoryPage extends RootSubPage {
continue;
}
if (exclusion.indexOf(' ') > -1) {
- list.add("\"" + exclusion + "\"");
+ list.add("\"" + exclusion + "\"");
} else {
list.add(exclusion);
}
@@ -363,7 +363,7 @@ public class EditRepositoryPage extends RootSubPage {
while (owners.hasNext()) {
repositoryModel.addOwner(owners.next());
}
-
+
// pre-receive scripts
List<String> preReceiveScripts = new ArrayList<String>();
Iterator<String> pres = preReceivePalette.getSelectedChoices();
@@ -379,7 +379,7 @@ public class EditRepositoryPage extends RootSubPage {
postReceiveScripts.add(post.next());
}
repositoryModel.postReceiveScripts = postReceiveScripts;
-
+
// custom fields
repositoryModel.customFields = new LinkedHashMap<String, String>();
for (int i = 0; i < customFieldsListView.size(); i++) {
@@ -388,10 +388,10 @@ public class EditRepositoryPage extends RootSubPage {
TextField<String> field = (TextField<String>) child.get("customFieldValue");
String value = field.getValue();
-
+
repositoryModel.customFields.put(key, value);
}
-
+
// save the repository
GitBlit.self().updateRepositoryModel(oldName, repositoryModel, isCreate);
@@ -423,7 +423,7 @@ public class EditRepositoryPage extends RootSubPage {
form.add(new CheckBox("isFrozen"));
// TODO enable origin definition
form.add(new TextField<String>("origin").setEnabled(false/* isCreate */));
-
+
// allow relinking HEAD to a branch or tag other than master on edit repository
List<String> availableRefs = new ArrayList<String>();
if (!ArrayUtils.isEmpty(repositoryModel.availableRefs)) {
@@ -431,7 +431,7 @@ public class EditRepositoryPage extends RootSubPage {
}
form.add(new DropDownChoice<String>("HEAD", availableRefs).setEnabled(availableRefs.size() > 0));
- boolean gcEnabled = GitBlit.getBoolean(Keys.git.enableGarbageCollection, false);
+ boolean gcEnabled = GitBlit.getBoolean(Keys.git.enableGarbageCollection, false);
List<Integer> gcPeriods = Arrays.asList(1, 2, 3, 4, 5, 7, 10, 14 );
form.add(new DropDownChoice<Integer>("gcPeriod", gcPeriods, new GCPeriodRenderer()).setEnabled(gcEnabled));
form.add(new TextField<String>("gcThreshold").setEnabled(gcEnabled));
@@ -463,12 +463,12 @@ public class EditRepositoryPage extends RootSubPage {
: StringUtils.flattenStrings(repositoryModel.mailingLists, " "));
form.add(new TextField<String>("mailingLists", mailingLists));
form.add(indexedBranchesPalette);
-
+
List<AuthorizationControl> acList = Arrays.asList(AuthorizationControl.values());
final RadioChoice<AuthorizationControl> authorizationControl = new RadioChoice<Constants.AuthorizationControl>(
"authorizationControl", acList, new AuthorizationControlRenderer());
form.add(authorizationControl);
-
+
final CheckBox verifyCommitter = new CheckBox("verifyCommitter");
verifyCommitter.setOutputMarkupId(true);
form.add(verifyCommitter);
@@ -482,11 +482,11 @@ public class EditRepositoryPage extends RootSubPage {
form.add(postReceivePalette);
form.add(new BulletListPanel("inheritedPostReceive", getString("gb.inherited"), GitBlit.self()
.getPostReceiveScriptsInherited(repositoryModel)));
-
+
WebMarkupContainer customFieldsSection = new WebMarkupContainer("customFieldsSection");
customFieldsSection.add(customFieldsListView);
form.add(customFieldsSection.setVisible(!GitBlit.getString(Keys.groovy.customFields, "").isEmpty()));
-
+
// initial enable/disable of permission controls
if (repositoryModel.accessRestriction.equals(AccessRestrictionType.NONE)) {
// anonymous everything, disable all controls
@@ -499,64 +499,66 @@ public class EditRepositoryPage extends RootSubPage {
// enable authorization controls
authorizationControl.setEnabled(true);
verifyCommitter.setEnabled(true);
-
+
boolean allowFineGrainedControls = repositoryModel.authorizationControl.equals(AuthorizationControl.NAMED);
usersPalette.setEnabled(allowFineGrainedControls);
teamsPalette.setEnabled(allowFineGrainedControls);
}
-
+
accessRestriction.add(new AjaxFormComponentUpdatingBehavior("onchange") {
-
+
private static final long serialVersionUID = 1L;
+ @Override
protected void onUpdate(AjaxRequestTarget target) {
// enable/disable permissions panel based on access restriction
boolean allowAuthorizationControl = repositoryModel.accessRestriction.exceeds(AccessRestrictionType.NONE);
authorizationControl.setEnabled(allowAuthorizationControl);
verifyCommitter.setEnabled(allowAuthorizationControl);
-
+
boolean allowFineGrainedControls = allowAuthorizationControl && repositoryModel.authorizationControl.equals(AuthorizationControl.NAMED);
usersPalette.setEnabled(allowFineGrainedControls);
teamsPalette.setEnabled(allowFineGrainedControls);
-
+
if (allowFineGrainedControls) {
repositoryModel.authorizationControl = AuthorizationControl.NAMED;
}
-
+
target.addComponent(authorizationControl);
target.addComponent(verifyCommitter);
target.addComponent(usersPalette);
target.addComponent(teamsPalette);
}
});
-
+
authorizationControl.add(new AjaxFormChoiceComponentUpdatingBehavior() {
-
+
private static final long serialVersionUID = 1L;
+ @Override
protected void onUpdate(AjaxRequestTarget target) {
// enable/disable permissions panel based on access restriction
boolean allowAuthorizationControl = repositoryModel.accessRestriction.exceeds(AccessRestrictionType.NONE);
authorizationControl.setEnabled(allowAuthorizationControl);
-
+
boolean allowFineGrainedControls = allowAuthorizationControl && repositoryModel.authorizationControl.equals(AuthorizationControl.NAMED);
usersPalette.setEnabled(allowFineGrainedControls);
teamsPalette.setEnabled(allowFineGrainedControls);
-
+
if (allowFineGrainedControls) {
repositoryModel.authorizationControl = AuthorizationControl.NAMED;
}
-
+
target.addComponent(authorizationControl);
target.addComponent(usersPalette);
target.addComponent(teamsPalette);
}
});
-
+
List<CommitMessageRenderer> renderers = Arrays.asList(CommitMessageRenderer.values());
DropDownChoice<CommitMessageRenderer> messageRendererChoice = new DropDownChoice<CommitMessageRenderer>("commitMessageRenderer", renderers);
form.add(messageRendererChoice);
-
+
form.add(new Button("save"));
Button cancel = new Button("cancel") {
private static final long serialVersionUID = 1L;
@@ -576,7 +578,7 @@ public class EditRepositoryPage extends RootSubPage {
* Unfortunately must repeat part of AuthorizaitonStrategy here because that
* mechanism does not take PageParameters into consideration, only page
* instantiation.
- *
+ *
* Repository Owners should be able to edit their repository.
*/
private void checkPermissions(RepositoryModel model) {
@@ -659,7 +661,7 @@ public class EditRepositoryPage extends RootSubPage {
return Integer.toString(index);
}
}
-
+
private class AuthorizationControlRenderer implements IChoiceRenderer<AuthorizationControl> {
private static final long serialVersionUID = 1L;
@@ -680,7 +682,7 @@ public class EditRepositoryPage extends RootSubPage {
return Integer.toString(index);
}
}
-
+
private class GCPeriodRenderer implements IChoiceRenderer<Integer> {
private static final long serialVersionUID = 1L;
@@ -702,7 +704,7 @@ public class EditRepositoryPage extends RootSubPage {
return Integer.toString(index);
}
}
-
+
private class MaxActivityCommitsRenderer implements IChoiceRenderer<Integer> {
private static final long serialVersionUID = 1L;
diff --git a/src/main/java/com/gitblit/wicket/pages/EditTeamPage.java b/src/main/java/com/gitblit/wicket/pages/EditTeamPage.java
index 25fbd983..617aa86b 100644
--- a/src/main/java/com/gitblit/wicket/pages/EditTeamPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/EditTeamPage.java
@@ -80,7 +80,7 @@ public class EditTeamPage extends RootSubPage {
protected boolean requiresPageMap() {
return true;
}
-
+
@Override
protected Class<? extends BasePage> getRootNavPageClass() {
return UsersPage.class;
@@ -134,7 +134,7 @@ public class EditTeamPage extends RootSubPage {
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.wicket.markup.html.form.Form#onSubmit()
*/
@Override
@@ -218,7 +218,7 @@ public class EditTeamPage extends RootSubPage {
// not all user services support manipulating team memberships
boolean editMemberships = GitBlit.self().supportsTeamMembershipChanges(null);
-
+
// field names reflective match TeamModel fields
form.add(new TextField<String>("name"));
form.add(new CheckBox("canAdmin"));
diff --git a/src/main/java/com/gitblit/wicket/pages/EditUserPage.java b/src/main/java/com/gitblit/wicket/pages/EditUserPage.java
index 93230c23..6838c196 100644
--- a/src/main/java/com/gitblit/wicket/pages/EditUserPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/EditUserPage.java
@@ -51,7 +51,7 @@ import com.gitblit.wicket.panels.RegistrantPermissionsPanel;
public class EditUserPage extends RootSubPage {
private final boolean isCreate;
-
+
public EditUserPage() {
// create constructor
super();
@@ -75,12 +75,12 @@ public class EditUserPage extends RootSubPage {
setStatelessHint(false);
setOutputMarkupId(true);
}
-
+
@Override
protected boolean requiresPageMap() {
return true;
}
-
+
@Override
protected Class<? extends BasePage> getRootNavPageClass() {
return UsersPage.class;
@@ -99,13 +99,13 @@ public class EditUserPage extends RootSubPage {
// build list of projects including all repositories wildcards
List<String> repos = getAccessRestrictedRepositoryList(true, userModel);
-
+
List<String> userTeams = new ArrayList<String>();
for (TeamModel team : userModel.teams) {
userTeams.add(team.name);
}
Collections.sort(userTeams);
-
+
final String oldName = userModel.username;
final List<RegistrantAccessPermission> permissions = GitBlit.self().getUserAccessPermissions(userModel);
@@ -115,10 +115,10 @@ public class EditUserPage extends RootSubPage {
Form<UserModel> form = new Form<UserModel>("editForm", model) {
private static final long serialVersionUID = 1L;
-
+
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.wicket.markup.html.form.Form#onSubmit()
*/
@Override
@@ -158,7 +158,7 @@ public class EditUserPage extends RootSubPage {
minLength));
return;
}
-
+
// Optionally store the password MD5 digest.
String type = GitBlit.getString(Keys.realm.passwordStorage, "md5");
if (type.equalsIgnoreCase("md5")) {
@@ -192,7 +192,7 @@ public class EditUserPage extends RootSubPage {
userModel.teams.add(team);
}
- try {
+ try {
GitBlit.self().updateUserModel(oldName, userModel, isCreate);
} catch (GitBlitException e) {
error(e.getMessage());
@@ -210,13 +210,13 @@ public class EditUserPage extends RootSubPage {
}
}
};
-
+
// do not let the browser pre-populate these fields
form.add(new SimpleAttributeModifier("autocomplete", "off"));
-
+
// not all user services support manipulating username and password
boolean editCredentials = GitBlit.self().supportsCredentialChanges(userModel);
-
+
// not all user services support manipulating display name
boolean editDisplayName = GitBlit.self().supportsDisplayNameChanges(userModel);
diff --git a/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage.java b/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage.java
index 41f109a0..4e05fad6 100644
--- a/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage.java
@@ -45,30 +45,30 @@ public class EmptyRepositoryPage extends RootPage {
if (repository == null) {
error(getString("gb.canNotLoadRepository") + " " + repositoryName, true);
}
-
+
if (repository.hasCommits) {
// redirect to the summary page if this repository is not empty
throw new GitblitRedirectException(SummaryPage.class, params);
}
-
+
setupPage(repositoryName, getString("gb.emptyRepository"));
UserModel user = GitBlitWebSession.get().getUser();
if (user == null) {
user = UserModel.ANONYMOUS;
}
-
+
HttpServletRequest req = ((WebRequest) getRequest()).getHttpServletRequest();
List<RepositoryUrl> repositoryUrls = GitBlit.self().getRepositoryUrls(req, user, repository);
RepositoryUrl primaryUrl = repositoryUrls.size() == 0 ? null : repositoryUrls.get(0);
String url = primaryUrl != null ? primaryUrl.url : "";
-
+
add(new Label("repository", repositoryName));
add(new RepositoryUrlPanel("pushurl", false, user, repository));
add(new Label("cloneSyntax", MessageFormat.format("git clone {0}", url)));
add(new Label("remoteSyntax", MessageFormat.format("git remote add gitblit {0}\ngit push gitblit master", url)));
}
-
+
@Override
protected Class<? extends BasePage> getRootNavPageClass() {
return RepositoriesPage.class;
diff --git a/src/main/java/com/gitblit/wicket/pages/FederationRegistrationPage.java b/src/main/java/com/gitblit/wicket/pages/FederationRegistrationPage.java
index 092f8e25..42f46943 100644
--- a/src/main/java/com/gitblit/wicket/pages/FederationRegistrationPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/FederationRegistrationPage.java
@@ -33,7 +33,7 @@ public class FederationRegistrationPage extends RootSubPage {
public FederationRegistrationPage(PageParameters params) {
super(params);
-
+
setStatelessHint(true);
String url = WicketUtils.getUrlParameter(params);
@@ -81,6 +81,7 @@ public class FederationRegistrationPage extends RootSubPage {
counter = 0;
}
+ @Override
public void populateItem(final Item<RepositoryStatus> item) {
final RepositoryStatus entry = item.getModelObject();
item.add(WicketUtils.getPullStatusImage("statusIcon", entry.status));
@@ -92,7 +93,7 @@ public class FederationRegistrationPage extends RootSubPage {
};
add(dataView);
}
-
+
@Override
protected Class<? extends BasePage> getRootNavPageClass() {
return FederationPage.class;
diff --git a/src/main/java/com/gitblit/wicket/pages/ForkPage.java b/src/main/java/com/gitblit/wicket/pages/ForkPage.java
index 340bd823..fe316fff 100644
--- a/src/main/java/com/gitblit/wicket/pages/ForkPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/ForkPage.java
@@ -35,7 +35,7 @@ public class ForkPage extends RepositoryPage {
super(params);
setVersioned(false);
-
+
GitBlitWebSession session = GitBlitWebSession.get();
RepositoryModel repository = getRepositoryModel();
diff --git a/src/main/java/com/gitblit/wicket/pages/ForksPage.java b/src/main/java/com/gitblit/wicket/pages/ForksPage.java
index f59955ee..5b5fcc0a 100644
--- a/src/main/java/com/gitblit/wicket/pages/ForksPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/ForksPage.java
@@ -42,20 +42,21 @@ public class ForksPage extends RepositoryPage {
public ForksPage(PageParameters params) {
super(params);
-
+
final RepositoryModel pageRepository = getRepositoryModel();
-
+
ForkModel root = GitBlit.self().getForkNetwork(pageRepository.name);
List<FlatFork> network = flatten(root);
-
+
ListDataProvider<FlatFork> forksDp = new ListDataProvider<FlatFork>(network);
DataView<FlatFork> forksList = new DataView<FlatFork>("fork", forksDp) {
private static final long serialVersionUID = 1L;
+ @Override
public void populateItem(final Item<FlatFork> item) {
FlatFork fork = item.getModelObject();
RepositoryModel repository = fork.repository;
-
+
if (repository.isPersonalRepository()) {
UserModel user = GitBlit.self().getUserModel(repository.projectPath.substring(1));
if (user == null) {
@@ -92,7 +93,7 @@ public class ForksPage extends RepositoryPage {
item.add(new LinkPanel("aProject", null, projectName, ProjectPage.class, WicketUtils.newProjectParameter(projectName)));
}
}
-
+
String repo = StringUtils.getLastPathElement(repository.name);
UserModel user = GitBlitWebSession.get().getUser();
if (user == null) {
@@ -110,7 +111,7 @@ public class ForksPage extends RepositoryPage {
item.add(new Label("aFork", repo));
item.add(new Label("lastChange").setVisible(false));
}
-
+
WicketUtils.setCssStyle(item, "margin-left:" + (32*fork.level) + "px;");
if (fork.level == 0) {
WicketUtils.setCssClass(item, "forkSource");
@@ -119,7 +120,7 @@ public class ForksPage extends RepositoryPage {
}
}
};
-
+
add(forksList);
}
@@ -127,13 +128,13 @@ public class ForksPage extends RepositoryPage {
protected String getPageName() {
return getString("gb.forks");
}
-
+
protected List<FlatFork> flatten(ForkModel root) {
List<FlatFork> list = new ArrayList<FlatFork>();
list.addAll(flatten(root, 0));
return list;
}
-
+
protected List<FlatFork> flatten(ForkModel node, int level) {
List<FlatFork> list = new ArrayList<FlatFork>();
list.add(new FlatFork(node.repository, level));
@@ -144,14 +145,14 @@ public class ForksPage extends RepositoryPage {
}
return list;
}
-
+
private class FlatFork implements Serializable {
-
+
private static final long serialVersionUID = 1L;
public final RepositoryModel repository;
public final int level;
-
+
public FlatFork(RepositoryModel repository, int level) {
this.repository = repository;
this.level = level;
diff --git a/src/main/java/com/gitblit/wicket/pages/GitSearchPage.java b/src/main/java/com/gitblit/wicket/pages/GitSearchPage.java
index 446531ab..befa5f10 100644
--- a/src/main/java/com/gitblit/wicket/pages/GitSearchPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/GitSearchPage.java
@@ -20,8 +20,8 @@ import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import com.gitblit.Constants;
import com.gitblit.wicket.CacheControl;
-import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.CacheControl.LastModified;
+import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.panels.SearchPanel;
@CacheControl(LastModified.REPOSITORY)
@@ -69,7 +69,7 @@ public class GitSearchPage extends RepositoryPage {
protected String getPageName() {
return getString("gb.search");
}
-
+
@Override
protected Class<? extends BasePage> getRepoNavPageClass() {
return LogPage.class;
diff --git a/src/main/java/com/gitblit/wicket/pages/GravatarProfilePage.java b/src/main/java/com/gitblit/wicket/pages/GravatarProfilePage.java
index ee567d75..984b2972 100644
--- a/src/main/java/com/gitblit/wicket/pages/GravatarProfilePage.java
+++ b/src/main/java/com/gitblit/wicket/pages/GravatarProfilePage.java
@@ -29,9 +29,9 @@ import com.gitblit.wicket.WicketUtils;
/**
* Gravatar Profile Page shows the Gravatar information, if available.
- *
+ *
* @author James Moger
- *
+ *
*/
public class GravatarProfilePage extends RootPage {
@@ -49,7 +49,7 @@ public class GravatarProfilePage extends RootPage {
} catch (IOException e) {
error(MessageFormat.format(getString("gb.failedToFindGravatarProfile"), object), e, true);
}
-
+
if (profile == null) {
error(MessageFormat.format(getString("gb.failedToFindGravatarProfile"), object), true);
}
diff --git a/src/main/java/com/gitblit/wicket/pages/HistoryPage.java b/src/main/java/com/gitblit/wicket/pages/HistoryPage.java
index 33bc54c1..f7f188df 100644
--- a/src/main/java/com/gitblit/wicket/pages/HistoryPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/HistoryPage.java
@@ -19,8 +19,8 @@ import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import com.gitblit.wicket.CacheControl;
-import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.CacheControl.LastModified;
+import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.panels.HistoryPanel;
@CacheControl(LastModified.REPOSITORY)
@@ -65,7 +65,7 @@ public class HistoryPage extends RepositoryPage {
protected String getPageName() {
return getString("gb.history");
}
-
+
@Override
protected Class<? extends BasePage> getRepoNavPageClass() {
return TreePage.class;
diff --git a/src/main/java/com/gitblit/wicket/pages/LogPage.java b/src/main/java/com/gitblit/wicket/pages/LogPage.java
index 1f4a9bf9..092f719a 100644
--- a/src/main/java/com/gitblit/wicket/pages/LogPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/LogPage.java
@@ -20,8 +20,8 @@ import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import com.gitblit.utils.StringUtils;
import com.gitblit.wicket.CacheControl;
-import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.CacheControl.LastModified;
+import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.panels.LogPanel;
@CacheControl(LastModified.REPOSITORY)
diff --git a/src/main/java/com/gitblit/wicket/pages/LogoutPage.java b/src/main/java/com/gitblit/wicket/pages/LogoutPage.java
index 1028c5a4..ff3b507f 100644
--- a/src/main/java/com/gitblit/wicket/pages/LogoutPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/LogoutPage.java
@@ -30,8 +30,8 @@ public class LogoutPage extends BasePage {
UserModel user = session.getUser();
GitBlit.self().setCookie((WebResponse) getResponse(), null);
GitBlit.self().logout(user);
- session.invalidate();
-
+ session.invalidate();
+
/*
* Now check whether the authentication was realized via the Authorization in the header.
* If so, it is likely to be cached by the browser, and cannot be undone. Effectively, this means
@@ -41,7 +41,7 @@ public class LogoutPage extends BasePage {
// authentication will be done via this route anyway, show a page to close the browser:
// this will be done by Wicket.
setupPage(null, getString("gb.logout"));
-
+
} else {
setRedirect(true);
setResponsePage(getApplication().getHomePage());
diff --git a/src/main/java/com/gitblit/wicket/pages/LuceneSearchPage.java b/src/main/java/com/gitblit/wicket/pages/LuceneSearchPage.java
index 98738b63..86a426ca 100644
--- a/src/main/java/com/gitblit/wicket/pages/LuceneSearchPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/LuceneSearchPage.java
@@ -60,9 +60,9 @@ public class LuceneSearchPage extends RootPage {
private void setup(PageParameters params) {
setupPage("", "");
-
+
// default values
- ArrayList<String> repositories = new ArrayList<String>();
+ ArrayList<String> repositories = new ArrayList<String>();
String query = "";
int page = 1;
int pageSize = GitBlit.getInteger(Keys.web.itemsPerPage, 50);
@@ -74,29 +74,29 @@ public class LuceneSearchPage extends RootPage {
}
page = WicketUtils.getPage(params);
-
+
if (params.containsKey("repositories")) {
String value = params.getString("repositories", "");
- List<String> list = StringUtils.getStringsFromValue(value);
+ List<String> list = StringUtils.getStringsFromValue(value);
repositories.addAll(list);
}
if (params.containsKey("query")) {
- query = params.getString("query", "");
+ query = params.getString("query", "");
} else {
String value = WicketUtils.getSearchString(params);
String type = WicketUtils.getSearchType(params);
com.gitblit.Constants.SearchType searchType = com.gitblit.Constants.SearchType.forName(type);
if (!StringUtils.isEmpty(value)) {
if (searchType == SearchType.COMMIT) {
- query = "type:" + searchType.name().toLowerCase() + " AND \"" + value + "\"";
+ query = "type:" + searchType.name().toLowerCase() + " AND \"" + value + "\"";
} else {
query = searchType.name().toLowerCase() + ":\"" + value + "\"";
}
}
}
}
-
+
// display user-accessible selections
UserModel user = GitBlitWebSession.get().getUser();
List<String> availableRepositories = new ArrayList<String>();
@@ -121,12 +121,12 @@ public class LuceneSearchPage extends RootPage {
searchRepositories.add(selectedRepository);
}
}
-
+
// search form
final Model<String> queryModel = new Model<String>(query);
final Model<ArrayList<String>> repositoriesModel = new Model<ArrayList<String>>(searchRepositories);
SessionlessForm<Void> form = new SessionlessForm<Void>("searchForm", getClass()) {
-
+
private static final long serialVersionUID = 1L;
@Override
@@ -135,7 +135,7 @@ public class LuceneSearchPage extends RootPage {
if (StringUtils.isEmpty(q)) {
error(getString("gb.undefinedQueryWarning"));
return;
- }
+ }
if (repositoriesModel.getObject().size() == 0) {
error(getString("gb.noSelectedRepositoriesWarning"));
return;
@@ -147,20 +147,20 @@ public class LuceneSearchPage extends RootPage {
setResponsePage(page);
}
};
-
- ListMultipleChoice<String> selections = new ListMultipleChoice<String>("repositories",
+
+ ListMultipleChoice<String> selections = new ListMultipleChoice<String>("repositories",
repositoriesModel, availableRepositories, new StringChoiceRenderer());
selections.setMaxRows(8);
form.add(selections.setEnabled(luceneEnabled));
form.add(new TextField<String>("query", queryModel).setEnabled(luceneEnabled));
add(form.setEnabled(luceneEnabled));
-
+
// execute search
final List<SearchResult> results = new ArrayList<SearchResult>();
if (!ArrayUtils.isEmpty(searchRepositories) && !StringUtils.isEmpty(query)) {
results.addAll(GitBlit.self().search(query, page, pageSize, searchRepositories));
}
-
+
// results header
if (results.size() == 0) {
if (!ArrayUtils.isEmpty(searchRepositories) && !StringUtils.isEmpty(query)) {
@@ -176,11 +176,12 @@ public class LuceneSearchPage extends RootPage {
results.get(0).hitId, results.get(results.size() - 1).hitId, results.get(0).totalHits)).
setRenderBodyOnly(true));
}
-
+
// search results view
ListDataProvider<SearchResult> resultsDp = new ListDataProvider<SearchResult>(results);
final DataView<SearchResult> resultsView = new DataView<SearchResult>("searchResults", resultsDp) {
private static final long serialVersionUID = 1L;
+ @Override
public void populateItem(final Item<SearchResult> item) {
final SearchResult sr = item.getModelObject();
switch(sr.type) {
@@ -198,11 +199,12 @@ public class LuceneSearchPage extends RootPage {
ListDataProvider<String> tagsDp = new ListDataProvider<String>(tags);
final DataView<String> tagsView = new DataView<String>("tag", tagsDp) {
private static final long serialVersionUID = 1L;
+ @Override
public void populateItem(final Item<String> item) {
String tag = item.getModelObject();
Component c = new LinkPanel("tagLink", null, tag, TagPage.class,
WicketUtils.newObjectParameter(sr.repository, Constants.R_TAGS + tag));
- WicketUtils.setCssClass(c, "tagRef");
+ WicketUtils.setCssClass(c, "tagRef");
item.add(c);
}
};
@@ -231,18 +233,18 @@ public class LuceneSearchPage extends RootPage {
}
};
add(resultsView.setVisible(results.size() > 0));
-
+
PageParameters pagerParams = new PageParameters();
pagerParams.put("repositories", StringUtils.flattenStrings(repositoriesModel.getObject()));
pagerParams.put("query", queryModel.getObject());
-
+
boolean showPager = false;
int totalPages = 0;
if (results.size() > 0) {
totalPages = (results.get(0).totalHits / pageSize) + (results.get(0).totalHits % pageSize > 0 ? 1 : 0);
showPager = results.get(0).totalHits > pageSize;
}
-
+
add(new PagerPanel("topPager", page, totalPages, LuceneSearchPage.class, pagerParams).setVisible(showPager));
add(new PagerPanel("bottomPager", page, totalPages, LuceneSearchPage.class, pagerParams).setVisible(showPager));
}
diff --git a/src/main/java/com/gitblit/wicket/pages/MarkdownPage.java b/src/main/java/com/gitblit/wicket/pages/MarkdownPage.java
index df078c72..5aa80294 100644
--- a/src/main/java/com/gitblit/wicket/pages/MarkdownPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/MarkdownPage.java
@@ -30,8 +30,8 @@ import com.gitblit.utils.JGitUtils;
import com.gitblit.utils.MarkdownUtils;
import com.gitblit.utils.StringUtils;
import com.gitblit.wicket.CacheControl;
-import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.CacheControl.LastModified;
+import com.gitblit.wicket.WicketUtils;
@CacheControl(LastModified.BOOT)
public class MarkdownPage extends RepositoryPage {
@@ -44,7 +44,7 @@ public class MarkdownPage extends RepositoryPage {
Repository r = getRepository();
RevCommit commit = JGitUtils.getCommit(r, objectId);
String [] encodings = GitBlit.getEncodings();
-
+
// markdown page links
add(new BookmarkablePageLink<Void>("blameLink", BlamePage.class,
WicketUtils.newPathParameter(repositoryName, objectId, markdownPath)));
@@ -73,7 +73,7 @@ public class MarkdownPage extends RepositoryPage {
protected String getPageName() {
return getString("gb.markdown");
}
-
+
@Override
protected Class<? extends BasePage> getRepoNavPageClass() {
return DocsPage.class;
diff --git a/src/main/java/com/gitblit/wicket/pages/MetricsPage.java b/src/main/java/com/gitblit/wicket/pages/MetricsPage.java
index 3aa1fccd..d4cfc8e9 100644
--- a/src/main/java/com/gitblit/wicket/pages/MetricsPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/MetricsPage.java
@@ -41,8 +41,8 @@ import com.gitblit.models.Metric;
import com.gitblit.utils.MetricUtils;
import com.gitblit.utils.StringUtils;
import com.gitblit.wicket.CacheControl;
-import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.CacheControl.LastModified;
+import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.charting.SecureChart;
@CacheControl(LastModified.REPOSITORY)
@@ -184,7 +184,7 @@ public class MetricsPage extends RepositoryPage {
protected String getPageName() {
return getString("gb.metrics");
}
-
+
@Override
protected Class<? extends BasePage> getRepoNavPageClass() {
return SummaryPage.class;
diff --git a/src/main/java/com/gitblit/wicket/pages/MyDashboardPage.java b/src/main/java/com/gitblit/wicket/pages/MyDashboardPage.java
index 0768b2ac..8e05b4f0 100644
--- a/src/main/java/com/gitblit/wicket/pages/MyDashboardPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/MyDashboardPage.java
@@ -44,9 +44,9 @@ import com.gitblit.utils.ArrayUtils;
import com.gitblit.utils.MarkdownUtils;
import com.gitblit.utils.StringUtils;
import com.gitblit.wicket.CacheControl;
+import com.gitblit.wicket.CacheControl.LastModified;
import com.gitblit.wicket.GitBlitWebSession;
import com.gitblit.wicket.WicketUtils;
-import com.gitblit.wicket.CacheControl.LastModified;
import com.gitblit.wicket.panels.FilterableProjectList;
import com.gitblit.wicket.panels.FilterableRepositoryList;
@@ -106,8 +106,8 @@ public class MyDashboardPage extends DashboardPage {
Calendar c = Calendar.getInstance();
c.add(Calendar.DATE, -1*daysBack);
Date minimumDate = c.getTime();
-
- // build repo lists
+
+ // build repo lists
List<RepositoryModel> starred = new ArrayList<RepositoryModel>();
List<RepositoryModel> owned = new ArrayList<RepositoryModel>();
List<RepositoryModel> active = new ArrayList<RepositoryModel>();
@@ -116,27 +116,27 @@ public class MyDashboardPage extends DashboardPage {
if (model.isUsersPersonalRepository(user.username) || model.isOwner(user.username)) {
owned.add(model);
}
-
+
if (user.getPreferences().isStarredRepository(model.name)) {
starred.add(model);
}
-
+
if (model.isShowActivity() && model.lastChange.after(minimumDate)) {
active.add(model);
}
}
-
+
Comparator<RepositoryModel> lastUpdateSort = new Comparator<RepositoryModel>() {
@Override
public int compare(RepositoryModel o1, RepositoryModel o2) {
return o2.lastChange.compareTo(o1.lastChange);
}
};
-
+
Collections.sort(owned, lastUpdateSort);
Collections.sort(starred, lastUpdateSort);
Collections.sort(active, lastUpdateSort);
-
+
String activityTitle;
Set<RepositoryModel> feed = new HashSet<RepositoryModel>();
feed.addAll(starred);
@@ -155,22 +155,22 @@ public class MyDashboardPage extends DashboardPage {
// starred and owned repositories
activityTitle = getString("gb.starredAndOwned");
}
-
+
addActivity(user, feed, activityTitle, daysBack);
-
+
Fragment repositoryTabs;
if (UserModel.ANONYMOUS.equals(user)) {
repositoryTabs = new Fragment("repositoryTabs", "anonymousTabsFragment", this);
} else {
repositoryTabs = new Fragment("repositoryTabs", "authenticatedTabsFragment", this);
}
-
+
add(repositoryTabs);
-
+
// projects list
List<ProjectModel> projects = GitBlit.self().getProjectModels(getRepositoryModels(), false);
repositoryTabs.add(new FilterableProjectList("projects", projects));
-
+
// active repository list
if (active.isEmpty()) {
repositoryTabs.add(new Label("active").setVisible(false));
@@ -179,7 +179,7 @@ public class MyDashboardPage extends DashboardPage {
repoList.setTitle(getString("gb.activeRepositories"), "icon-time");
repositoryTabs.add(repoList);
}
-
+
// starred repository list
if (ArrayUtils.isEmpty(starred)) {
repositoryTabs.add(new Label("starred").setVisible(false));
@@ -188,7 +188,7 @@ public class MyDashboardPage extends DashboardPage {
repoList.setTitle(getString("gb.starredRepositories"), "icon-star");
repositoryTabs.add(repoList);
}
-
+
// owned repository list
if (ArrayUtils.isEmpty(owned)) {
repositoryTabs.add(new Label("owned").setVisible(false));
@@ -199,7 +199,7 @@ public class MyDashboardPage extends DashboardPage {
repositoryTabs.add(repoList);
}
}
-
+
private String readMarkdown(String messageSource, String resource) {
String message = "";
if (messageSource.equalsIgnoreCase("gitblit")) {
@@ -268,7 +268,7 @@ public class MyDashboardPage extends DashboardPage {
} catch (Exception e) {
}
}
- }
+ }
}
return MessageFormat.format(getString("gb.failedToReadMessage"), file);
}
diff --git a/src/main/java/com/gitblit/wicket/pages/OverviewPage.java b/src/main/java/com/gitblit/wicket/pages/OverviewPage.java
index e1de9f39..f6362c22 100644
--- a/src/main/java/com/gitblit/wicket/pages/OverviewPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/OverviewPage.java
@@ -35,9 +35,9 @@ import com.gitblit.models.RepositoryModel;
import com.gitblit.models.UserModel;
import com.gitblit.utils.JGitUtils;
import com.gitblit.wicket.CacheControl;
+import com.gitblit.wicket.CacheControl.LastModified;
import com.gitblit.wicket.GitBlitWebSession;
import com.gitblit.wicket.WicketUtils;
-import com.gitblit.wicket.CacheControl.LastModified;
import com.gitblit.wicket.charting.GoogleChart;
import com.gitblit.wicket.charting.GoogleCharts;
import com.gitblit.wicket.charting.GoogleLineChart;
@@ -73,13 +73,14 @@ public class OverviewPage extends RepositoryPage {
// repository description
add(new Label("repositoryDescription", getRepositoryModel().description));
-
+
// owner links
final List<String> owners = new ArrayList<String>(getRepositoryModel().owners);
ListDataProvider<String> ownersDp = new ListDataProvider<String>(owners);
DataView<String> ownersView = new DataView<String>("repositoryOwners", ownersDp) {
private static final long serialVersionUID = 1L;
int counter = 0;
+ @Override
public void populateItem(final Item<String> item) {
String ownername = item.getModelObject();
UserModel ownerModel = GitBlit.self().getUserModel(ownername);
@@ -99,11 +100,11 @@ public class OverviewPage extends RepositoryPage {
};
ownersView.setRenderBodyOnly(true);
add(ownersView);
-
+
add(WicketUtils.createTimestampLabel("repositoryLastChange",
JGitUtils.getLastChange(r).when, getTimeZone(), getTimeUtils()));
add(new Label("repositorySize", model.size));
-
+
if (metricsTotal == null) {
add(new Label("branchStats", ""));
} else {
@@ -134,7 +135,7 @@ public class OverviewPage extends RepositoryPage {
private void insertActivityGraph(List<Metric> metrics) {
if ((metrics != null) && (metrics.size() > 0)
&& GitBlit.getBoolean(Keys.web.generateActivityGraph, true)) {
-
+
// daily line chart
GoogleChart chart = new GoogleLineChart("chartDaily", "", "unit",
getString("gb.commits"));
@@ -143,7 +144,7 @@ public class OverviewPage extends RepositoryPage {
}
chart.setWidth(375);
chart.setHeight(150);
-
+
GoogleCharts charts = new GoogleCharts();
charts.addChart(chart);
add(new HeaderContributor(charts));
diff --git a/src/main/java/com/gitblit/wicket/pages/ProjectPage.java b/src/main/java/com/gitblit/wicket/pages/ProjectPage.java
index c9388913..19588a95 100644
--- a/src/main/java/com/gitblit/wicket/pages/ProjectPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/ProjectPage.java
@@ -46,7 +46,7 @@ import com.gitblit.wicket.panels.FilterableRepositoryList;
@CacheControl(LastModified.PROJECT)
public class ProjectPage extends DashboardPage {
-
+
List<ProjectModel> projectModels = new ArrayList<ProjectModel>();
public ProjectPage() {
@@ -58,7 +58,8 @@ public class ProjectPage extends DashboardPage {
super(params);
setup(params);
}
-
+
+ @Override
protected Class<? extends BasePage> getRootNavPageClass() {
return RepositoriesPage.class;
}
@@ -82,7 +83,7 @@ public class ProjectPage extends DashboardPage {
}
}
}
-
+
private void setup(PageParameters params) {
setupPage("", "");
// check to see if we should display a login message
@@ -96,21 +97,21 @@ public class ProjectPage extends DashboardPage {
if (StringUtils.isEmpty(projectName)) {
throw new GitblitRedirectException(GitBlitWebApp.get().getHomePage());
}
-
+
ProjectModel project = getProjectModel(projectName);
if (project == null) {
throw new GitblitRedirectException(GitBlitWebApp.get().getHomePage());
}
-
+
add(new Label("projectTitle", project.getDisplayName()));
add(new Label("projectDescription", project.description));
-
+
String feedLink = SyndicationServlet.asLink(getRequest().getRelativePathPrefixToContextRoot(), projectName, null, 0);
add(new ExternalLink("syndication", feedLink));
add(WicketUtils.syndicationDiscoveryLink(SyndicationServlet.getTitle(project.getDisplayName(),
null), feedLink));
-
+
// project markdown message
String pmessage = transformMarkdown(project.projectMarkdown);
Component projectMessage = new Label("projectMessage", pmessage)
@@ -135,7 +136,7 @@ public class ProjectPage extends DashboardPage {
// repository list. the recent activity will be built up by the
// reflog utils.
params.remove("db");
-
+
List<RepositoryModel> repositories = getRepositories(params);
Collections.sort(repositories, new Comparator<RepositoryModel>() {
@Override
@@ -146,7 +147,7 @@ public class ProjectPage extends DashboardPage {
});
addActivity(user, repositories, getString("gb.recentActivity"), daysBack);
-
+
if (repositories.isEmpty()) {
add(new Label("repositoryList").setVisible(false));
} else {
@@ -155,7 +156,7 @@ public class ProjectPage extends DashboardPage {
add(repoList);
}
}
-
+
@Override
protected void addDropDownMenus(List<PageRegistration> pages) {
PageParameters params = getPageParameters();
@@ -174,13 +175,13 @@ public class ProjectPage extends DashboardPage {
}
pages.add(menu);
-
+
DropDownMenuRegistration projects = new DropDownMenuRegistration("gb.projects",
ProjectPage.class);
projects.menuItems.addAll(getProjectsMenu());
pages.add(projects);
}
-
+
@Override
protected List<ProjectModel> getProjectModels() {
if (projectModels.isEmpty()) {
@@ -190,7 +191,7 @@ public class ProjectPage extends DashboardPage {
}
return projectModels;
}
-
+
private ProjectModel getProjectModel(String name) {
for (ProjectModel project : getProjectModels()) {
if (name.equalsIgnoreCase(project.name)) {
@@ -199,7 +200,7 @@ public class ProjectPage extends DashboardPage {
}
return null;
}
-
+
protected List<DropDownMenuItem> getProjectsMenu() {
List<DropDownMenuItem> menu = new ArrayList<DropDownMenuItem>();
List<ProjectModel> projects = new ArrayList<ProjectModel>();
@@ -236,7 +237,7 @@ public class ProjectPage extends DashboardPage {
}
return menu;
}
-
+
private String transformMarkdown(String markdown) {
String message = "";
if (!StringUtils.isEmpty(markdown)) {
diff --git a/src/main/java/com/gitblit/wicket/pages/ProjectsPage.java b/src/main/java/com/gitblit/wicket/pages/ProjectsPage.java
index d0001ecb..e5000462 100644
--- a/src/main/java/com/gitblit/wicket/pages/ProjectsPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/ProjectsPage.java
@@ -49,7 +49,7 @@ public class ProjectsPage extends RootPage {
protected boolean reusePageParameters() {
return true;
}
-
+
@Override
protected Class<? extends BasePage> getRootNavPageClass() {
return RepositoriesPage.class;
@@ -83,6 +83,7 @@ public class ProjectsPage extends RootPage {
counter = 0;
}
+ @Override
public void populateItem(final Item<ProjectModel> item) {
final ProjectModel entry = item.getModelObject();
@@ -117,7 +118,7 @@ public class ProjectsPage extends RootPage {
@Override
protected void addDropDownMenus(List<PageRegistration> pages) {
PageParameters params = getPageParameters();
-
+
DropDownMenuRegistration menu = new DropDownMenuRegistration("gb.filters",
ProjectsPage.class);
// preserve time filter option on repository choices
diff --git a/src/main/java/com/gitblit/wicket/pages/RawPage.java b/src/main/java/com/gitblit/wicket/pages/RawPage.java
index d322e955..50268717 100644
--- a/src/main/java/com/gitblit/wicket/pages/RawPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/RawPage.java
@@ -46,7 +46,7 @@ public class RawPage extends SessionPage {
public RawPage(final PageParameters params) {
super(params);
-
+
if (!params.containsKey("r")) {
error(getString("gb.repositoryNotSpecified"));
redirectToInterceptPage(new RepositoriesPage());
@@ -67,7 +67,7 @@ public class RawPage extends SessionPage {
String[] encodings = GitBlit.getEncodings();
GitBlitWebSession session = GitBlitWebSession.get();
UserModel user = session.getUser();
-
+
RepositoryModel model = GitBlit.self().getRepositoryModel(user, repositoryName);
if (model == null) {
// user does not have permission
@@ -75,7 +75,7 @@ public class RawPage extends SessionPage {
redirectToInterceptPage(new RepositoriesPage());
return;
}
-
+
Repository r = GitBlit.self().getRepository(repositoryName);
if (r == null) {
error(getString("gb.canNotLoadRepository") + " " + repositoryName);
@@ -138,11 +138,11 @@ public class RawPage extends SessionPage {
byte[] binary = JGitUtils.getByteContent(r, commit.getTree(), blobPath, true);
response.setContentLength(binary.length);
response.setContentType("application/octet-stream; charset=UTF-8");
-
+
try {
WebRequest request = (WebRequest) requestCycle.getRequest();
String userAgent = request.getHttpServletRequest().getHeader("User-Agent");
-
+
if (userAgent != null && userAgent.indexOf("MSIE 5.5") > -1) {
response.setHeader("Content-Disposition", "filename=\""
+ URLEncoder.encode(filename, "UTF-8") + "\"");
@@ -157,7 +157,7 @@ public class RawPage extends SessionPage {
catch (UnsupportedEncodingException e) {
response.setHeader("Content-Disposition", "attachment; filename=\"" + filename + "\"");
}
-
+
try {
response.getOutputStream().write(binary);
} catch (IOException e) {
diff --git a/src/main/java/com/gitblit/wicket/pages/ReflogPage.java b/src/main/java/com/gitblit/wicket/pages/ReflogPage.java
index c97b2cc1..29fd449f 100644
--- a/src/main/java/com/gitblit/wicket/pages/ReflogPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/ReflogPage.java
@@ -19,8 +19,8 @@ import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import com.gitblit.wicket.CacheControl;
-import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.CacheControl.LastModified;
+import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.panels.ReflogPanel;
@CacheControl(LastModified.REPOSITORY)
diff --git a/src/main/java/com/gitblit/wicket/pages/RepositoriesPage.java b/src/main/java/com/gitblit/wicket/pages/RepositoriesPage.java
index a4a1ab58..b446279a 100644
--- a/src/main/java/com/gitblit/wicket/pages/RepositoriesPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/RepositoriesPage.java
@@ -34,9 +34,9 @@ import com.gitblit.models.RepositoryModel;
import com.gitblit.utils.MarkdownUtils;
import com.gitblit.utils.StringUtils;
import com.gitblit.wicket.CacheControl;
+import com.gitblit.wicket.CacheControl.LastModified;
import com.gitblit.wicket.GitBlitWebSession;
import com.gitblit.wicket.PageRegistration;
-import com.gitblit.wicket.CacheControl.LastModified;
import com.gitblit.wicket.PageRegistration.DropDownMenuItem;
import com.gitblit.wicket.PageRegistration.DropDownMenuRegistration;
import com.gitblit.wicket.WicketUtils;
@@ -180,7 +180,7 @@ public class RepositoriesPage extends RootPage {
} catch (Exception e) {
}
}
- }
+ }
}
return MessageFormat.format(getString("gb.failedToReadMessage"), file);
}
diff --git a/src/main/java/com/gitblit/wicket/pages/ReviewProposalPage.java b/src/main/java/com/gitblit/wicket/pages/ReviewProposalPage.java
index e1813861..ebe15304 100644
--- a/src/main/java/com/gitblit/wicket/pages/ReviewProposalPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/ReviewProposalPage.java
@@ -50,14 +50,14 @@ public class ReviewProposalPage extends RootSubPage {
}
setupPage(getString("gb.proposals"), proposal.url);
-
+
add(new Label("url", proposal.url));
add(new Label("message", proposal.message));
add(WicketUtils.createTimestampLabel("received", proposal.received, getTimeZone(), getTimeUtils()));
add(new Label("token", proposal.token));
add(new Label("tokenType", proposal.tokenType.name()));
-
+
String p;
if (GitBlit.isGO()) {
// gitblit.properties definition
diff --git a/src/main/java/com/gitblit/wicket/pages/RootPage.java b/src/main/java/com/gitblit/wicket/pages/RootPage.java
index ec4e9b43..a59e2022 100644
--- a/src/main/java/com/gitblit/wicket/pages/RootPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/RootPage.java
@@ -65,9 +65,9 @@ import com.gitblit.wicket.panels.NavigationPanel;
/**
* Root page is a topbar, navigable page like Repositories, Users, or
* Federation.
- *
+ *
* @author James Moger
- *
+ *
*/
public abstract class RootPage extends BasePage {
@@ -92,6 +92,7 @@ public abstract class RootPage extends BasePage {
add(new HeaderContributor(new IHeaderContributor() {
private static final long serialVersionUID = 1L;
+ @Override
public void renderHead(IHeaderResponse response) {
StringBuilder buffer = new StringBuilder();
buffer.append("<style type=\"text/css\">\n");
@@ -130,7 +131,7 @@ public abstract class RootPage extends BasePage {
response.renderString(buffer.toString());
}
}));
-
+
boolean authenticateView = GitBlit.getBoolean(Keys.web.authenticateViewPages, false);
boolean authenticateAdmin = GitBlit.getBoolean(Keys.web.authenticateAdminPages, true);
boolean allowAdmin = GitBlit.getBoolean(Keys.web.allowAdministration, true);
@@ -149,7 +150,7 @@ public abstract class RootPage extends BasePage {
setStatelessHint(true);
}
}
-
+
if (authenticateView || authenticateAdmin) {
if (GitBlitWebSession.get().isLoggedIn()) {
UserMenu userFragment = new UserMenu("userPanel", "userMenuFragment", RootPage.this);
@@ -161,7 +162,7 @@ public abstract class RootPage extends BasePage {
} else {
add(new Label("userPanel").setVisible(false));
}
-
+
boolean showRegistrations = GitBlit.canFederate()
&& GitBlit.getBoolean(Keys.web.showFederationRegistrations, false);
@@ -187,7 +188,7 @@ public abstract class RootPage extends BasePage {
addDropDownMenus(pages);
}
}
-
+
NavigationPanel navPanel = new NavigationPanel("navPanel", getRootNavPageClass(), pages);
add(navPanel);
@@ -207,7 +208,7 @@ public abstract class RootPage extends BasePage {
super.setupPage(repositoryName, pageName);
}
-
+
protected Class<? extends BasePage> getRootNavPageClass() {
return getClass();
}
@@ -232,7 +233,7 @@ public abstract class RootPage extends BasePage {
params.remove("db");
}
return params;
- }
+ }
}
return null;
}
@@ -269,7 +270,7 @@ public abstract class RootPage extends BasePage {
}
}
}
-
+
protected List<RepositoryModel> getRepositoryModels() {
if (repositoryModels.isEmpty()) {
final UserModel user = GitBlitWebSession.get().getUser();
@@ -359,11 +360,11 @@ public abstract class RootPage extends BasePage {
} else {
clonedParams = new PageParameters(params);
}
-
+
if (!clonedParams.containsKey("db")) {
clonedParams.put("db", daysBack);
}
-
+
List<DropDownMenuItem> items = new ArrayList<DropDownMenuItem>();
Set<Integer> choicesSet = new TreeSet<Integer>(GitBlit.getIntegers(Keys.web.activityDurationChoices));
if (choicesSet.isEmpty()) {
@@ -420,7 +421,7 @@ public abstract class RootPage extends BasePage {
if (!StringUtils.isEmpty(projectName)) {
// try named project
- hasParameter = true;
+ hasParameter = true;
if (projectName.equalsIgnoreCase(GitBlit.getString(Keys.web.repositoryRootGroupName, "main"))) {
// root project/group
for (RepositoryModel model : availableModels) {
@@ -511,14 +512,14 @@ public abstract class RootPage extends BasePage {
}
models = timeFiltered;
}
-
+
List<RepositoryModel> list = new ArrayList<RepositoryModel>(models);
Collections.sort(list);
return list;
}
-
+
/**
- * Inline login form.
+ * Inline login form.
*/
private class LoginForm extends Fragment {
private static final long serialVersionUID = 1L;
@@ -558,7 +559,7 @@ public abstract class RootPage extends BasePage {
add(loginForm);
}
}
-
+
/**
* Menu for the authenticated user.
*/
@@ -587,12 +588,12 @@ public abstract class RootPage extends BasePage {
add(new BookmarkablePageLink<Void>("newRepository",
EditRepositoryPage.class).setVisible(user.canAdmin() || user.canCreate()));
- add(new BookmarkablePageLink<Void>("myProfile",
+ add(new BookmarkablePageLink<Void>("myProfile",
UserPage.class, WicketUtils.newUsernameParameter(user.username)));
- add(new BookmarkablePageLink<Void>("changePassword",
+ add(new BookmarkablePageLink<Void>("changePassword",
ChangePasswordPage.class).setVisible(editCredentials));
-
+
add(new BookmarkablePageLink<Void>("logout",
LogoutPage.class).setVisible(standardLogin));
}
diff --git a/src/main/java/com/gitblit/wicket/pages/RootSubPage.java b/src/main/java/com/gitblit/wicket/pages/RootSubPage.java
index 0be714e2..e81717a1 100644
--- a/src/main/java/com/gitblit/wicket/pages/RootSubPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/RootSubPage.java
@@ -32,9 +32,9 @@ import com.gitblit.utils.StringUtils;
/**
* RootSubPage is a non-topbar navigable RootPage. It also has a page header.
- *
+ *
* @author James Moger
- *
+ *
*/
public abstract class RootSubPage extends RootPage {
@@ -47,11 +47,11 @@ public abstract class RootSubPage extends RootPage {
super(params);
createPageMapIfNeeded();
}
-
+
protected boolean requiresPageMap() {
return false;
}
-
+
protected void createPageMapIfNeeded() {
if (requiresPageMap()) {
// because Gitblit strives for page-statelessness
@@ -72,7 +72,7 @@ public abstract class RootSubPage extends RootPage {
add(new Label("pageSubName", subName));
super.setupPage("", pageName);
}
-
+
protected List<String> getAccessRestrictedRepositoryList(boolean includeWildcards, UserModel user) {
// build list of access-restricted projects
String lastProject = null;
@@ -85,7 +85,7 @@ public abstract class RootSubPage extends RootPage {
repos.add("[^" + ModelUtils.getUserRepoPrefix() + "].*");
}
}
-
+
for (String repo : GitBlit.self().getRepositoryList()) {
RepositoryModel repositoryModel = GitBlit.self().getRepositoryModel(repo);
if (repositoryModel.accessRestriction.exceeds(AccessRestrictionType.NONE)
diff --git a/src/main/java/com/gitblit/wicket/pages/SendProposalPage.java b/src/main/java/com/gitblit/wicket/pages/SendProposalPage.java
index a0706695..b1a8c5b6 100644
--- a/src/main/java/com/gitblit/wicket/pages/SendProposalPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/SendProposalPage.java
@@ -149,7 +149,7 @@ public class SendProposalPage extends RootSubPage {
false, repositories, false, getAccessRestrictions());
add(repositoriesPanel);
}
-
+
@Override
protected Class<? extends BasePage> getRootNavPageClass() {
return FederationPage.class;
diff --git a/src/main/java/com/gitblit/wicket/pages/SummaryPage.java b/src/main/java/com/gitblit/wicket/pages/SummaryPage.java
index 17c41eb2..00d77a4e 100644
--- a/src/main/java/com/gitblit/wicket/pages/SummaryPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/SummaryPage.java
@@ -51,9 +51,9 @@ import com.gitblit.utils.JGitUtils;
import com.gitblit.utils.MarkdownUtils;
import com.gitblit.utils.StringUtils;
import com.gitblit.wicket.CacheControl;
+import com.gitblit.wicket.CacheControl.LastModified;
import com.gitblit.wicket.GitBlitWebSession;
import com.gitblit.wicket.WicketUtils;
-import com.gitblit.wicket.CacheControl.LastModified;
import com.gitblit.wicket.charting.SecureChart;
import com.gitblit.wicket.panels.BranchesPanel;
import com.gitblit.wicket.panels.LinkPanel;
@@ -91,13 +91,14 @@ public class SummaryPage extends RepositoryPage {
// repository description
add(new Label("repositoryDescription", getRepositoryModel().description));
-
+
// owner links
final List<String> owners = new ArrayList<String>(getRepositoryModel().owners);
ListDataProvider<String> ownersDp = new ListDataProvider<String>(owners);
DataView<String> ownersView = new DataView<String>("repositoryOwners", ownersDp) {
private static final long serialVersionUID = 1L;
int counter = 0;
+ @Override
public void populateItem(final Item<String> item) {
String ownername = item.getModelObject();
UserModel ownerModel = GitBlit.self().getUserModel(ownername);
@@ -117,7 +118,7 @@ public class SummaryPage extends RepositoryPage {
};
ownersView.setRenderBodyOnly(true);
add(ownersView);
-
+
add(WicketUtils.createTimestampLabel("repositoryLastChange",
JGitUtils.getLastChange(r).when, getTimeZone(), getTimeUtils()));
add(new Label("repositorySize", getRepositoryModel().size));
@@ -132,7 +133,7 @@ public class SummaryPage extends RepositoryPage {
WicketUtils.newRepositoryParameter(repositoryName)));
add(new RepositoryUrlPanel("repositoryUrlPanel", false, user, model));
-
+
add(new LogPanel("commitsPanel", repositoryName, getRepositoryModel().HEAD, r, numberCommits, 0, getRepositoryModel().showRemoteBranches));
add(new TagsPanel("tagsPanel", repositoryName, r, numberRefs).hideIfEmpty());
add(new BranchesPanel("branchesPanel", getRepositoryModel(), r, numberRefs, false).hideIfEmpty());
@@ -144,7 +145,7 @@ public class SummaryPage extends RepositoryPage {
try {
RevCommit head = JGitUtils.getCommit(r, null);
List<String> markdownExtensions = GitBlit.getStrings(Keys.web.markdownExtensions);
- List<PathModel> paths = JGitUtils.getFilesInPath(r, null, head);
+ List<PathModel> paths = JGitUtils.getFilesInPath(r, null, head);
for (PathModel path : paths) {
if (!path.isTree()) {
String name = path.name.toLowerCase();
diff --git a/src/main/java/com/gitblit/wicket/pages/TagPage.java b/src/main/java/com/gitblit/wicket/pages/TagPage.java
index b8b6eef0..afade81c 100644
--- a/src/main/java/com/gitblit/wicket/pages/TagPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/TagPage.java
@@ -78,7 +78,7 @@ public class TagPage extends RepositoryPage {
break;
}
add(new GravatarImage("taggerAvatar", tagRef.getAuthorIdent()));
-
+
add(new RefsPanel("tagName", repositoryName, Arrays.asList(tagRef)));
add(new Label("tagId", tagRef.getObjectId().getName()));
add(new LinkPanel("taggedObject", "list", tagRef.getReferencedObjectId().getName(),
@@ -99,7 +99,7 @@ public class TagPage extends RepositoryPage {
protected String getPageName() {
return getString("gb.tag");
}
-
+
@Override
protected Class<? extends BasePage> getRepoNavPageClass() {
return LogPage.class;
diff --git a/src/main/java/com/gitblit/wicket/pages/TagsPage.java b/src/main/java/com/gitblit/wicket/pages/TagsPage.java
index 2abb410a..d6b8abb2 100644
--- a/src/main/java/com/gitblit/wicket/pages/TagsPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/TagsPage.java
@@ -35,7 +35,7 @@ public class TagsPage extends RepositoryPage {
protected String getPageName() {
return getString("gb.tags");
}
-
+
@Override
protected Class<? extends BasePage> getRepoNavPageClass() {
return LogPage.class;
diff --git a/src/main/java/com/gitblit/wicket/pages/TreePage.java b/src/main/java/com/gitblit/wicket/pages/TreePage.java
index 25bcd67a..870b75d1 100644
--- a/src/main/java/com/gitblit/wicket/pages/TreePage.java
+++ b/src/main/java/com/gitblit/wicket/pages/TreePage.java
@@ -86,6 +86,7 @@ public class TreePage extends RepositoryPage {
private static final long serialVersionUID = 1L;
int counter;
+ @Override
public void populateItem(final Item<PathModel> item) {
PathModel entry = item.getModelObject();
item.add(new Label("pathPermissions", JGitUtils.getPermissionsFromMode(entry.mode)));
@@ -113,26 +114,26 @@ public class TreePage extends RepositoryPage {
entry.path)));
links.add(new BookmarkablePageLink<Void>("history", HistoryPage.class,
WicketUtils.newPathParameter(repositoryName, entry.commitId,
- entry.path)));
+ entry.path)));
links.add(new CompressedDownloadsPanel("compressedLinks", baseUrl,
repositoryName, objectId, entry.path));
item.add(links);
} else if (entry.isSubmodule()) {
// submodule
- String submoduleId = entry.objectId;
+ String submoduleId = entry.objectId;
String submodulePath;
boolean hasSubmodule = false;
SubmoduleModel submodule = getSubmodule(entry.path);
submodulePath = submodule.gitblitPath;
hasSubmodule = submodule.hasSubmodule;
-
+
item.add(WicketUtils.newImage("pathIcon", "git-orange-16x16.png"));
item.add(new Label("pathSize", ""));
- item.add(new LinkPanel("pathName", "list", entry.name + " @ " +
+ item.add(new LinkPanel("pathName", "list", entry.name + " @ " +
getShortObjectId(submoduleId), TreePage.class,
WicketUtils.newPathParameter(submodulePath, submoduleId, "")).setEnabled(hasSubmodule));
-
+
Fragment links = new Fragment("pathLinks", "submoduleLinks", this);
links.add(new BookmarkablePageLink<Void>("view", SummaryPage.class,
WicketUtils.newRepositoryParameter(submodulePath)).setEnabled(hasSubmodule));
@@ -144,7 +145,7 @@ public class TreePage extends RepositoryPage {
entry.path)));
links.add(new CompressedDownloadsPanel("compressedLinks", baseUrl,
submodulePath, submoduleId, "").setEnabled(hasSubmodule));
- item.add(links);
+ item.add(links);
} else {
// blob link
String displayPath = entry.name;
diff --git a/src/main/java/com/gitblit/wicket/pages/UserPage.java b/src/main/java/com/gitblit/wicket/pages/UserPage.java
index 4faee20b..4b62e797 100644
--- a/src/main/java/com/gitblit/wicket/pages/UserPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/UserPage.java
@@ -46,7 +46,7 @@ import com.gitblit.wicket.panels.LinkPanel;
import com.gitblit.wicket.panels.ProjectRepositoryPanel;
public class UserPage extends RootPage {
-
+
List<ProjectModel> projectModels = new ArrayList<ProjectModel>();
public UserPage() {
@@ -83,23 +83,23 @@ public class UserPage extends RootPage {
// construct a temporary user model
user = new UserModel(userName);
}
-
+
String projectName = user.getPersonalPath();
-
+
ProjectModel project = GitBlit.self().getProjectModel(projectName);
if (project == null) {
project = new ProjectModel(projectName);
}
-
+
add(new Label("userDisplayName", user.getDisplayName()));
add(new Label("userUsername", user.username));
LinkPanel email = new LinkPanel("userEmail", null, user.emailAddress, "mailto:#");
email.setRenderBodyOnly(true);
add(email.setVisible(GitBlit.getBoolean(Keys.web.showEmailAddresses, true) && !StringUtils.isEmpty(user.emailAddress)));
-
+
PersonIdent person = new PersonIdent(user.getDisplayName(), user.emailAddress == null ? user.getDisplayName() : user.emailAddress);
add(new GravatarImage("gravatar", person, 210));
-
+
UserModel sessionUser = GitBlitWebSession.get().getUser();
if (sessionUser != null && user.canCreate() && sessionUser.equals(user)) {
// user can create personal repositories
@@ -107,9 +107,9 @@ public class UserPage extends RootPage {
} else {
add(new Label("newRepository").setVisible(false));
}
-
+
List<RepositoryModel> repositories = getRepositories(params);
-
+
Collections.sort(repositories, new Comparator<RepositoryModel>() {
@Override
public int compare(RepositoryModel o1, RepositoryModel o2) {
@@ -122,10 +122,11 @@ public class UserPage extends RootPage {
DataView<RepositoryModel> dataView = new DataView<RepositoryModel>("repositoryList", dp) {
private static final long serialVersionUID = 1L;
+ @Override
public void populateItem(final Item<RepositoryModel> item) {
final RepositoryModel entry = item.getModelObject();
-
- ProjectRepositoryPanel row = new ProjectRepositoryPanel("repository",
+
+ ProjectRepositoryPanel row = new ProjectRepositoryPanel("repository",
getLocalizer(), this, showAdmin, entry, getAccessRestrictions());
item.add(row);
}
diff --git a/src/main/java/com/gitblit/wicket/pages/UsersPage.java b/src/main/java/com/gitblit/wicket/pages/UsersPage.java
index 9526deae..652bdba6 100644
--- a/src/main/java/com/gitblit/wicket/pages/UsersPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/UsersPage.java
@@ -23,11 +23,11 @@ import com.gitblit.wicket.panels.UsersPanel;
public class UsersPage extends RootPage {
public UsersPage() {
- super();
+ super();
setupPage("", "");
add(new TeamsPanel("teamsPanel", showAdmin).setVisible(showAdmin));
-
+
add(new UsersPanel("usersPanel", showAdmin).setVisible(showAdmin));
}
}
diff --git a/src/main/java/com/gitblit/wicket/panels/ActivityPanel.java b/src/main/java/com/gitblit/wicket/panels/ActivityPanel.java
index b509f655..e5c8e464 100644
--- a/src/main/java/com/gitblit/wicket/panels/ActivityPanel.java
+++ b/src/main/java/com/gitblit/wicket/panels/ActivityPanel.java
@@ -40,9 +40,9 @@ import com.gitblit.wicket.pages.TreePage;
/**
* Renders activity in day-blocks in reverse-chronological order.
- *
+ *
* @author James Moger
- *
+ *
*/
public class ActivityPanel extends BasePanel {
@@ -52,12 +52,13 @@ public class ActivityPanel extends BasePanel {
super(wicketId);
Collections.sort(recentActivity);
-
+
final int shortHashLen = GitBlit.getInteger(Keys.web.shortCommitIdLength, 6);
DataView<Activity> activityView = new DataView<Activity>("activity",
new ListDataProvider<Activity>(recentActivity)) {
private static final long serialVersionUID = 1L;
+ @Override
public void populateItem(final Item<Activity> activityItem) {
final Activity entry = activityItem.getModelObject();
activityItem.add(WicketUtils.createDatestampLabel("title", entry.startDate, getTimeZone(), getTimeUtils()));
@@ -67,6 +68,7 @@ public class ActivityPanel extends BasePanel {
new ListDataProvider<RepositoryCommit>(entry.getCommits())) {
private static final long serialVersionUID = 1L;
+ @Override
public void populateItem(final Item<RepositoryCommit> commitItem) {
final RepositoryCommit commit = commitItem.getModelObject();
@@ -138,7 +140,7 @@ public class ActivityPanel extends BasePanel {
WicketUtils.newObjectParameter(commit.repository, commit.getName()))
.setEnabled(commit.getParentCount() > 0));
commitItem.add(new BookmarkablePageLink<Void>("tree", TreePage.class,
- WicketUtils.newObjectParameter(commit.repository, commit.getName())));
+ WicketUtils.newObjectParameter(commit.repository, commit.getName())));
}
};
activityItem.add(commits);
diff --git a/src/main/java/com/gitblit/wicket/panels/BasePanel.java b/src/main/java/com/gitblit/wicket/panels/BasePanel.java
index e4aeeb02..b60579b7 100644
--- a/src/main/java/com/gitblit/wicket/panels/BasePanel.java
+++ b/src/main/java/com/gitblit/wicket/panels/BasePanel.java
@@ -33,7 +33,7 @@ import com.gitblit.wicket.WicketUtils;
public abstract class BasePanel extends Panel {
private static final long serialVersionUID = 1L;
-
+
private transient TimeUtils timeUtils;
public BasePanel(String wicketId) {
@@ -44,10 +44,10 @@ public abstract class BasePanel extends Panel {
return GitBlit.getBoolean(Keys.web.useClientTimezone, false) ? GitBlitWebSession.get()
.getTimezone() : GitBlit.getTimezone();
}
-
+
protected TimeUtils getTimeUtils() {
if (timeUtils == null) {
- ResourceBundle bundle;
+ ResourceBundle bundle;
try {
bundle = ResourceBundle.getBundle("com.gitblit.wicket.GitBlitWebApp", GitBlitWebSession.get().getLocale());
} catch (Throwable t) {
@@ -57,7 +57,7 @@ public abstract class BasePanel extends Panel {
}
return timeUtils;
}
-
+
protected void setPersonSearchTooltip(Component component, String value, Constants.SearchType searchType) {
if (searchType.equals(Constants.SearchType.AUTHOR)) {
WicketUtils.setHtmlTooltip(component, getString("gb.searchForAuthor") + " " + value);
@@ -74,6 +74,7 @@ public abstract class BasePanel extends Panel {
super(event, true, new Model<String>(msg));
}
+ @Override
protected String newValue(final String currentValue, final String replacementValue) {
String prefix = "var conf = confirm('" + replacementValue + "'); "
+ "if (!conf) return false; ";
@@ -90,12 +91,13 @@ public abstract class BasePanel extends Panel {
private static final long serialVersionUID = 1L;
private String initialValue = "";
-
+
public JavascriptTextPrompt(String event, String msg, String value) {
super(event, true, new Model<String>(msg));
initialValue = value;
}
+ @Override
protected String newValue(final String currentValue, final String message) {
String result = "var userText = prompt('" + message + "','"
+ (initialValue == null ? "" : initialValue) + "'); " + "return userText; ";
diff --git a/src/main/java/com/gitblit/wicket/panels/BranchesPanel.java b/src/main/java/com/gitblit/wicket/panels/BranchesPanel.java
index dba40897..4981c8b2 100644
--- a/src/main/java/com/gitblit/wicket/panels/BranchesPanel.java
+++ b/src/main/java/com/gitblit/wicket/panels/BranchesPanel.java
@@ -101,15 +101,16 @@ public class BranchesPanel extends BasePanel {
// branches page
add(new Label("branches", new StringResourceModel("gb.branches", this, null)));
}
-
+
// only allow delete if we have multiple branches
final boolean showDelete = showAdmin && branches.size() > 1;
-
+
ListDataProvider<RefModel> branchesDp = new ListDataProvider<RefModel>(branches);
DataView<RefModel> branchesView = new DataView<RefModel>("branch", branchesDp) {
private static final long serialVersionUID = 1L;
int counter;
+ @Override
public void populateItem(final Item<RefModel> item) {
final RefModel entry = item.getModelObject();
@@ -136,7 +137,7 @@ public class BranchesPanel extends BasePanel {
WicketUtils.setHtmlTooltip(shortlog, shortMessage);
}
item.add(shortlog);
-
+
if (maxCount <= 0) {
Fragment fragment = new Fragment("branchLinks", showDelete? "branchPageAdminLinks" : "branchPageLinks", this);
fragment.add(new BookmarkablePageLink<Void>("log", LogPage.class, WicketUtils
@@ -219,15 +220,15 @@ public class BranchesPanel extends BasePanel {
RefLogUtils.deleteRef(user, r, ref);
}
}
-
+
if (success) {
- info(MessageFormat.format("Branch \"{0}\" deleted", branch));
+ info(MessageFormat.format("Branch \"{0}\" deleted", branch));
} else {
error(MessageFormat.format("Failed to delete branch \"{0}\"", branch));
}
}
r.close();
-
+
// redirect to the owning page
PageParameters params = WicketUtils.newRepositoryParameter(repositoryModel.name);
String relativeUrl = urlFor(getPage().getClass(), params).toString();
@@ -235,7 +236,7 @@ public class BranchesPanel extends BasePanel {
getRequestCycle().setRequestTarget(new RedirectRequestTarget(absoluteUrl));
}
};
-
+
deleteLink.add(new JavascriptEventConfirmation("onclick", MessageFormat.format(
"Delete branch \"{0}\"?", entry.displayName )));
return deleteLink;
diff --git a/src/main/java/com/gitblit/wicket/panels/BulletListPanel.java b/src/main/java/com/gitblit/wicket/panels/BulletListPanel.java
index e49223e0..defc08e2 100644
--- a/src/main/java/com/gitblit/wicket/panels/BulletListPanel.java
+++ b/src/main/java/com/gitblit/wicket/panels/BulletListPanel.java
@@ -38,6 +38,7 @@ public class BulletListPanel extends Panel {
DataView<String> listView = new DataView<String>("list", listDp) {
private static final long serialVersionUID = 1L;
+ @Override
public void populateItem(final Item<String> item) {
String entry = item.getModelObject();
item.add(new Label("listItem", entry));
diff --git a/src/main/java/com/gitblit/wicket/panels/CommitLegendPanel.java b/src/main/java/com/gitblit/wicket/panels/CommitLegendPanel.java
index 1e906ef7..3f31effe 100644
--- a/src/main/java/com/gitblit/wicket/panels/CommitLegendPanel.java
+++ b/src/main/java/com/gitblit/wicket/panels/CommitLegendPanel.java
@@ -44,6 +44,7 @@ public class CommitLegendPanel extends Panel {
DataView<ChangeType> legendsView = new DataView<ChangeType>("legend", legendDp) {
private static final long serialVersionUID = 1L;
+ @Override
public void populateItem(final Item<ChangeType> item) {
ChangeType entry = item.getModelObject();
diff --git a/src/main/java/com/gitblit/wicket/panels/CompressedDownloadsPanel.java b/src/main/java/com/gitblit/wicket/panels/CompressedDownloadsPanel.java
index 122ae55e..d8a4a106 100644
--- a/src/main/java/com/gitblit/wicket/panels/CompressedDownloadsPanel.java
+++ b/src/main/java/com/gitblit/wicket/panels/CompressedDownloadsPanel.java
@@ -17,7 +17,6 @@ package com.gitblit.wicket.panels;
import java.util.List;
-import org.apache.wicket.Component;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.markup.repeater.Item;
@@ -35,13 +34,13 @@ public class CompressedDownloadsPanel extends Panel {
public CompressedDownloadsPanel(String id, final String baseUrl, final String repositoryName, final String objectId, final String path) {
super(id);
-
+
List<String> types = GitBlit.getStrings(Keys.web.compressedDownloads);
if (types.isEmpty()) {
types.add(Format.zip.name());
types.add(Format.gz.name());
}
-
+
ListDataProvider<String> refsDp = new ListDataProvider<String>(types);
DataView<String> refsView = new DataView<String>("compressedLinks", refsDp) {
private static final long serialVersionUID = 1L;
@@ -52,12 +51,12 @@ public class CompressedDownloadsPanel extends Panel {
super.onBeforeRender();
counter = 0;
}
-
+
@Override
public void populateItem(final Item<String> item) {
String compressionType = item.getModelObject();
Format format = Format.fromName(compressionType);
-
+
String href = DownloadZipServlet.asLink(baseUrl, repositoryName,
objectId, path, format);
LinkPanel c = new LinkPanel("compressedLink", null, format.name(), href);
@@ -72,7 +71,7 @@ public class CompressedDownloadsPanel extends Panel {
}
};
add(refsView);
-
+
setVisible(GitBlit.getBoolean(Keys.web.allowZipDownloads, true));
}
} \ No newline at end of file
diff --git a/src/main/java/com/gitblit/wicket/panels/DigestsPanel.java b/src/main/java/com/gitblit/wicket/panels/DigestsPanel.java
index 3590dfee..10d5d1b3 100644
--- a/src/main/java/com/gitblit/wicket/panels/DigestsPanel.java
+++ b/src/main/java/com/gitblit/wicket/panels/DigestsPanel.java
@@ -49,7 +49,7 @@ public class DigestsPanel extends BasePanel {
private static final long serialVersionUID = 1L;
private final boolean hasChanges;
-
+
private boolean hasMore;
public DigestsPanel(String wicketId, List<DailyLogEntry> digests) {
@@ -63,11 +63,12 @@ public class DigestsPanel extends BasePanel {
final DateFormat df = new SimpleDateFormat(dateFormat);
df.setTimeZone(timezone);
final Calendar cal = Calendar.getInstance(timezone);
-
+
ListDataProvider<DailyLogEntry> dp = new ListDataProvider<DailyLogEntry>(digests);
DataView<DailyLogEntry> pushView = new DataView<DailyLogEntry>("change", dp) {
private static final long serialVersionUID = 1L;
+ @Override
public void populateItem(final Item<DailyLogEntry> logItem) {
final DailyLogEntry change = logItem.getModelObject();
String fullRefName = change.getChangedRefs().get(0);
@@ -79,7 +80,7 @@ public class DigestsPanel extends BasePanel {
shortRefName = shortRefName.substring(Constants.R_TAGS.length());
isTag = true;
}
-
+
String fuzzydate;
TimeUtils tu = getTimeUtils();
Date pushDate = change.date;
@@ -122,7 +123,7 @@ public class DigestsPanel extends BasePanel {
} else {
logItem.add(new Label("whoChanged").setVisible(false));
}
-
+
String preposition = "gb.of";
boolean isDelete = false;
String what;
@@ -150,17 +151,17 @@ public class DigestsPanel extends BasePanel {
break;
default:
what = MessageFormat.format(change.getCommitCount() > 1 ? getString("gb.commitsTo") : getString("gb.oneCommitTo"), change.getCommitCount());
-
+
if (change.getAuthorCount() == 1) {
by = MessageFormat.format(getString("gb.byOneAuthor"), change.getAuthorIdent().getName());
} else {
- by = MessageFormat.format(getString("gb.byNAuthors"), change.getAuthorCount());
+ by = MessageFormat.format(getString("gb.byNAuthors"), change.getAuthorCount());
}
break;
}
logItem.add(new Label("whatChanged", what));
logItem.add(new Label("byAuthors", by).setVisible(!StringUtils.isEmpty(by)));
-
+
if (isDelete) {
// can't link to deleted ref
logItem.add(new Label("refChanged", shortRefName));
@@ -173,19 +174,19 @@ public class DigestsPanel extends BasePanel {
logItem.add(new LinkPanel("refChanged", null, shortRefName,
TreePage.class, WicketUtils.newObjectParameter(change.repository, fullRefName)));
}
-
+
// to/from/etc
logItem.add(new Label("repoPreposition", getString(preposition)));
String repoName = StringUtils.stripDotGit(change.repository);
logItem.add(new LinkPanel("repoChanged", null, repoName,
SummaryPage.class, WicketUtils.newRepositoryParameter(change.repository)));
-
+
int maxCommitCount = 5;
List<RepositoryCommit> commits = change.getCommits();
if (commits.size() > maxCommitCount) {
- commits = new ArrayList<RepositoryCommit>(commits.subList(0, maxCommitCount));
+ commits = new ArrayList<RepositoryCommit>(commits.subList(0, maxCommitCount));
}
-
+
// compare link
String compareLinkText = null;
if ((change.getCommitCount() <= maxCommitCount) && (change.getCommitCount() > 1)) {
@@ -201,20 +202,21 @@ public class DigestsPanel extends BasePanel {
String startRangeId = change.getOldId(fullRefName);
logItem.add(new LinkPanel("compareLink", null, compareLinkText, ComparePage.class, WicketUtils.newRangeParameter(change.repository, startRangeId, endRangeId)));
}
-
+
final boolean showSwatch = GitBlit.getBoolean(Keys.web.repositoryListSwatches, true);
-
+
ListDataProvider<RepositoryCommit> cdp = new ListDataProvider<RepositoryCommit>(commits);
DataView<RepositoryCommit> commitsView = new DataView<RepositoryCommit>("commit", cdp) {
private static final long serialVersionUID = 1L;
+ @Override
public void populateItem(final Item<RepositoryCommit> commitItem) {
final RepositoryCommit commit = commitItem.getModelObject();
// author gravatar
commitItem.add(new GravatarImage("commitAuthor", commit.getAuthorIdent().getName(),
commit.getAuthorIdent().getEmailAddress(), null, 16, false, false));
-
+
// merge icon
if (commit.getParentCount() > 1) {
commitItem.add(WicketUtils.newImage("commitIcon", "commit_merge_16x16.png"));
@@ -245,7 +247,7 @@ public class DigestsPanel extends BasePanel {
WicketUtils.setCssClass(commitHash, "shortsha1");
WicketUtils.setHtmlTooltip(commitHash, commit.getName());
commitItem.add(commitHash);
-
+
if (showSwatch) {
// set repository color
String color = StringUtils.getColor(StringUtils.stripDotGit(change.repository));
@@ -257,14 +259,14 @@ public class DigestsPanel extends BasePanel {
logItem.add(commitsView);
}
};
-
+
add(pushView);
}
public boolean hasMore() {
return hasMore;
}
-
+
public boolean hideIfEmpty() {
setVisible(hasChanges);
return hasChanges;
diff --git a/src/main/java/com/gitblit/wicket/panels/DropDownMenu.java b/src/main/java/com/gitblit/wicket/panels/DropDownMenu.java
index 60a8a3d2..d1a632e2 100644
--- a/src/main/java/com/gitblit/wicket/panels/DropDownMenu.java
+++ b/src/main/java/com/gitblit/wicket/panels/DropDownMenu.java
@@ -38,6 +38,7 @@ public class DropDownMenu extends Panel {
DataView<DropDownMenuItem> view = new DataView<DropDownMenuItem>("menuItems", items) {
private static final long serialVersionUID = 1L;
+ @Override
public void populateItem(final Item<DropDownMenuItem> item) {
DropDownMenuItem entry = item.getModelObject();
if (entry.isDivider()) {
diff --git a/src/main/java/com/gitblit/wicket/panels/FederationProposalsPanel.java b/src/main/java/com/gitblit/wicket/panels/FederationProposalsPanel.java
index 3e70ccec..c15a0a5c 100644
--- a/src/main/java/com/gitblit/wicket/panels/FederationProposalsPanel.java
+++ b/src/main/java/com/gitblit/wicket/panels/FederationProposalsPanel.java
@@ -52,6 +52,7 @@ public class FederationProposalsPanel extends BasePanel {
counter = 0;
}
+ @Override
public void populateItem(final Item<FederationProposal> item) {
final FederationProposal entry = item.getModelObject();
item.add(new LinkPanel("url", "list", entry.url, ReviewProposalPage.class,
diff --git a/src/main/java/com/gitblit/wicket/panels/FederationRegistrationsPanel.java b/src/main/java/com/gitblit/wicket/panels/FederationRegistrationsPanel.java
index ff947175..344af49d 100644
--- a/src/main/java/com/gitblit/wicket/panels/FederationRegistrationsPanel.java
+++ b/src/main/java/com/gitblit/wicket/panels/FederationRegistrationsPanel.java
@@ -55,6 +55,7 @@ public class FederationRegistrationsPanel extends BasePanel {
counter = 0;
}
+ @Override
public void populateItem(final Item<FederationModel> item) {
final FederationModel entry = item.getModelObject();
item.add(new LinkPanel("url", "list", entry.url, FederationRegistrationPage.class,
diff --git a/src/main/java/com/gitblit/wicket/panels/FederationTokensPanel.java b/src/main/java/com/gitblit/wicket/panels/FederationTokensPanel.java
index 3454492f..afe553c5 100644
--- a/src/main/java/com/gitblit/wicket/panels/FederationTokensPanel.java
+++ b/src/main/java/com/gitblit/wicket/panels/FederationTokensPanel.java
@@ -71,6 +71,7 @@ public class FederationTokensPanel extends BasePanel {
counter = 0;
}
+ @Override
public void populateItem(final Item<String[]> item) {
final String[] entry = item.getModelObject();
final FederationToken token = FederationToken.fromName(entry[0]);
diff --git a/src/main/java/com/gitblit/wicket/panels/FilterableProjectList.java b/src/main/java/com/gitblit/wicket/panels/FilterableProjectList.java
index a5b74131..4c579264 100644
--- a/src/main/java/com/gitblit/wicket/panels/FilterableProjectList.java
+++ b/src/main/java/com/gitblit/wicket/panels/FilterableProjectList.java
@@ -39,8 +39,8 @@ import com.gitblit.wicket.ng.NgController;
/**
* A client-side filterable rich project list which uses Freemarker, Wicket,
- * and AngularJS.
- *
+ * and AngularJS.
+ *
* @author James Moger
*
*/
@@ -49,21 +49,21 @@ public class FilterableProjectList extends BasePanel {
private static final long serialVersionUID = 1L;
private final List<ProjectModel> projects;
-
+
private String title;
-
+
private String iconClass;
-
+
public FilterableProjectList(String id, List<ProjectModel> projects) {
super(id);
this.projects = projects;
}
-
+
public void setTitle(String title, String iconClass) {
this.title = title;
this.iconClass = iconClass;
}
-
+
@Override
protected void onInitialize() {
super.onInitialize();
@@ -71,18 +71,18 @@ public class FilterableProjectList extends BasePanel {
String id = getId();
String ngCtrl = id + "Ctrl";
String ngList = id + "List";
-
+
Map<String, Object> values = new HashMap<String, Object>();
values.put("ngCtrl", ngCtrl);
values.put("ngList", ngList);
-
+
// use Freemarker to setup an AngularJS/Wicket html snippet
FreemarkerPanel panel = new FreemarkerPanel("listComponent", "FilterableProjectList.fm", values);
panel.setParseGeneratedMarkup(true);
panel.setRenderBodyOnly(true);
add(panel);
-
- // add the Wicket controls that are referenced in the snippet
+
+ // add the Wicket controls that are referenced in the snippet
String listTitle = StringUtils.isEmpty(title) ? getString("gb.projects") : title;
panel.add(new Label(ngList + "Title", MessageFormat.format("{0} ({1})", listTitle, projects.size())));
if (StringUtils.isEmpty(iconClass)) {
@@ -92,7 +92,7 @@ public class FilterableProjectList extends BasePanel {
WicketUtils.setCssClass(icon, iconClass);
panel.add(icon);
}
-
+
String format = GitBlit.getString(Keys.web.datestampShortFormat, "MM/dd/yy");
final DateFormat df = new SimpleDateFormat(format);
df.setTimeZone(getTimeZone());
@@ -118,7 +118,7 @@ public class FilterableProjectList extends BasePanel {
item.c = proj.repositories.size();
list.add(item);
}
-
+
// inject an AngularJS controller with static data
NgController ctrl = new NgController(ngCtrl);
ctrl.addVariable(ngList, list);
@@ -128,7 +128,7 @@ public class FilterableProjectList extends BasePanel {
protected class ProjectListItem implements Serializable {
private static final long serialVersionUID = 1L;
-
+
String p; // path
String n; // name
String t; // time ago
diff --git a/src/main/java/com/gitblit/wicket/panels/FilterableRepositoryList.java b/src/main/java/com/gitblit/wicket/panels/FilterableRepositoryList.java
index 6c43b787..d68155e7 100644
--- a/src/main/java/com/gitblit/wicket/panels/FilterableRepositoryList.java
+++ b/src/main/java/com/gitblit/wicket/panels/FilterableRepositoryList.java
@@ -38,8 +38,8 @@ import com.gitblit.wicket.pages.EditRepositoryPage;
/**
* A client-side filterable rich repository list which uses Freemarker, Wicket,
- * and AngularJS.
- *
+ * and AngularJS.
+ *
* @author James Moger
*
*/
@@ -48,23 +48,23 @@ public class FilterableRepositoryList extends BasePanel {
private static final long serialVersionUID = 1L;
private final List<RepositoryModel> repositories;
-
+
private String title;
-
+
private String iconClass;
-
+
private boolean allowCreate;
-
+
public FilterableRepositoryList(String id, List<RepositoryModel> repositories) {
super(id);
this.repositories = repositories;
}
-
+
public void setTitle(String title, String iconClass) {
this.title = title;
this.iconClass = iconClass;
}
-
+
public void setAllowCreate(boolean value) {
this.allowCreate = value;
}
@@ -76,18 +76,18 @@ public class FilterableRepositoryList extends BasePanel {
String id = getId();
String ngCtrl = id + "Ctrl";
String ngList = id + "List";
-
+
Map<String, Object> values = new HashMap<String, Object>();
values.put("ngCtrl", ngCtrl);
values.put("ngList", ngList);
-
+
// use Freemarker to setup an AngularJS/Wicket html snippet
FreemarkerPanel panel = new FreemarkerPanel("listComponent", "FilterableRepositoryList.fm", values);
panel.setParseGeneratedMarkup(true);
panel.setRenderBodyOnly(true);
add(panel);
-
- // add the Wicket controls that are referenced in the snippet
+
+ // add the Wicket controls that are referenced in the snippet
String listTitle = StringUtils.isEmpty(title) ? getString("gb.repositories") : title;
panel.add(new Label(ngList + "Title", MessageFormat.format("{0} ({1})", listTitle, repositories.size())));
if (StringUtils.isEmpty(iconClass)) {
@@ -97,13 +97,13 @@ public class FilterableRepositoryList extends BasePanel {
WicketUtils.setCssClass(icon, iconClass);
panel.add(icon);
}
-
+
if (allowCreate) {
panel.add(new LinkPanel(ngList + "Button", "btn btn-mini", getString("gb.newRepository"), EditRepositoryPage.class));
} else {
panel.add(new Label(ngList + "Button").setVisible(false));
}
-
+
String format = GitBlit.getString(Keys.web.datestampShortFormat, "MM/dd/yy");
final DateFormat df = new SimpleDateFormat(format);
df.setTimeZone(getTimeZone());
@@ -111,13 +111,13 @@ public class FilterableRepositoryList extends BasePanel {
// prepare the simplified repository models list
List<RepoListItem> list = new ArrayList<RepoListItem>();
for (RepositoryModel repo : repositories) {
- String name = StringUtils.stripDotGit(repo.name);
+ String name = StringUtils.stripDotGit(repo.name);
String path = "";
if (name.indexOf('/') > -1) {
path = name.substring(0, name.lastIndexOf('/') + 1);
name = name.substring(name.lastIndexOf('/') + 1);
}
-
+
RepoListItem item = new RepoListItem();
item.n = name;
item.p = path;
@@ -130,17 +130,17 @@ public class FilterableRepositoryList extends BasePanel {
item.wc = repo.isBare ? 0 : 1;
list.add(item);
}
-
+
// inject an AngularJS controller with static data
NgController ctrl = new NgController(ngCtrl);
ctrl.addVariable(ngList, list);
add(new HeaderContributor(ctrl));
}
-
+
protected class RepoListItem implements Serializable {
private static final long serialVersionUID = 1L;
-
+
String r; // repository
String n; // name
String p; // project/path
diff --git a/src/main/java/com/gitblit/wicket/panels/GravatarImage.java b/src/main/java/com/gitblit/wicket/panels/GravatarImage.java
index da20e9b8..741328c3 100644
--- a/src/main/java/com/gitblit/wicket/panels/GravatarImage.java
+++ b/src/main/java/com/gitblit/wicket/panels/GravatarImage.java
@@ -33,9 +33,9 @@ import com.gitblit.wicket.pages.GravatarProfilePage;
/**
* Represents a Gravatar image and links to the Gravatar profile page.
- *
+ *
* @author James Moger
- *
+ *
*/
public class GravatarImage extends Panel {
@@ -44,7 +44,7 @@ public class GravatarImage extends Panel {
public GravatarImage(String id, PersonIdent person) {
this(id, person, 0);
}
-
+
public GravatarImage(String id, PersonIdent person, int width) {
this(id, person, width, true);
}
@@ -52,7 +52,7 @@ public class GravatarImage extends Panel {
public GravatarImage(String id, PersonIdent person, int width, boolean linked) {
this(id, person.getName(), person.getEmailAddress(), "gravatar", width, linked, true);
}
-
+
public GravatarImage(String id, String username, String emailaddress, String cssClass, int width, boolean linked, boolean identicon) {
super(id);
diff --git a/src/main/java/com/gitblit/wicket/panels/HistoryPanel.java b/src/main/java/com/gitblit/wicket/panels/HistoryPanel.java
index 5e03e01b..10a8b570 100644
--- a/src/main/java/com/gitblit/wicket/panels/HistoryPanel.java
+++ b/src/main/java/com/gitblit/wicket/panels/HistoryPanel.java
@@ -107,13 +107,13 @@ public class HistoryPanel extends BasePanel {
tw.release();
}
}
-
+
final boolean isTree = matchingPath == null ? true : matchingPath.isTree();
final boolean isSubmodule = matchingPath == null ? false : matchingPath.isSubmodule();
// submodule
final String submodulePath;
- final boolean hasSubmodule;
+ final boolean hasSubmodule;
if (isSubmodule) {
SubmoduleModel submodule = getSubmodule(submodules, repositoryName, matchingPath == null ? null : matchingPath.path);
submodulePath = submodule.gitblitPath;
@@ -122,7 +122,7 @@ public class HistoryPanel extends BasePanel {
submodulePath = "";
hasSubmodule = false;
}
-
+
final Map<ObjectId, List<RefModel>> allRefs = JGitUtils.getAllRefs(r, showRemoteRefs);
List<RevCommit> commits;
if (pageResults) {
@@ -149,6 +149,7 @@ public class HistoryPanel extends BasePanel {
private static final long serialVersionUID = 1L;
int counter;
+ @Override
public void populateItem(final Item<RevCommit> item) {
final RevCommit entry = item.getModelObject();
final Date date = JGitUtils.getCommitDate(entry);
@@ -195,9 +196,9 @@ public class HistoryPanel extends BasePanel {
TreePage.class, WicketUtils.newObjectParameter(
repositoryName, entry.getName()));
WicketUtils.setCssClass(commitHash, "shortsha1");
- WicketUtils.setHtmlTooltip(commitHash, entry.getName());
+ WicketUtils.setHtmlTooltip(commitHash, entry.getName());
item.add(commitHash);
-
+
Fragment links = new Fragment("historyLinks", "treeLinks", this);
links.add(new BookmarkablePageLink<Void>("commitdiff", CommitDiffPage.class,
WicketUtils.newObjectParameter(repositoryName, entry.getName())));
@@ -218,14 +219,14 @@ public class HistoryPanel extends BasePanel {
TreePage.class, WicketUtils.newObjectParameter(
submodulePath, submoduleId));
WicketUtils.setCssClass(commitHash, "shortsha1");
- WicketUtils.setHtmlTooltip(commitHash, submoduleId);
+ WicketUtils.setHtmlTooltip(commitHash, submoduleId);
item.add(commitHash.setEnabled(hasSubmodule));
}
Fragment links = new Fragment("historyLinks", "treeLinks", this);
links.add(new BookmarkablePageLink<Void>("commitdiff", CommitDiffPage.class,
WicketUtils.newObjectParameter(repositoryName, entry.getName())));
item.add(links);
- } else {
+ } else {
// commit
item.add(new Label("hashLabel", getString("gb.blob") + "@"));
LinkPanel commitHash = new LinkPanel("hashLink", null, entry.getName().substring(0, hashLen),
@@ -234,7 +235,7 @@ public class HistoryPanel extends BasePanel {
WicketUtils.setCssClass(commitHash, "sha1");
WicketUtils.setHtmlTooltip(commitHash, entry.getName());
item.add(commitHash);
-
+
Fragment links = new Fragment("historyLinks", "blobLinks", this);
links.add(new BookmarkablePageLink<Void>("commitdiff", CommitDiffPage.class,
WicketUtils.newObjectParameter(repositoryName, entry.getName())));
@@ -276,7 +277,7 @@ public class HistoryPanel extends BasePanel {
public boolean hasMore() {
return hasMore;
}
-
+
protected SubmoduleModel getSubmodule(Map<String, SubmoduleModel> submodules, String repositoryName, String path) {
SubmoduleModel model = submodules.get(path);
if (model == null) {
@@ -289,7 +290,7 @@ public class HistoryPanel extends BasePanel {
// extract the repository name from the clone url
List<String> patterns = GitBlit.getStrings(Keys.git.submoduleUrlPatterns);
String submoduleName = StringUtils.extractRepositoryPath(model.url, patterns.toArray(new String[0]));
-
+
// determine the current path for constructing paths relative
// to the current repository
String currentPath = "";
@@ -332,10 +333,10 @@ public class HistoryPanel extends BasePanel {
return model;
}
}
-
+
// we do not have a copy of the submodule, but we need a path
model.gitblitPath = candidates.get(0);
return model;
- }
+ }
}
}
diff --git a/src/main/java/com/gitblit/wicket/panels/LinkPanel.java b/src/main/java/com/gitblit/wicket/panels/LinkPanel.java
index 21470b27..cdcf574f 100644
--- a/src/main/java/com/gitblit/wicket/panels/LinkPanel.java
+++ b/src/main/java/com/gitblit/wicket/panels/LinkPanel.java
@@ -107,7 +107,7 @@ public class LinkPanel extends Panel {
link.add(new Label("label", labelModel));
add(link);
}
-
+
public void setNoFollow() {
Component c = get("link");
c.add(new SimpleAttributeModifier("rel", "nofollow"));
diff --git a/src/main/java/com/gitblit/wicket/panels/LogPanel.java b/src/main/java/com/gitblit/wicket/panels/LogPanel.java
index a9f80db9..eba0dd3b 100644
--- a/src/main/java/com/gitblit/wicket/panels/LogPanel.java
+++ b/src/main/java/com/gitblit/wicket/panels/LogPanel.java
@@ -32,10 +32,10 @@ import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
+import com.gitblit.BranchGraphServlet;
import com.gitblit.Constants;
import com.gitblit.GitBlit;
import com.gitblit.Keys;
-import com.gitblit.BranchGraphServlet;
import com.gitblit.models.RefModel;
import com.gitblit.utils.JGitUtils;
import com.gitblit.utils.StringUtils;
@@ -75,10 +75,10 @@ public class LogPanel extends BasePanel {
// inaccurate way to determine if there are more commits.
// works unless commits.size() represents the exact end.
hasMore = commits.size() >= itemsPerPage;
-
+
final String baseUrl = WicketUtils.getGitblitURL(getRequest());
final boolean showGraph = GitBlit.getBoolean(Keys.web.showBranchGraph, true);
-
+
MarkupContainer graph = new WebMarkupContainer("graph");
add(graph);
if (!showGraph || commits.isEmpty()) {
@@ -107,6 +107,7 @@ public class LogPanel extends BasePanel {
private static final long serialVersionUID = 1L;
int counter;
+ @Override
public void populateItem(final Item<RevCommit> item) {
final RevCommit entry = item.getModelObject();
final Date date = JGitUtils.getCommitDate(entry);
@@ -120,7 +121,7 @@ public class LogPanel extends BasePanel {
objectId, author, Constants.SearchType.AUTHOR));
setPersonSearchTooltip(authorLink, author, Constants.SearchType.AUTHOR);
item.add(authorLink);
-
+
// merge icon
if (entry.getParentCount() > 1) {
item.add(WicketUtils.newImage("commitIcon", "commit_merge_16x16.png"));
@@ -153,7 +154,7 @@ public class LogPanel extends BasePanel {
WicketUtils.setCssClass(commitHash, "shortsha1");
WicketUtils.setHtmlTooltip(commitHash, entry.getName());
item.add(commitHash);
-
+
item.add(new BookmarkablePageLink<Void>("diff", CommitDiffPage.class, WicketUtils
.newObjectParameter(repositoryName, entry.getName())).setEnabled(entry
.getParentCount() > 0));
diff --git a/src/main/java/com/gitblit/wicket/panels/NavigationPanel.java b/src/main/java/com/gitblit/wicket/panels/NavigationPanel.java
index 436db37f..393dd139 100644
--- a/src/main/java/com/gitblit/wicket/panels/NavigationPanel.java
+++ b/src/main/java/com/gitblit/wicket/panels/NavigationPanel.java
@@ -42,6 +42,7 @@ public class NavigationPanel extends Panel {
DataView<PageRegistration> refsView = new DataView<PageRegistration>("navLink", refsDp) {
private static final long serialVersionUID = 1L;
+ @Override
public void populateItem(final Item<PageRegistration> item) {
PageRegistration entry = item.getModelObject();
if (entry.hiddenPhone) {
diff --git a/src/main/java/com/gitblit/wicket/panels/ObjectContainer.java b/src/main/java/com/gitblit/wicket/panels/ObjectContainer.java
index d7f1f789..3c09e7c7 100644
--- a/src/main/java/com/gitblit/wicket/panels/ObjectContainer.java
+++ b/src/main/java/com/gitblit/wicket/panels/ObjectContainer.java
@@ -83,7 +83,7 @@ public abstract class ObjectContainer extends WebMarkupContainer {
if (parent instanceof Fragment) {
// must check for fragment, otherwise we end up in Wicket namespace
parent = parent.getParent();
- }
+ }
if (parent != null) {
ResourceReference resRef = new ResourceReference(parent.getClass(), src, false);
return (urlFor(resRef).toString());
@@ -92,6 +92,7 @@ public abstract class ObjectContainer extends WebMarkupContainer {
return (src);
}
+ @Override
public void onComponentTag(ComponentTag tag) {
super.onComponentTag(tag);
@@ -122,6 +123,7 @@ public abstract class ObjectContainer extends WebMarkupContainer {
}
}
+ @Override
public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
Response response = getResponse();
response.write("\n");
diff --git a/src/main/java/com/gitblit/wicket/panels/PagerPanel.java b/src/main/java/com/gitblit/wicket/panels/PagerPanel.java
index a5dbb9ef..2d774c41 100644
--- a/src/main/java/com/gitblit/wicket/panels/PagerPanel.java
+++ b/src/main/java/com/gitblit/wicket/panels/PagerPanel.java
@@ -39,10 +39,10 @@ public class PagerPanel extends Panel {
int[] deltas;
if (currentPage == 1) {
// [1], 2, 3, 4, 5
- deltas = new int[] { 0, 1, 2, 3, 4 };
+ deltas = new int[] { 0, 1, 2, 3, 4 };
} else if (currentPage == 2) {
// 1, [2], 3, 4, 5
- deltas = new int[] { -1, 0, 1, 2, 3 };
+ deltas = new int[] { -1, 0, 1, 2, 3 };
} else {
// 1, 2, [3], 4, 5
deltas = new int[] { -2, -1, 0, 1, 2 };
@@ -65,6 +65,7 @@ public class PagerPanel extends Panel {
final DataView<PageObject> pagesView = new DataView<PageObject>("page", pagesProvider) {
private static final long serialVersionUID = 1L;
+ @Override
public void populateItem(final Item<PageObject> item) {
PageObject pageItem = item.getModelObject();
PageParameters pageParams = new PageParameters(baseParams);
@@ -83,7 +84,7 @@ public class PagerPanel extends Panel {
private class PageObject implements Serializable {
private static final long serialVersionUID = 1L;
-
+
String text;
int page;
diff --git a/src/main/java/com/gitblit/wicket/panels/PathBreadcrumbsPanel.java b/src/main/java/com/gitblit/wicket/panels/PathBreadcrumbsPanel.java
index f6c0e4f8..2ac7bf91 100644
--- a/src/main/java/com/gitblit/wicket/panels/PathBreadcrumbsPanel.java
+++ b/src/main/java/com/gitblit/wicket/panels/PathBreadcrumbsPanel.java
@@ -56,6 +56,7 @@ public class PathBreadcrumbsPanel extends Panel {
DataView<BreadCrumb> pathsView = new DataView<BreadCrumb>("path", crumbsDp) {
private static final long serialVersionUID = 1L;
+ @Override
public void populateItem(final Item<BreadCrumb> item) {
final BreadCrumb entry = item.getModelObject();
String path = entry.path;
diff --git a/src/main/java/com/gitblit/wicket/panels/ReflogPanel.java b/src/main/java/com/gitblit/wicket/panels/ReflogPanel.java
index 99ce55a1..d63f26c3 100644
--- a/src/main/java/com/gitblit/wicket/panels/ReflogPanel.java
+++ b/src/main/java/com/gitblit/wicket/panels/ReflogPanel.java
@@ -55,7 +55,7 @@ public class ReflogPanel extends BasePanel {
private static final long serialVersionUID = 1L;
private final boolean hasChanges;
-
+
private boolean hasMore;
public ReflogPanel(String wicketId, final RepositoryModel model, Repository r, int limit, int pageOffset) {
@@ -77,9 +77,9 @@ public class ReflogPanel extends BasePanel {
// works unless commits.size() represents the exact end.
hasMore = changes.size() >= changesPerPage;
hasChanges = changes.size() > 0;
-
+
setup(changes);
-
+
// determine to show pager, more, or neither
if (limit <= 0) {
// no display limit
@@ -102,14 +102,14 @@ public class ReflogPanel extends BasePanel {
}
}
}
-
+
public ReflogPanel(String wicketId, List<RefLogEntry> changes) {
super(wicketId);
hasChanges = changes.size() > 0;
setup(changes);
add(new Label("moreChanges").setVisible(false));
}
-
+
protected void setup(List<RefLogEntry> changes) {
final int hashLen = GitBlit.getInteger(Keys.web.shortCommitIdLength, 6);
@@ -118,11 +118,12 @@ public class ReflogPanel extends BasePanel {
final DateFormat df = new SimpleDateFormat(dateFormat);
df.setTimeZone(timezone);
final Calendar cal = Calendar.getInstance(timezone);
-
+
ListDataProvider<RefLogEntry> dp = new ListDataProvider<RefLogEntry>(changes);
DataView<RefLogEntry> changeView = new DataView<RefLogEntry>("change", dp) {
private static final long serialVersionUID = 1L;
+ @Override
public void populateItem(final Item<RefLogEntry> changeItem) {
final RefLogEntry change = changeItem.getModelObject();
String fullRefName = change.getChangedRefs().get(0);
@@ -134,7 +135,7 @@ public class ReflogPanel extends BasePanel {
shortRefName = shortRefName.substring(Constants.R_TAGS.length());
isTag = true;
}
-
+
String fuzzydate;
TimeUtils tu = getTimeUtils();
Date changeDate = change.date;
@@ -175,7 +176,7 @@ public class ReflogPanel extends BasePanel {
changeItem.add(new LinkPanel("whoChanged", null, change.user.getDisplayName(),
UserPage.class, WicketUtils.newUsernameParameter(change.user.username)));
}
-
+
boolean isDelete = false;
boolean isRewind = false;
String what;
@@ -202,19 +203,19 @@ public class ReflogPanel extends BasePanel {
isRewind = true;
default:
what = MessageFormat.format(change.getCommitCount() > 1 ? getString("gb.pushedNCommitsTo") : getString("gb.pushedOneCommitTo") , change.getCommitCount());
-
+
if (change.getAuthorCount() == 1) {
by = MessageFormat.format(getString("gb.byOneAuthor"), change.getAuthorIdent().getName());
} else {
- by = MessageFormat.format(getString("gb.byNAuthors"), change.getAuthorCount());
+ by = MessageFormat.format(getString("gb.byNAuthors"), change.getAuthorCount());
}
break;
}
changeItem.add(new Label("whatChanged", what));
changeItem.add(new Label("byAuthors", by).setVisible(!StringUtils.isEmpty(by)));
-
+
changeItem.add(new Label("refRewind", getString("gb.rewind")).setVisible(isRewind));
-
+
if (isDelete) {
// can't link to deleted ref
changeItem.add(new Label("refChanged", shortRefName));
@@ -227,13 +228,13 @@ public class ReflogPanel extends BasePanel {
changeItem.add(new LinkPanel("refChanged", null, shortRefName,
TreePage.class, WicketUtils.newObjectParameter(change.repository, fullRefName)));
}
-
+
int maxCommitCount = 5;
List<RepositoryCommit> commits = change.getCommits();
if (commits.size() > maxCommitCount) {
- commits = new ArrayList<RepositoryCommit>(commits.subList(0, maxCommitCount));
+ commits = new ArrayList<RepositoryCommit>(commits.subList(0, maxCommitCount));
}
-
+
// compare link
String compareLinkText = null;
if ((change.getCommitCount() <= maxCommitCount) && (change.getCommitCount() > 1)) {
@@ -249,18 +250,19 @@ public class ReflogPanel extends BasePanel {
String startRangeId = change.getOldId(fullRefName);
changeItem.add(new LinkPanel("compareLink", null, compareLinkText, ComparePage.class, WicketUtils.newRangeParameter(change.repository, startRangeId, endRangeId)));
}
-
+
ListDataProvider<RepositoryCommit> cdp = new ListDataProvider<RepositoryCommit>(commits);
DataView<RepositoryCommit> commitsView = new DataView<RepositoryCommit>("commit", cdp) {
private static final long serialVersionUID = 1L;
+ @Override
public void populateItem(final Item<RepositoryCommit> commitItem) {
final RepositoryCommit commit = commitItem.getModelObject();
// author gravatar
commitItem.add(new GravatarImage("commitAuthor", commit.getAuthorIdent().getName(),
commit.getAuthorIdent().getEmailAddress(), null, 16, false, false));
-
+
// merge icon
if (commit.getParentCount() > 1) {
commitItem.add(WicketUtils.newImage("commitIcon", "commit_merge_16x16.png"));
@@ -297,14 +299,14 @@ public class ReflogPanel extends BasePanel {
changeItem.add(commitsView);
}
};
-
+
add(changeView);
}
public boolean hasMore() {
return hasMore;
}
-
+
public boolean hideIfEmpty() {
setVisible(hasChanges);
return hasChanges;
diff --git a/src/main/java/com/gitblit/wicket/panels/RefsPanel.java b/src/main/java/com/gitblit/wicket/panels/RefsPanel.java
index e477b65f..1a763119 100644
--- a/src/main/java/com/gitblit/wicket/panels/RefsPanel.java
+++ b/src/main/java/com/gitblit/wicket/panels/RefsPanel.java
@@ -43,7 +43,7 @@ import com.gitblit.wicket.pages.TagPage;
public class RefsPanel extends Panel {
private static final long serialVersionUID = 1L;
-
+
public RefsPanel(String id, final String repositoryName, RevCommit c,
Map<ObjectId, List<RefModel>> refs) {
this(id, repositoryName, refs.get(c.getId()));
@@ -65,7 +65,7 @@ public class RefsPanel extends Panel {
boolean remote2 = o2.displayName.startsWith(Constants.R_REMOTES);
if (remote1 && remote2) {
// both are remote heads, sort by name
- return o1.displayName.compareTo(o2.displayName);
+ return o1.displayName.compareTo(o2.displayName);
}
if (remote1) {
// o1 is remote, o2 comes first
@@ -79,7 +79,7 @@ public class RefsPanel extends Panel {
return o1.displayName.compareTo(o2.displayName);
}
});
-
+
// count remote and determine if we should insert a break
int remoteCount = 0;
for (RefModel ref : refs) {
@@ -88,12 +88,13 @@ public class RefsPanel extends Panel {
}
}
final boolean shouldBreak = remoteCount < refs.size();
-
+
ListDataProvider<RefModel> refsDp = new ListDataProvider<RefModel>(refs);
DataView<RefModel> refsView = new DataView<RefModel>("ref", refsDp) {
private static final long serialVersionUID = 1L;
private boolean alreadyInsertedBreak = !shouldBreak;
+ @Override
public void populateItem(final Item<RefModel> item) {
RefModel entry = item.getModelObject();
String name = entry.displayName;
@@ -123,9 +124,9 @@ public class RefsPanel extends Panel {
// Pull Request ref
name = "pull #" + name.substring(Constants.R_PULL.length());
if (name.endsWith("/head")) {
- // strip pull request head from name
+ // strip pull request head from name
name = name.substring(0, name.length() - "/head".length());
- }
+ }
cssClass = "pullRef";
} else if (name.startsWith(Constants.R_REMOTES)) {
// remote branch
diff --git a/src/main/java/com/gitblit/wicket/panels/RegistrantPermissionsPanel.java b/src/main/java/com/gitblit/wicket/panels/RegistrantPermissionsPanel.java
index 4156cd19..b728082b 100644
--- a/src/main/java/com/gitblit/wicket/panels/RegistrantPermissionsPanel.java
+++ b/src/main/java/com/gitblit/wicket/panels/RegistrantPermissionsPanel.java
@@ -52,17 +52,17 @@ import com.gitblit.wicket.WicketUtils;
/**
* Allows user to manipulate registrant access permissions.
- *
+ *
* @author James Moger
*
*/
public class RegistrantPermissionsPanel extends BasePanel {
private static final long serialVersionUID = 1L;
-
+
public enum Show {
specified, mutable, effective;
-
+
public boolean show(RegistrantAccessPermission ap) {
switch (this) {
case specified:
@@ -76,9 +76,9 @@ public class RegistrantPermissionsPanel extends BasePanel {
}
}
}
-
+
private Show activeState = Show.mutable;
-
+
public RegistrantPermissionsPanel(String wicketId, RegistrantType registrantType, List<String> allRegistrants, final List<RegistrantAccessPermission> permissions, final Map<AccessPermission, String> translations) {
super(wicketId);
setOutputMarkupId(true);
@@ -97,7 +97,7 @@ public class RegistrantPermissionsPanel extends BasePanel {
*/
RefreshingView<RegistrantAccessPermission> dataView = new RefreshingView<RegistrantAccessPermission>("permissionRow") {
private static final long serialVersionUID = 1L;
-
+
@Override
protected Iterator<IModel<RegistrantAccessPermission>> getItemModels() {
// the iterator returns RepositoryPermission objects, but we need it to
@@ -116,7 +116,8 @@ public class RegistrantPermissionsPanel extends BasePanel {
// 'even' for decoration
return new OddEvenItem<RegistrantAccessPermission>(id, index, model);
}
-
+
+ @Override
public void populateItem(final Item<RegistrantAccessPermission> item) {
final RegistrantAccessPermission entry = item.getModelObject();
if (RegistrantType.REPOSITORY.equals(entry.registrantType)) {
@@ -135,7 +136,7 @@ public class RegistrantPermissionsPanel extends BasePanel {
Label label = new Label("registrant", entry.registrant);
WicketUtils.setCssStyle(label, "font-weight: bold;");
item.add(label);
- }
+ }
} else if (RegistrantType.USER.equals(entry.registrantType)) {
// user
PersonIdent ident = new PersonIdent(entry.registrant, "");
@@ -146,8 +147,8 @@ public class RegistrantPermissionsPanel extends BasePanel {
Fragment userFragment = new Fragment("registrant", "userRegistrant", RegistrantPermissionsPanel.this);
userFragment.add(new GravatarImage("userAvatar", ident, 20, false));
- userFragment.add(new Label("userName", entry.registrant));
- item.add(userFragment);
+ userFragment.add(new Label("userName", entry.registrant));
+ item.add(userFragment);
} else {
// team
Fragment teamFragment = new Fragment("registrant", "teamRegistrant", RegistrantPermissionsPanel.this);
@@ -209,9 +210,10 @@ public class RegistrantPermissionsPanel extends BasePanel {
permissionChoice.setOutputMarkupId(true);
if (entry.mutable) {
permissionChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") {
-
+
private static final long serialVersionUID = 1L;
+ @Override
protected void onUpdate(AjaxRequestTarget target) {
target.addComponent(permissionChoice);
}
@@ -265,29 +267,30 @@ public class RegistrantPermissionsPanel extends BasePanel {
copy.source = copy.registrant;
}
permissions.add(copy);
-
+
// resort permissions after insert to convey idea of eval order
Collections.sort(permissions);
-
+
// remove registrant from available choices
registrants.remove(rp.registrant);
-
+
// force the panel to refresh
target.addComponent(RegistrantPermissionsPanel.this);
}
};
addPermissionForm.add(button);
-
+
// only show add permission form if we have a registrant choice
add(addPermissionForm.setVisible(registrants.size() > 0));
}
-
+
+ @Override
protected boolean getStatelessHint()
{
return false;
}
-
+
private class AccessPermissionRenderer implements IChoiceRenderer<AccessPermission> {
private static final long serialVersionUID = 1L;
@@ -308,18 +311,18 @@ public class RegistrantPermissionsPanel extends BasePanel {
return Integer.toString(index);
}
}
-
+
private class ShowStateButton extends AjaxButton {
private static final long serialVersionUID = 1L;
Show buttonState;
-
+
public ShowStateButton(String wicketId, Show state) {
super(wicketId);
this.buttonState = state;
setOutputMarkupId(true);
}
-
+
@Override
protected void onBeforeRender()
{
@@ -330,7 +333,7 @@ public class RegistrantPermissionsPanel extends BasePanel {
WicketUtils.setCssClass(this, cssClass);
super.onBeforeRender();
}
-
+
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
RegistrantPermissionsPanel.this.activeState = buttonState;
diff --git a/src/main/java/com/gitblit/wicket/panels/RepositoriesPanel.java b/src/main/java/com/gitblit/wicket/panels/RepositoriesPanel.java
index 256cc645..89fc02ac 100644
--- a/src/main/java/com/gitblit/wicket/panels/RepositoriesPanel.java
+++ b/src/main/java/com/gitblit/wicket/panels/RepositoriesPanel.java
@@ -128,7 +128,7 @@ public class RepositoriesPanel extends BasePanel {
roots.add(0, "");
groups.put("", rootRepositories);
}
-
+
List<RepositoryModel> groupedModels = new ArrayList<RepositoryModel>();
for (String root : roots) {
List<RepositoryModel> subModels = groups.get(root);
@@ -149,7 +149,7 @@ public class RepositoriesPanel extends BasePanel {
final String baseUrl = WicketUtils.getGitblitURL(getRequest());
final boolean showSwatch = GitBlit.getBoolean(Keys.web.repositoryListSwatches, true);
-
+
DataView<RepositoryModel> dataView = new DataView<RepositoryModel>("row", dp) {
private static final long serialVersionUID = 1L;
int counter;
@@ -161,6 +161,7 @@ public class RepositoriesPanel extends BasePanel {
counter = 0;
}
+ @Override
public void populateItem(final Item<RepositoryModel> item) {
final RepositoryModel entry = item.getModelObject();
if (entry instanceof GroupRepositoryModel) {
@@ -168,7 +169,7 @@ public class RepositoriesPanel extends BasePanel {
currGroupName = entry.name;
Fragment row = new Fragment("rowContent", "groupRepositoryRow", this);
item.add(row);
-
+
String name = groupRow.name;
if (name.startsWith(ModelUtils.getUserRepoPrefix())) {
// user page
@@ -194,7 +195,7 @@ public class RepositoriesPanel extends BasePanel {
if (!StringUtils.isEmpty(currGroupName) && (repoName.indexOf('/') > -1)) {
repoName = repoName.substring(currGroupName.length() + 1);
}
-
+
// repository swatch
Component swatch;
if (entry.isBare){
@@ -241,7 +242,7 @@ public class RepositoriesPanel extends BasePanel {
} else {
row.add(WicketUtils.newClearPixel("sparkleshareIcon").setVisible(false));
}
-
+
if (entry.isFork()) {
row.add(WicketUtils.newImage("forkIcon", "commit_divide_16x16.png",
getString("gb.isFork")));
diff --git a/src/main/java/com/gitblit/wicket/panels/RepositoryUrlPanel.java b/src/main/java/com/gitblit/wicket/panels/RepositoryUrlPanel.java
index 0dae3cf1..ea8693bb 100644
--- a/src/main/java/com/gitblit/wicket/panels/RepositoryUrlPanel.java
+++ b/src/main/java/com/gitblit/wicket/panels/RepositoryUrlPanel.java
@@ -50,7 +50,7 @@ import com.gitblit.wicket.WicketUtils;
/**
* Smart repository url panel which can display multiple Gitblit repository urls
* and also supports 3rd party app clone links.
- *
+ *
* @author James Moger
*
*/
@@ -61,12 +61,12 @@ public class RepositoryUrlPanel extends BasePanel {
private final String externalPermission = "?";
private boolean onlyUrls;
- private UserModel user;
+ private UserModel user;
private RepositoryModel repository;
private RepositoryUrl primaryUrl;
private Map<String, String> urlPermissionsMap;
private Map<AccessRestrictionType, String> accessRestrictionsMap;
-
+
public RepositoryUrlPanel(String wicketId, boolean onlyUrls, UserModel user, RepositoryModel repository) {
super(wicketId);
this.onlyUrls = onlyUrls;
@@ -74,7 +74,7 @@ public class RepositoryUrlPanel extends BasePanel {
this.repository = repository;
this.urlPermissionsMap = new HashMap<String, String>();
}
-
+
@Override
protected void onInitialize() {
super.onInitialize();
@@ -94,7 +94,7 @@ public class RepositoryUrlPanel extends BasePanel {
add(new Label("repositoryIndicators").setVisible(false));
return;
}
-
+
// display primary url
add(createPrimaryUrlPanel("repositoryUrlPanel", repository, repositoryUrls));
@@ -122,7 +122,7 @@ public class RepositoryUrlPanel extends BasePanel {
Fragment urlPanel = new Fragment(wicketId, "repositoryUrlFragment", this);
urlPanel.setRenderBodyOnly(true);
-
+
if (repositoryUrls.size() == 1) {
//
// Single repository url, no dropdown menu
@@ -136,15 +136,16 @@ public class RepositoryUrlPanel extends BasePanel {
DataView<RepositoryUrl> repoUrlMenuItems = new DataView<RepositoryUrl>("repoUrls", urlsDp) {
private static final long serialVersionUID = 1L;
+ @Override
public void populateItem(final Item<RepositoryUrl> item) {
RepositoryUrl repoUrl = item.getModelObject();
// repository url
- Fragment fragment = new Fragment("repoUrl", "actionFragment", this);
+ Fragment fragment = new Fragment("repoUrl", "actionFragment", this);
Component content = new Label("content", repoUrl.url).setRenderBodyOnly(true);
WicketUtils.setCssClass(content, "commandMenuItem");
fragment.add(content);
item.add(fragment);
-
+
Label permissionLabel = new Label("permission", repoUrl.isExternal() ? externalPermission : repoUrl.permission.toString());
WicketUtils.setPermissionClass(permissionLabel, repoUrl.permission);
String tooltip = getProtocolPermissionDescription(repository, repoUrl);
@@ -195,22 +196,22 @@ public class RepositoryUrlPanel extends BasePanel {
urlPanel.add(WicketUtils.newClearPixel("accessRestrictionIcon").setVisible(false));
}
}
-
+
urlPanel.add(new Label("primaryUrl", primaryUrl.url).setRenderBodyOnly(true));
- Label permissionLabel = new Label("primaryUrlPermission", primaryUrl.isExternal() ? externalPermission : primaryUrl.permission.toString());
+ Label permissionLabel = new Label("primaryUrlPermission", primaryUrl.isExternal() ? externalPermission : primaryUrl.permission.toString());
String tooltip = getProtocolPermissionDescription(repository, primaryUrl);
WicketUtils.setHtmlTooltip(permissionLabel, tooltip);
urlPanel.add(permissionLabel);
urlPanel.add(createCopyFragment(primaryUrl.url));
-
+
return urlPanel;
}
-
+
protected Fragment createApplicationMenus(String wicketId, UserModel user, final RepositoryModel repository, final List<RepositoryUrl> repositoryUrls) {
final List<GitClientApplication> displayedApps = new ArrayList<GitClientApplication>();
final String userAgent = ((WebClientInfo) GitBlitWebSession.get().getClientInfo()).getUserAgent();
-
+
if (user.canClone(repository)) {
for (GitClientApplication app : GitBlit.self().getClientApplications()) {
if (app.isActive && app.allowsPlatform(userAgent)) {
@@ -224,6 +225,7 @@ public class RepositoryUrlPanel extends BasePanel {
DataView<GitClientApplication> appMenus = new DataView<GitClientApplication>("appMenus", displayedAppsDp) {
private static final long serialVersionUID = 1L;
+ @Override
public void populateItem(final Item<GitClientApplication> item) {
final GitClientApplication clientApp = item.getModelObject();
@@ -242,24 +244,24 @@ public class RepositoryUrlPanel extends BasePanel {
}
}
}
-
+
if (urls.size() == 0) {
// do not show this app menu because there are no urls
item.add(new Label("appMenu").setVisible(false));
return;
}
-
+
Fragment appMenu = new Fragment("appMenu", "appMenuFragment", this);
appMenu.setRenderBodyOnly(true);
item.add(appMenu);
-
+
// menu button
appMenu.add(new Label("applicationName", clientApp.name));
-
+
// application icon
Component img;
if (StringUtils.isEmpty(clientApp.icon)) {
- img = WicketUtils.newClearPixel("applicationIcon").setVisible(false);
+ img = WicketUtils.newClearPixel("applicationIcon").setVisible(false);
} else {
if (clientApp.icon.contains("://")) {
// external image
@@ -268,35 +270,36 @@ public class RepositoryUrlPanel extends BasePanel {
// context image
img = WicketUtils.newImage("applicationIcon", clientApp.icon);
}
- }
+ }
appMenu.add(img);
-
+
// application menu title, may be a link
if (StringUtils.isEmpty(clientApp.productUrl)) {
appMenu.add(new Label("applicationTitle", clientApp.toString()));
} else {
appMenu.add(new LinkPanel("applicationTitle", null, clientApp.toString(), clientApp.productUrl, true));
}
-
+
// brief application description
if (StringUtils.isEmpty(clientApp.description)) {
appMenu.add(new Label("applicationDescription").setVisible(false));
} else {
appMenu.add(new Label("applicationDescription", clientApp.description));
}
-
+
// brief application legal info, copyright, license, etc
if (StringUtils.isEmpty(clientApp.legal)) {
appMenu.add(new Label("applicationLegal").setVisible(false));
} else {
appMenu.add(new Label("applicationLegal", clientApp.legal));
}
-
+
// a nested repeater for all action items
ListDataProvider<RepositoryUrl> urlsDp = new ListDataProvider<RepositoryUrl>(urls);
DataView<RepositoryUrl> actionItems = new DataView<RepositoryUrl>("actionItems", urlsDp) {
private static final long serialVersionUID = 1L;
+ @Override
public void populateItem(final Item<RepositoryUrl> repoLinkItem) {
RepositoryUrl repoUrl = repoLinkItem.getModelObject();
Fragment fragment = new Fragment("actionItem", "actionFragment", this);
@@ -315,7 +318,7 @@ public class RepositoryUrlPanel extends BasePanel {
WicketUtils.setCssClass(content, "commandMenuItem");
fragment.add(content);
repoLinkItem.add(fragment);
-
+
// copy function for command
fragment.add(createCopyFragment(command));
}
@@ -323,16 +326,16 @@ public class RepositoryUrlPanel extends BasePanel {
appMenu.add(actionItems);
}
};
-
+
Fragment applicationMenus = new Fragment(wicketId, "applicationMenusFragment", this);
applicationMenus.add(appMenus);
return applicationMenus;
}
-
+
protected String substitute(String pattern, String repoUrl, String baseUrl) {
return pattern.replace("${repoUrl}", repoUrl).replace("${baseUrl}", baseUrl);
}
-
+
protected Label createPermissionBadge(String wicketId, RepositoryUrl repoUrl) {
Label permissionLabel = new Label(wicketId, repoUrl.isExternal() ? externalPermission : repoUrl.permission.toString());
WicketUtils.setPermissionClass(permissionLabel, repoUrl.permission);
@@ -340,7 +343,7 @@ public class RepositoryUrlPanel extends BasePanel {
WicketUtils.setHtmlTooltip(permissionLabel, tooltip);
return permissionLabel;
}
-
+
protected Fragment createCopyFragment(String text) {
if (GitBlit.getBoolean(Keys.web.allowFlashCopyToClipboard, true)) {
// clippy: flash-based copy & paste
@@ -359,7 +362,7 @@ public class RepositoryUrlPanel extends BasePanel {
return copyFragment;
}
}
-
+
protected String getProtocolPermissionDescription(RepositoryModel repository,
RepositoryUrl repoUrl) {
if (!urlPermissionsMap.containsKey(repoUrl.url)) {
@@ -374,9 +377,9 @@ public class RepositoryUrlPanel extends BasePanel {
// implicit SSH url
protocol = "ssh";
}
- note = MessageFormat.format(getString("gb.externalPermissions"), protocol);
+ note = MessageFormat.format(getString("gb.externalPermissions"), protocol);
} else {
- note = null;
+ note = null;
String key;
switch (repoUrl.permission) {
case OWNER:
@@ -411,7 +414,7 @@ public class RepositoryUrlPanel extends BasePanel {
}
return urlPermissionsMap.get(repoUrl.url);
}
-
+
protected Map<AccessRestrictionType, String> getAccessRestrictions() {
if (accessRestrictionsMap == null) {
accessRestrictionsMap = new HashMap<AccessRestrictionType, String>();
@@ -434,7 +437,7 @@ public class RepositoryUrlPanel extends BasePanel {
}
return accessRestrictionsMap;
}
-
+
protected Component createRepositoryIndicators(RepositoryModel repository) {
Fragment fragment = new Fragment("repositoryIndicators", "indicatorsFragment", this);
if (repository.isBare) {
@@ -446,7 +449,7 @@ public class RepositoryUrlPanel extends BasePanel {
wc.add(lbl);
fragment.add(wc);
}
-
+
boolean allowForking = GitBlit.getBoolean(Keys.web.allowForking, true);
if (!allowForking || user == null || !user.isAuthenticated) {
// must be logged-in to fork, hide all fork controls
diff --git a/src/main/java/com/gitblit/wicket/panels/SearchPanel.java b/src/main/java/com/gitblit/wicket/panels/SearchPanel.java
index 9d38ab09..bfa38ed4 100644
--- a/src/main/java/com/gitblit/wicket/panels/SearchPanel.java
+++ b/src/main/java/com/gitblit/wicket/panels/SearchPanel.java
@@ -84,6 +84,7 @@ public class SearchPanel extends BasePanel {
private static final long serialVersionUID = 1L;
int counter;
+ @Override
public void populateItem(final Item<RevCommit> item) {
final RevCommit entry = item.getModelObject();
final Date date = JGitUtils.getCommitDate(entry);
diff --git a/src/main/java/com/gitblit/wicket/panels/ShockWaveComponent.java b/src/main/java/com/gitblit/wicket/panels/ShockWaveComponent.java
index fa989453..78822c6d 100644
--- a/src/main/java/com/gitblit/wicket/panels/ShockWaveComponent.java
+++ b/src/main/java/com/gitblit/wicket/panels/ShockWaveComponent.java
@@ -29,11 +29,11 @@ import org.apache.wicket.util.value.IValueMap;
/**
* https://cwiki.apache.org/WICKET/object-container-adding-flash-to-a-wicket-application.html
- *
+ *
* @author Jan Kriesten
* @author manuelbarzi
* @author James Moger
- *
+ *
*/
public class ShockWaveComponent extends ObjectContainer {
private static final long serialVersionUID = 1L;
@@ -67,7 +67,7 @@ public class ShockWaveComponent extends ObjectContainer {
attributes = new HashMap<String, String>();
parameters = new HashMap<String, String>();
}
-
+
public ShockWaveComponent(String id, String movie) {
this(id);
setValue("movie", movie);
@@ -81,6 +81,7 @@ public class ShockWaveComponent extends ObjectContainer {
setValue("height", height);
}
+ @Override
public void setValue(String name, String value) {
// IE and other browsers handle movie/data differently. So movie is used
// for IE, whereas
@@ -100,6 +101,7 @@ public class ShockWaveComponent extends ObjectContainer {
parameters.put(parameter, value);
}
+ @Override
public String getValue(String name) {
String parameter = name.toLowerCase();
String value = null;
@@ -122,6 +124,7 @@ public class ShockWaveComponent extends ObjectContainer {
return value;
}
+ @Override
public void onComponentTag(ComponentTag tag) {
// get options from the markup
IValueMap valueMap = tag.getAttributes();
@@ -142,6 +145,7 @@ public class ShockWaveComponent extends ObjectContainer {
super.onComponentTag(tag);
}
+ @Override
public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
super.onComponentTagBody(markupStream, openTag);
diff --git a/src/main/java/com/gitblit/wicket/panels/TagsPanel.java b/src/main/java/com/gitblit/wicket/panels/TagsPanel.java
index 907b3174..1e06a7fc 100644
--- a/src/main/java/com/gitblit/wicket/panels/TagsPanel.java
+++ b/src/main/java/com/gitblit/wicket/panels/TagsPanel.java
@@ -66,6 +66,7 @@ public class TagsPanel extends BasePanel {
private static final long serialVersionUID = 1L;
int counter;
+ @Override
public void populateItem(final Item<RefModel> item) {
RefModel entry = item.getModelObject();
@@ -89,7 +90,7 @@ public class TagsPanel extends BasePanel {
.getReferencedObjectId().getName())));
// workaround for RevTag returning a lengthy shortlog. :(
- String message = StringUtils.trimString(entry.getShortMessage(),
+ String message = StringUtils.trimString(entry.getShortMessage(),
com.gitblit.Constants.LEN_SHORTLOG);
if (linkClass.equals(BlobPage.class)) {
diff --git a/src/main/java/com/gitblit/wicket/panels/TeamsPanel.java b/src/main/java/com/gitblit/wicket/panels/TeamsPanel.java
index b76388b3..f567c78b 100644
--- a/src/main/java/com/gitblit/wicket/panels/TeamsPanel.java
+++ b/src/main/java/com/gitblit/wicket/panels/TeamsPanel.java
@@ -54,6 +54,7 @@ public class TeamsPanel extends BasePanel {
counter = 0;
}
+ @Override
public void populateItem(final Item<TeamModel> item) {
final TeamModel entry = item.getModelObject();
LinkPanel editLink = new LinkPanel("teamname", "list", entry.name,
diff --git a/src/main/java/com/gitblit/wicket/panels/UsersPanel.java b/src/main/java/com/gitblit/wicket/panels/UsersPanel.java
index f5b95e20..545734f0 100644
--- a/src/main/java/com/gitblit/wicket/panels/UsersPanel.java
+++ b/src/main/java/com/gitblit/wicket/panels/UsersPanel.java
@@ -56,13 +56,14 @@ public class UsersPanel extends BasePanel {
counter = 0;
}
+ @Override
public void populateItem(final Item<UserModel> item) {
final UserModel entry = item.getModelObject();
LinkPanel editLink = new LinkPanel("username", "list", entry.username,
EditUserPage.class, WicketUtils.newUsernameParameter(entry.username));
WicketUtils.setHtmlTooltip(editLink, getString("gb.edit") + " " + entry.getDisplayName());
item.add(editLink);
-
+
if (StringUtils.isEmpty(entry.displayName)) {
item.add(new Label("displayName").setVisible(false));
} else {
diff --git a/src/test/java/com/gitblit/tests/HtpasswdUserServiceTest.java b/src/test/java/com/gitblit/tests/HtpasswdUserServiceTest.java
index ef9d35ff..b5f85cd5 100644
--- a/src/test/java/com/gitblit/tests/HtpasswdUserServiceTest.java
+++ b/src/test/java/com/gitblit/tests/HtpasswdUserServiceTest.java
@@ -10,6 +10,7 @@ import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.HashMap;
+
import org.apache.commons.io.FileUtils;
import org.junit.After;
import org.junit.Before;
diff --git a/src/test/java/com/gitblit/tests/JnaUtilsTest.java b/src/test/java/com/gitblit/tests/JnaUtilsTest.java
index 25d1ccf5..03c6aead 100644
--- a/src/test/java/com/gitblit/tests/JnaUtilsTest.java
+++ b/src/test/java/com/gitblit/tests/JnaUtilsTest.java
@@ -15,14 +15,13 @@
*/
package com.gitblit.tests;
-import com.gitblit.utils.JGitUtils;
-import com.gitblit.utils.JnaUtils;
-import java.io.File;
-import java.io.IOException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import java.io.File;
+import java.io.IOException;
+
import org.apache.commons.io.FileUtils;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.RepositoryCache;
@@ -30,6 +29,9 @@ import org.eclipse.jgit.lib.RepositoryCache.FileKey;
import org.eclipse.jgit.util.FS;
import org.junit.Test;
+import com.gitblit.utils.JGitUtils;
+import com.gitblit.utils.JnaUtils;
+
/**
*
* @author Florian Zschocke