##### Coverage Report - org.owasp.dependencycheck.data.update.UpdateTaskFactory

Classes in this File | Line Coverage | Branch Coverage | Complexity
UpdateTaskFactory |
0% | 0/7
0% | 0/2
| 1.5;1.5

1 |  |
     /*
2 |  |
      * This file is part of dependency-check-core.
3 |  |
      *
4 |  |
      * Dependency-check-core is free software: you can redistribute it and/or modify it
5 |  |
      * under the terms of the GNU General Public License as published by the Free
6 |  |
      * Software Foundation, either version 3 of the License, or (at your option) any
7 |  |
      * later version.
8 |  |
      *
9 |  |
      * Dependency-check-core is distributed in the hope that it will be useful, but
10 |  |
      * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 |  |
      * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12 |  |
      * details.
13 |  |
      *
14 |  |
      * You should have received a copy of the GNU General Public License along with
15 |  |
      * dependency-check-core. If not, see http://www.gnu.org/licenses/.
16 |  |
      *
17 |  |
      * Copyright (c) 2012 Jeremy Long. All Rights Reserved.
18 |  |
      */
19 |  |
     package org.owasp.dependencycheck.data.update;
20 |  |
21 |  |
     import java.net.MalformedURLException;
22 |  |
     import org.owasp.dependencycheck.data.UpdateException;
23 |  |
     import org.owasp.dependencycheck.utils.DownloadFailedException;
24 |  |
25 |  |
     /**
26 |  |
      * An UpdateTask Factory that instantiates the correct UpdateTask based on the
27 |  |
      * given configuration.
28 |  |
      *
29 |  |
      * @author Jeremy Long (jeremy.long@owasp.org)
30 |  |
      */
31 |  |
     public final class UpdateTaskFactory {
32 |  |
33 |  |
         /**
34 |  |
          * private constructor for a utility class.
35 |  |
          */
36 | 0 |
         private UpdateTaskFactory() {
37 |  |
             //empty contrusctor for utility class
38 | 0 |
         }
39 |  |
40 |  |
         /**
41 |  |
          * Constructs the appropriate update task based on configuration.
42 |  |
          *
43 |  |
          * @return an UpdateTask
44 |  |
          * @throws MalformedURLException thrown if a configured URL is malformed
45 |  |
          * @throws DownloadFailedException thrown if a timestamp cannot be checked
46 |  |
          * on a configured URL
47 |  |
          * @throws UpdateException thrown if there is an exception generating the
48 |  |
          * update task
49 |  |
          */
50 |  |
         public static UpdateTask getUpdateTask() throws MalformedURLException, DownloadFailedException, UpdateException {
51 |  |
             final UpdateTask task;
52 | 0 |
             final DataStoreMetaInfo properties = new DataStoreMetaInfo();
53 | 0 |
             if (properties.isBatchUpdateMode()) {
54 | 0 |
                 task = new BatchUpdateTask(properties);
55 |  |
             } else {
56 | 0 |
                 task = new StandardUpdateTask(properties);
57 |  |
             }
58 | 0 |
             return task;
59 |  |
         }
60 |  |
     }