|
18 | 18 | */
|
19 | 19 |
|
20 | 20 | /*
|
21 |
| - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. |
| 21 | + * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. |
22 | 22 | * Portions Copyright (c) 2020, Chris Fraire <[email protected]>.
|
23 | 23 | */
|
24 | 24 | package org.opengrok.web.api.v1.controller;
|
|
41 | 41 | import javax.ws.rs.Consumes;
|
42 | 42 | import javax.ws.rs.DELETE;
|
43 | 43 | import javax.ws.rs.GET;
|
| 44 | +import javax.ws.rs.NotFoundException; |
44 | 45 | import javax.ws.rs.POST;
|
45 | 46 | import javax.ws.rs.PUT;
|
46 | 47 | import javax.ws.rs.Path;
|
@@ -250,27 +251,28 @@ public void markIndexed(@PathParam("project") String projectName) throws Excepti
|
250 | 251 | projectName = Laundromat.launderInput(projectName);
|
251 | 252 |
|
252 | 253 | Project project = env.getProjects().get(projectName);
|
253 |
| - if (project != null) { |
254 |
| - project.setIndexed(true); |
| 254 | + if (project == null) { |
| 255 | + logger.log(Level.WARNING, "cannot find project {0} to mark as indexed", projectName); |
| 256 | + throw new NotFoundException(String.format("project '%s' does not exist", projectName)); |
| 257 | + } |
255 | 258 |
|
256 |
| - // Refresh current version of the project's repositories. |
257 |
| - List<RepositoryInfo> riList = env.getProjectRepositoriesMap().get(project); |
258 |
| - if (riList != null) { |
259 |
| - for (RepositoryInfo ri : riList) { |
260 |
| - Repository repo = getRepository(ri, CommandTimeoutType.RESTFUL); |
| 259 | + project.setIndexed(true); |
261 | 260 |
|
262 |
| - if (repo != null && repo.getCurrentVersion() != null && repo.getCurrentVersion().length() > 0) { |
263 |
| - // getRepository() always creates fresh instance |
264 |
| - // of the Repository object so there is no need |
265 |
| - // to call setCurrentVersion() on it. |
266 |
| - ri.setCurrentVersion(repo.determineCurrentVersion()); |
267 |
| - } |
| 261 | + // Refresh current version of the project's repositories. |
| 262 | + List<RepositoryInfo> riList = env.getProjectRepositoriesMap().get(project); |
| 263 | + if (riList != null) { |
| 264 | + for (RepositoryInfo ri : riList) { |
| 265 | + Repository repo = getRepository(ri, CommandTimeoutType.RESTFUL); |
| 266 | + |
| 267 | + if (repo != null && repo.getCurrentVersion() != null && repo.getCurrentVersion().length() > 0) { |
| 268 | + // getRepository() always creates fresh instance |
| 269 | + // of the Repository object so there is no need |
| 270 | + // to call setCurrentVersion() on it. |
| 271 | + ri.setCurrentVersion(repo.determineCurrentVersion()); |
268 | 272 | }
|
269 | 273 | }
|
270 |
| - suggester.rebuild(projectName); |
271 |
| - } else { |
272 |
| - logger.log(Level.WARNING, "cannot find project {0} to mark as indexed", projectName); |
273 | 274 | }
|
| 275 | + suggester.rebuild(projectName); |
274 | 276 |
|
275 | 277 | // In case this project has just been incrementally indexed,
|
276 | 278 | // its IndexSearcher needs a poke.
|
|
0 commit comments