├── src
├── main
│ ├── resources
│ │ ├── code.json
│ │ ├── log4j2.xml
│ │ └── config.properties
│ ├── webapp
│ │ ├── favicon.ico
│ │ ├── index.html
│ │ └── WEB-INF
│ │ │ └── web.xml
│ └── java
│ │ └── gov
│ │ └── faa
│ │ └── ait
│ │ └── apra
│ │ ├── util
│ │ ├── ChartCycleJsonUnmarshaller.java
│ │ ├── JsonUtil.java
│ │ ├── ChartInfoTable.java
│ │ ├── URLCache.java
│ │ ├── TACSpecialCase.java
│ │ ├── GenericsUtil.java
│ │ ├── ChartInfoTableKey.java
│ │ ├── TableChartClient.java
│ │ ├── SupplementMetadataClient.java
│ │ └── CycleDateUtil.java
│ │ ├── cycle
│ │ ├── ChartCycleData.java
│ │ ├── ChartCycleElementsJson.java
│ │ ├── DenodoClient.java
│ │ ├── HelicopterChartCycleClient.java
│ │ └── WallPlanningChartCycleClient.java
│ │ ├── json
│ │ ├── TPPChartMetadata.java
│ │ ├── SupplementChartMetadata.java
│ │ ├── USState.java
│ │ ├── USStateReference.java
│ │ └── SupplementMetadata.java
│ │ ├── bootstrap
│ │ ├── ErrorCodes.java
│ │ ├── TPPVolume.java
│ │ └── USStateReferenceData.java
│ │ ├── path
│ │ ├── ProductPath.java
│ │ └── PathElement.java
│ │ └── api
│ │ ├── DownloadServiceApp.java
│ │ ├── ProductApiListener.java
│ │ ├── management
│ │ └── ManagementControl.java
│ │ ├── DigitalEnrouteSupplementCharts.java
│ │ └── DailyDigitalObstacleFile.java
└── test
│ └── java
│ └── gov
│ └── faa
│ └── ait
│ └── apra
│ └── test
│ ├── TPPVolumeTest.java
│ ├── KeyTest.java
│ ├── DDOFTest.java
│ ├── IfrPlanningChartsTest.java
│ ├── SectionalChartsTest.java
│ ├── StateReferenceTest.java
│ ├── ManagementTest.java
│ ├── DECTest.java
│ ├── VerifyValues.java
│ ├── SectionalChartTableTest.java
│ ├── DERSTest.java
│ ├── NASRTest.java
│ ├── ChartCycleTest.java
│ ├── IFREnrouteFunctionalTest.java
│ ├── SectionalChartClientTest.java
│ ├── CycleDateTest.java
│ ├── CIFPTest.java
│ ├── WallPlanningChartsTest.java
│ ├── IFREnrouteChartsTest.java
│ ├── VFRChartsTest.java
│ ├── CityNameConversionTest.java
│ ├── HelicopterChartsTest.java
│ ├── VFRFunctionalTest.java
│ ├── GOMTest.java
│ ├── CIFP2Test.java
│ ├── HelicopterFunctionalTest.java
│ └── SupplementFunctionalTest.java
├── CONTRIBUTING.md
├── LICENSE.md
├── README.md
└── pom.xml
/src/main/resources/code.json:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Federal-Aviation-Administration/APRA/HEAD/src/main/resources/code.json
--------------------------------------------------------------------------------
/src/main/webapp/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Federal-Aviation-Administration/APRA/HEAD/src/main/webapp/favicon.ico
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | Public domain
2 |
3 | This project is in the public domain within the United States, and copyright and related rights in the work worldwide are waived through the CC0 1.0 Universal public domain dedication.
4 |
5 | All contributions to this project will be released under the CC0 dedication. By submitting a pull request or modifying any of this project's content you are agreeing to comply with this waiver of copyright interest.
6 |
--------------------------------------------------------------------------------
/src/main/webapp/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Aeronautic Product Release API - APRA
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/main/java/gov/faa/ait/apra/util/ChartCycleJsonUnmarshaller.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Federal Aviation Administration (FAA) public work
3 | *
4 | * As a work of the United States Government, this project is in the
5 | * public domain within the United States. Additionally, we waive copyright
6 | * and related rights in the work worldwide
7 | * through the Creative Commons 0 (CC0) 1.0 Universal public domain dedication
8 | *
9 | * APRA is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 | *
13 | */
14 | package gov.faa.ait.apra.util;
15 |
16 | import gov.faa.ait.apra.cycle.ChartCycleData;
17 |
18 | public class ChartCycleJsonUnmarshaller extends JsonUtil {
19 | public ChartCycleJsonUnmarshaller() {
20 |
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/src/test/java/gov/faa/ait/apra/test/TPPVolumeTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Federal Aviation Administration (FAA) public work
3 | *
4 | * As a work of the United States Government, this project is in the
5 | * public domain within the United States. Additionally, we waive copyright
6 | * and related rights in the work worldwide
7 | * through the Creative Commons 0 (CC0) 1.0 Universal public domain dedication
8 | *
9 | * APRA is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 | *
13 | */
14 | package gov.faa.ait.apra.test;
15 |
16 | import gov.faa.ait.apra.bootstrap.TPPVolume;
17 | import static org.junit.Assert.fail;
18 |
19 | import org.junit.Test;
20 |
21 | public class TPPVolumeTest {
22 |
23 | @Test
24 | public void getNortheastTest () {
25 | if (! TPPVolume.isValidVolumeName("NE-1"))
26 | fail();
27 |
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/test/java/gov/faa/ait/apra/test/KeyTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Federal Aviation Administration (FAA) public work
3 | *
4 | * As a work of the United States Government, this project is in the
5 | * public domain within the United States. Additionally, we waive copyright
6 | * and related rights in the work worldwide
7 | * through the Creative Commons 0 (CC0) 1.0 Universal public domain dedication
8 | *
9 | * APRA is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 | *
13 | */
14 | package gov.faa.ait.apra.test;
15 |
16 | import static org.junit.Assert.*;
17 |
18 | import org.junit.Test;
19 |
20 | import gov.faa.ait.apra.util.ChartInfoTableKey;
21 |
22 | public class KeyTest {
23 |
24 | @Test
25 | public void test() {
26 | ChartInfoTableKey k1 = new ChartInfoTableKey("ALBUQUERQUE", "CURRENT", "SECTIONAL");
27 | ChartInfoTableKey k2 = new ChartInfoTableKey("ALBUQUERQUE", "NEXT", "SECTIONAL");
28 |
29 | assertEquals(k1,k1);
30 | assertEquals(k2,k2);
31 | assertEquals(k1.hashCode(), k1.hashCode());
32 | assertEquals(k2.hashCode(), k2.hashCode());
33 | assertNotEquals(k1,k2);
34 | assertNotEquals(k1.hashCode(), k2.hashCode());
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | As a work of the United States government, this project is in the public domain within the United States.
2 |
3 | Additionally, we waive copyright and related rights in the work worldwide through the CC0 1.0 Universal public domain dedication.
4 |
5 | CC0 1.0 Universal summary
6 |
7 | This is a human-readable summary of the Legal Code found here: https://creativecommons.org/publicdomain/zero/1.0/legalcode
8 |
9 | No copyright
10 |
11 | The person who associated a work with this deed has dedicated the work to the public domain by waiving all rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law.
12 |
13 | You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.
14 |
15 | Other information
16 |
17 | In no way are the patent or trademark rights of any person affected by CC0, nor are the rights that other persons may have in the work or in how the work is used, such as publicity or privacy rights.
18 |
19 | Unless expressly stated otherwise, the person who associated a work with this deed makes no warranties about the work, and disclaims liability for all uses of the work, to the fullest extent permitted by applicable law. When using or citing the work, you should not imply endorsement by the author or the affirmer.
20 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Aeronautic Product Release API (APRA)
2 |
3 | APRA provides the private sector greater access to core FAA data to spur more innovation in the aviation industry,
4 | and ultimately advance the FAA's mission of safety in flight. Based on stakeholder recommendations, this
5 | initiative's first effort strived to provide both more data and better data for Aeronautical products and
6 | information. Solution Delivery developed and deployed web services for several aeronautical products including both
7 | information about those products and the ability to automatically download those products which satisfied one of
8 | the recommendations.
9 |
10 | ## About APRA
11 |
12 | APRA provides a mechanism for a client program to scan the FAA public web site for a specific type of aeronautic
13 | product for download. The aeronautic products available include charts in various formats. Such charts are often
14 | released to the public on either a 28 day or 56 day airspace cycle. Upon release of charts, the URL(s) for
15 | the chart retrieval necessarily change. APRA constructs the standard URL where the chart may be downloaded
16 | to enable a software application to pull the charts without the need for a human interface or web based GUI.
17 |
18 | ## Documentation
19 |
20 | Documentation for the API may be found on swaggerhub
21 | https://app.swaggerhub.com/apis/FAA/APRA
22 |
--------------------------------------------------------------------------------
/src/test/java/gov/faa/ait/apra/test/DDOFTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Federal Aviation Administration (FAA) public work
3 | *
4 | * As a work of the United States Government, this project is in the
5 | * public domain within the United States. Additionally, we waive copyright
6 | * and related rights in the work worldwide
7 | * through the Creative Commons 0 (CC0) 1.0 Universal public domain dedication
8 | *
9 | * APRA is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 | *
13 | */
14 | package gov.faa.ait.apra.test;
15 |
16 | import static org.junit.Assert.fail;
17 |
18 | import javax.ws.rs.core.Response;
19 |
20 | import org.junit.Test;
21 |
22 | import gov.faa.ait.apra.api.DailyDigitalObstacleFile;
23 |
24 | public class DDOFTest {
25 |
26 | @Test
27 | public void releaseTest () {
28 | DailyDigitalObstacleFile ddof = new DailyDigitalObstacleFile();
29 | Response response = ddof.getDDOFRelease();
30 | if (response.getStatus() != 200)
31 | fail();
32 | }
33 |
34 | @Test
35 | public void editionTest () {
36 | DailyDigitalObstacleFile ddof = new DailyDigitalObstacleFile();
37 | Response response = ddof.getDDOFEdition();
38 | if (response.getStatus() != 200)
39 | fail();
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/resources/log4j2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | [%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %X{ID} %c{1} - %msg%n
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | [%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %X{ID} %c{1} - %msg%n
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/src/main/java/gov/faa/ait/apra/cycle/ChartCycleData.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Federal Aviation Administration (FAA) public work
3 | *
4 | * As a work of the United States Government, this project is in the
5 | * public domain within the United States. Additionally, we waive copyright
6 | * and related rights in the work worldwide
7 | * through the Creative Commons 0 (CC0) 1.0 Universal public domain dedication
8 | *
9 | * APRA is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 | *
13 | */
14 | package gov.faa.ait.apra.cycle;
15 |
16 | public class ChartCycleData {
17 | private String name;
18 | private ChartCycleElementsJson [] elements;
19 |
20 | public ChartCycleData () {
21 | name = "";
22 | elements = new ChartCycleElementsJson [1];
23 | }
24 |
25 | public ChartCycleData (String name, ChartCycleElementsJson [] elements) {
26 | this.name = new String (name);
27 | this.elements = elements.clone();
28 | }
29 |
30 | public String getName() {
31 | return name;
32 | }
33 |
34 | public void setName(String name) {
35 | this.name = name;
36 | }
37 |
38 | public ChartCycleElementsJson [] getElements() {
39 | return elements.clone();
40 | }
41 |
42 | public void setElements(ChartCycleElementsJson [] elements) {
43 | this.elements = elements.clone();
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/gov/faa/ait/apra/json/TPPChartMetadata.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Federal Aviation Administration (FAA) public work
3 | *
4 | * As a work of the United States Government, this project is in the
5 | * public domain within the United States. Additionally, we waive copyright
6 | * and related rights in the work worldwide
7 | * through the Creative Commons 0 (CC0) 1.0 Universal public domain dedication
8 | *
9 | * APRA is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 | *
13 | */
14 | package gov.faa.ait.apra.json;
15 |
16 | /**
17 | * This class holds the top level TPP chart metadata object as returned by denodo. This is just a POJO data class
18 | * for the denodo response of the serialized and virtualized XML metadata file for TPP
19 | *
20 | */
21 | public class TPPChartMetadata {
22 | private String name;
23 | private TPPMetadata[] elements;
24 |
25 | public TPPChartMetadata () {
26 | name = "";
27 | elements = new TPPMetadata [1];
28 | }
29 |
30 | public String getName() {
31 | return name;
32 | }
33 |
34 | public void setName(String name) {
35 | this.name = name;
36 | }
37 |
38 | public TPPMetadata [] getElements() {
39 | return elements.clone();
40 | }
41 |
42 | public void setElements(TPPMetadata [] elements) {
43 | this.elements = elements.clone();
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/gov/faa/ait/apra/json/SupplementChartMetadata.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Federal Aviation Administration (FAA) public work
3 | *
4 | * As a work of the United States Government, this project is in the
5 | * public domain within the United States. Additionally, we waive copyright
6 | * and related rights in the work worldwide
7 | * through the Creative Commons 0 (CC0) 1.0 Universal public domain dedication
8 | *
9 | * APRA is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 | *
13 | */
14 | package gov.faa.ait.apra.json;
15 |
16 | /**
17 | * This class holds the top level Supplement chart metadata object as returned by denodo.
18 | * This is just a POJO data class for the denodo response of the serialized and virtualized
19 | * XML metadata file for Supplement
20 | *
21 | * @author FAA
22 | *
23 | */
24 | public class SupplementChartMetadata {
25 | private String name;
26 | private SupplementMetadata[] elements;
27 |
28 | public SupplementChartMetadata () {
29 | name = "";
30 | elements = new SupplementMetadata [1];
31 | }
32 |
33 | public String getName() {
34 | return name;
35 | }
36 |
37 | public void setName(String name) {
38 | this.name = name;
39 | }
40 |
41 | public SupplementMetadata [] getElements() {
42 | return elements.clone();
43 | }
44 |
45 | public void setElements(SupplementMetadata [] elements) {
46 | this.elements = elements.clone();
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/gov/faa/ait/apra/bootstrap/ErrorCodes.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Federal Aviation Administration (FAA) public work
3 | *
4 | * As a work of the United States Government, this project is in the
5 | * public domain within the United States. Additionally, we waive copyright
6 | * and related rights in the work worldwide
7 | * through the Creative Commons 0 (CC0) 1.0 Universal public domain dedication
8 | *
9 | * APRA is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 | *
13 | */
14 | package gov.faa.ait.apra.bootstrap;
15 |
16 | /**
17 | * This class is used to manage the error codes and error responses that can be returned from the application
18 | * @author FAA
19 | *
20 | */
21 | public class ErrorCodes {
22 |
23 | // Hide the default public constructor. This is a utility class that needs no constructor
24 | private ErrorCodes () { }
25 |
26 | public static final String RESPONSE_200="OK";
27 | public static final String ERROR_400="Illegal arguments provided to service. One or more of the service parameter values is invalid";
28 | public static final String ERROR_404="Requested edition has not been released for download or could not be found on the FAA aeronav web site.";
29 | public static final String ERROR_500="Internal service error occurred which prevented a valid response from being returned.";
30 | public static final String DEPRECATED="This product has been deprecated and is no longer published by the FAA.";
31 | }
32 |
--------------------------------------------------------------------------------
/src/test/java/gov/faa/ait/apra/test/IfrPlanningChartsTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Federal Aviation Administration (FAA) public work
3 | *
4 | * As a work of the United States Government, this project is in the
5 | * public domain within the United States. Additionally, we waive copyright
6 | * and related rights in the work worldwide
7 | * through the Creative Commons 0 (CC0) 1.0 Universal public domain dedication
8 | *
9 | * APRA is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 | *
13 | */
14 | package gov.faa.ait.apra.test;
15 |
16 | import static org.junit.Assert.*;
17 |
18 | import java.util.Calendar;
19 |
20 | import org.junit.Test;
21 |
22 | import gov.faa.ait.apra.api.UsIfrVfrPlanning;
23 | import gov.faa.ait.apra.jaxb.ProductSet;
24 | import gov.faa.ait.apra.util.TableChartClient;
25 |
26 | public class IfrPlanningChartsTest {
27 |
28 | @Test
29 | public void test() {
30 | Calendar cal = Calendar.getInstance();
31 | //cal.set(2016, 05, 15); // careful, 0-based month
32 | TableChartClient client = new TableChartClient(cal.getTime());
33 | UsIfrVfrPlanning api = new UsIfrVfrPlanning(client);
34 | ProductSet result = (ProductSet) api.getIfrPlanningChart("current", "pdf").getEntity();
35 | assertTrue(!result.getEdition().isEmpty());
36 | String url = result.getEdition().get(0).getProduct().getUrl();
37 | assertTrue("URL was null",url!=null);
38 | assertTrue("URL did not match pattern",url.matches("http://aeronav.faa.gov/enroute/IFR_Planning/[0-9]{2}-[0-9]{2}-[0-9]{4}/US_IFR_Planning_pdf.zip"));
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/test/java/gov/faa/ait/apra/test/SectionalChartsTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Federal Aviation Administration (FAA) public work
3 | *
4 | * As a work of the United States Government, this project is in the
5 | * public domain within the United States. Additionally, we waive copyright
6 | * and related rights in the work worldwide
7 | * through the Creative Commons 0 (CC0) 1.0 Universal public domain dedication
8 | *
9 | * APRA is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 | *
13 | */
14 | package gov.faa.ait.apra.test;
15 |
16 | import static org.junit.Assert.*;
17 |
18 | import java.util.Calendar;
19 |
20 | import org.junit.Test;
21 |
22 | import gov.faa.ait.apra.api.SectionalCharts;
23 | import gov.faa.ait.apra.bootstrap.ErrorCodes;
24 | import gov.faa.ait.apra.jaxb.ProductSet;
25 | import gov.faa.ait.apra.jaxb.ProductSet.Edition;
26 |
27 | public class SectionalChartsTest {
28 |
29 | @Test
30 | public void test() {
31 | SectionalCharts api = new SectionalCharts();
32 | ProductSet result = (ProductSet) api.getSectionalChart("Albuquerque", "current", "pdf").getEntity();
33 | assertTrue(!result.getEdition().isEmpty());
34 | Edition ed = result.getEdition().get(0);
35 | assertEquals(100,ed.getEditionNumber());
36 | }
37 |
38 | @Test
39 | public void testInvalidCity() {
40 | SectionalCharts api = new SectionalCharts();
41 | ProductSet result = (ProductSet) api.getSectionalChart("Albuquer", "current", "pdf").getEntity();
42 | assertEquals(Integer.valueOf(404),result.getStatus().getCode());
43 | assertEquals(ErrorCodes.ERROR_404, result.getStatus().getMessage());
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/test/java/gov/faa/ait/apra/test/StateReferenceTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Federal Aviation Administration (FAA) public work
3 | *
4 | * As a work of the United States Government, this project is in the
5 | * public domain within the United States. Additionally, we waive copyright
6 | * and related rights in the work worldwide
7 | * through the Creative Commons 0 (CC0) 1.0 Universal public domain dedication
8 | *
9 | * APRA is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 | *
13 | */
14 | package gov.faa.ait.apra.test;
15 |
16 | import static org.junit.Assert.fail;
17 |
18 | import java.util.Locale;
19 |
20 | import org.apache.commons.lang3.text.WordUtils;
21 | import org.junit.Test;
22 |
23 |
24 | import gov.faa.ait.apra.bootstrap.USStateReferenceData;
25 |
26 | public class StateReferenceTest {
27 |
28 | @Test
29 | public void getNebraskaByAbbr () {
30 | String nebraska = USStateReferenceData.getStateName("NE");
31 | if (! "NEBRASKA".equals(nebraska))
32 | fail();
33 | }
34 |
35 | @Test
36 | public void getNebraskaByName () {
37 | String nebraska = USStateReferenceData.getAbbreviation("NEBRASKA");
38 | if (! "NE".equals(nebraska))
39 | fail();
40 | }
41 |
42 | @Test
43 | public void getNewYorkByAbbr () {
44 | String newYork = USStateReferenceData.getStateName("NY");
45 | if (! "NEW YORK".equals(newYork))
46 | fail();
47 | }
48 |
49 | @Test
50 | public void getNewYorkCapitalized () {
51 | String newYork = USStateReferenceData.getStateName("NY");
52 | char[] separators = {'-', '_', ' '};
53 | String capitalized = WordUtils.capitalize(newYork.toLowerCase(Locale.ENGLISH), separators);
54 | if (! "New York".equals(capitalized))
55 | fail();
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/src/test/java/gov/faa/ait/apra/test/ManagementTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Federal Aviation Administration (FAA) public work
3 | *
4 | * As a work of the United States Government, this project is in the
5 | * public domain within the United States. Additionally, we waive copyright
6 | * and related rights in the work worldwide
7 | * through the Creative Commons 0 (CC0) 1.0 Universal public domain dedication
8 | *
9 | * APRA is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 | *
13 | */
14 | package gov.faa.ait.apra.test;
15 |
16 | import static org.junit.Assert.assertEquals;
17 |
18 | import org.junit.Test;
19 |
20 | import gov.faa.ait.apra.api.management.ManagementControl;
21 |
22 | public class ManagementTest {
23 |
24 | @Test
25 | public void getStatus () {
26 | ManagementControl check = new ManagementControl();
27 | ManagementControl.start();
28 | String state = check.getStatus();
29 | assertEquals(state, "ServerOK");
30 | }
31 |
32 | @Test
33 | public void getStart () {
34 | ManagementControl check = new ManagementControl();
35 | ManagementControl.start();
36 | String state = check.getStatus();
37 | assertEquals(state, "ServerOK");
38 | }
39 |
40 | @Test
41 | public void getStop () {
42 | ManagementControl check = new ManagementControl();
43 | ManagementControl.stop();
44 | String state = check.getStatus();
45 | assertEquals(state, "ServerDown");
46 | }
47 |
48 | @Test
49 | public void refresh () {
50 | ManagementControl check = new ManagementControl();
51 | assertEquals(check.refresh(), "Cycle Reload Complete");
52 | }
53 |
54 | @Test
55 | public void reloadConfig () {
56 | ManagementControl check = new ManagementControl();
57 | assertEquals(check.reloadConfig(), "Config Reload Complete");
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/main/java/gov/faa/ait/apra/json/USState.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Federal Aviation Administration (FAA) public work
3 | *
4 | * As a work of the United States Government, this project is in the
5 | * public domain within the United States. Additionally, we waive copyright
6 | * and related rights in the work worldwide
7 | * through the Creative Commons 0 (CC0) 1.0 Universal public domain dedication
8 | *
9 | * APRA is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 | *
13 | */
14 | package gov.faa.ait.apra.json;
15 |
16 | /**
17 | * This class represents a US state. It contains the US state full name and its 2-letter abbreviation. This is the
18 | * class that Jackson serializes from a JSON object set into a POJO
19 | *
20 | */
21 | public class USState {
22 | private String abbreviation;
23 | private String name;
24 |
25 | /**
26 | * Default null constructor returns District of Columbia, DC
27 | */
28 | public USState () {
29 | abbreviation = "DC";
30 | name = "District of Columbia";
31 | }
32 |
33 | /**
34 | * Get the state 2-letter abbreviation
35 | * @return the 2-letter abbreviation as a string
36 | */
37 | public String getAbbreviation() {
38 | return abbreviation;
39 | }
40 |
41 | /**
42 | * Set the state 2-letter abbreviation
43 | * @param abbreviation
44 | */
45 | public void setAbbreviation(String abbreviation) {
46 | this.abbreviation = abbreviation;
47 | }
48 |
49 | /**
50 | * Get the state proper name
51 | * @return proper name of the state or territory
52 | */
53 | public String getName() {
54 | return name;
55 | }
56 |
57 | /**
58 | * Set the state proper name
59 | * @param name state or territory name
60 | */
61 | public void setName(String name) {
62 | this.name = name;
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/src/main/java/gov/faa/ait/apra/json/USStateReference.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Federal Aviation Administration (FAA) public work
3 | *
4 | * As a work of the United States Government, this project is in the
5 | * public domain within the United States. Additionally, we waive copyright
6 | * and related rights in the work worldwide
7 | * through the Creative Commons 0 (CC0) 1.0 Universal public domain dedication
8 | *
9 | * APRA is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 | *
13 | */
14 | package gov.faa.ait.apra.json;
15 |
16 | /**
17 | * A US state reference set of information that includes state name and abbreviation.
18 | * Used by Jackson to marshal and unmarshal the JSON objects from the denodo reference data set
19 | *
20 | */
21 | public class USStateReference {
22 | private String name;
23 | private USState [] elements;
24 |
25 | /**
26 | * Default constructor initializes members
27 | */
28 |
29 | public USStateReference () {
30 | name = "";
31 | elements = null;
32 | }
33 |
34 | /**
35 | * Get the name of the reference set
36 | * @return name of the reference set
37 | */
38 | public String getName() {
39 | return name;
40 | }
41 |
42 | /**
43 | * Set the name of the reference set
44 | * @param name the name of the reference data set
45 | */
46 | public void setName(String name) {
47 | this.name = name;
48 | }
49 |
50 | /**
51 | * Get the elements of the reference set as an array. The elements contain the listing of US states and their 2-letter abbreviations
52 | * @return all of the elements from the reference data set
53 | */
54 | public USState [] getElements() {
55 | return elements.clone();
56 | }
57 |
58 | /**
59 | * Set the elements of the data set. A listing of all US state names and abbreviations
60 | * @param elements the list of states and abbreviations
61 | */
62 | public void setElements(USState [] elements) {
63 | this.elements = elements.clone();
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/main/java/gov/faa/ait/apra/util/JsonUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Federal Aviation Administration (FAA) public work
3 | *
4 | * As a work of the United States Government, this project is in the
5 | * public domain within the United States. Additionally, we waive copyright
6 | * and related rights in the work worldwide
7 | * through the Creative Commons 0 (CC0) 1.0 Universal public domain dedication
8 | *
9 | * APRA is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 | *
13 | */
14 | package gov.faa.ait.apra.util;
15 |
16 | import java.io.IOException;
17 | import java.text.SimpleDateFormat;
18 | import java.util.List;
19 |
20 | import com.fasterxml.jackson.core.JsonParseException;
21 | import com.fasterxml.jackson.databind.DeserializationFeature;
22 | import com.fasterxml.jackson.databind.JsonMappingException;
23 | import com.fasterxml.jackson.databind.ObjectMapper;
24 | import com.google.common.base.Charsets;
25 | /**
26 | * Unmarshalling utility class for json data. Target type must extend this.
27 | * This construct was due to Java Generics and type erasure.
28 | *
29 | * @author FAA
30 | *
31 | * @param
32 | */
33 | public abstract class JsonUtil {
34 |
35 | /**
36 | *
37 | * @param unbound
38 | * @return
39 | * @throws IOException
40 | * @throws JsonParseException
41 | * @throws JsonMappingException
42 | */
43 | @SuppressWarnings("unchecked")
44 | public T unmarshalJson(String unbound)
45 | throws IOException, JsonParseException, JsonMappingException {
46 | ObjectMapper mapper = new ObjectMapper();
47 | mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
48 | mapper.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true);
49 | mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd"));
50 | Class> targetClass = (Class) GenericsUtil.getTypeArguments(JsonUtil.class, this.getClass()).get(0);
51 | return (T) mapper.readValue(unbound.getBytes(Charsets.UTF_16), targetClass);
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/gov/faa/ait/apra/util/ChartInfoTable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Federal Aviation Administration (FAA) public work
3 | *
4 | * As a work of the United States Government, this project is in the
5 | * public domain within the United States. Additionally, we waive copyright
6 | * and related rights in the work worldwide
7 | * through the Creative Commons 0 (CC0) 1.0 Universal public domain dedication
8 | *
9 | * APRA is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 | *
13 | */
14 | package gov.faa.ait.apra.util;
15 |
16 | import java.util.concurrent.ConcurrentHashMap;
17 |
18 | import gov.faa.ait.apra.cycle.ChartCycleData;
19 | import gov.faa.ait.apra.cycle.ChartCycleElementsJson;
20 |
21 | /**
22 | * This class stores Chart Info from ChartCycleJson in a map format
23 | * @author FAA
24 | *
25 | */
26 | public class ChartInfoTable extends ConcurrentHashMap {
27 |
28 | /**
29 | *
30 | */
31 | private static final long serialVersionUID = -4599811904037606947L;
32 |
33 | /**
34 | * Default constructor, empty map with default capacity
35 | */
36 | public ChartInfoTable() {
37 | super();
38 | }
39 |
40 | /**
41 | * Constructor for default capacity, with data to load
42 | * @param chartCycle the chart cycle information in json model class
43 | */
44 | public ChartInfoTable(ChartCycleData chartCycle) {
45 | super();
46 | load(chartCycle);
47 | }
48 |
49 | /**
50 | * Method to reload chart cycle data
51 | * @param chartCycle Chart cycle data in json model eclass
52 | */
53 | public void load(ChartCycleData chartCycle) {
54 | for(ChartCycleElementsJson element: chartCycle.getElements()) {
55 | //System.out.println(element.getChart_city_name()+"; "+element.getChart_cycle_number()+"; "+element.getChart_cycle_period_code()+"; "+element.getChart_cycle_type_code());
56 | ChartInfoTableKey key = new ChartInfoTableKey(
57 | element.getChart_city_name().toUpperCase(),
58 | element.getChart_cycle_period_code().toUpperCase(),
59 | element.getChart_cycle_type_code().toUpperCase());
60 | this.put(key, element);
61 | }
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/src/test/java/gov/faa/ait/apra/test/DECTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Federal Aviation Administration (FAA) public work
3 | *
4 | * As a work of the United States Government, this project is in the
5 | * public domain within the United States. Additionally, we waive copyright
6 | * and related rights in the work worldwide
7 | * through the Creative Commons 0 (CC0) 1.0 Universal public domain dedication
8 | *
9 | * APRA is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 | *
13 | */
14 | package gov.faa.ait.apra.test;
15 |
16 | import static org.junit.Assert.assertEquals;
17 | import static org.junit.Assert.assertTrue;
18 | import static org.junit.Assert.fail;
19 |
20 | import javax.ws.rs.core.Response;
21 |
22 | import org.junit.Test;
23 | import org.slf4j.Logger;
24 | import org.slf4j.LoggerFactory;
25 |
26 | import gov.faa.ait.apra.api.DigitalEnrouteCharts;
27 | import gov.faa.ait.apra.cycle.ChartCycleClient;
28 | import gov.faa.ait.apra.jaxb.ProductSet;
29 |
30 | public class DECTest {
31 | private DigitalEnrouteCharts dec;
32 | private static final Logger logger = LoggerFactory.getLogger(DECTest.class);
33 |
34 | public DECTest () {
35 | ChartCycleClient client = new ChartCycleClient();
36 | client.forceUpdate();
37 | }
38 |
39 | @Test
40 | public void testCurrentRelease() {
41 | dec = new DigitalEnrouteCharts();
42 | Response ps = dec.getDECRelease("current");
43 | int code = ps.getStatus();
44 | assertEquals(code, 200);
45 | ProductSet psEntity = (ProductSet) ps.getEntity();
46 | assertTrue(VerifyValues.verifyURL(psEntity.getEdition().get(0).getProduct().getUrl()));
47 | }
48 |
49 | @Test
50 | public void testNextRelease() {
51 | dec = new DigitalEnrouteCharts();
52 | Response ps = dec.getDECRelease("next");
53 | int code = ps.getStatus();
54 |
55 | // Have to allow for either a positive response or a not found due to the AJV release cycle. A "next" edition may
56 | // only be published 20 days in advance. Therefore, there is a time period when we may ask for "next", but it really hasn't
57 | // been put on the web site yet
58 | if (! (code == 200 || code == 404) ) {
59 | fail();
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/main/resources/config.properties:
--------------------------------------------------------------------------------
1 | gov.faa.ait.aeronav.host=http://www.aeronav.faa.gov
2 | gov.faa.ait.denodo.host=https://soadev.sm.faa.gov
3 | gov.faa.ait.nfdc.host=https://nfdc.faa.gov
4 | gov.faa.ait.aeronav.upload.folder=upload_313-d
5 | gov.faa.ait.aeronav.sectional.folder=/content/aeronav/sectional_files
6 | gov.faa.ait.aeronav.vfr.upload.folder=content/aeronav/grand_canyon_files
7 | gov.faa.ait.aeronav.wallplan.upload.folder=content/aeronav/grand_canyon_files
8 | gov.faa.ait.aeronav.enroute.upload.folder=enroute
9 | gov.faa.ait.aeronav.helicopter.upload.folder=content/aeronav/heli_files
10 | gov.faa.ait.denodo.cycle.resource=/denodo/apra/server/ifpa/edai/views/chart_cycle
11 | gov.faa.ait.denodo.vfr.cycle.resource=/denodo/apra/server/ifpa/edai/vfr_chart_cycle
12 | gov.faa.ait.cycle.ageLimit=1
13 | gov.faa.ait.sup.chart.path=/afd
14 | gov.faa.ait.nfdc.nasr.path=/webContent/28DaySub
15 | gov.faa.ait.nasr.date.format=yyyy-MM-dd
16 | gov.faa.ait.nasr.file.prefix=28DaySubscription_Effective_
17 | gov.faa.ait.sup.us.path=/upload_313-d/supplements
18 | gov.faa.ait.sup.check.flag=false
19 | gov.faa.ait.nasr.check.flag=false
20 |
21 |
22 | # DMZ proxy information. Required for APRA to reach back to the Intranet for denodo support services
23 | # If proxy not required, leave blank
24 | gov.faa.dmz.proxy.host=http://dmzproxy.esc.gov
25 | gov.faa.dmz.proxy.port=8080
26 |
27 | # IFR en route properties
28 | gov.faa.ait.enroute.count.us.area.pdf=1
29 | gov.faa.ait.enroute.count.us.area.tiff=2
30 | gov.faa.ait.enroute.count.us.low.tiff=36
31 | gov.faa.ait.enroute.count.us.low.pdf=36
32 | gov.faa.ait.enroute.count.us.high.tiff=12
33 | gov.faa.ait.enroute.count.us.high.pdf=12
34 | gov.faa.ait.enroute.count.alaska.low.tiff=4
35 | gov.faa.ait.enroute.count.alaska.low.pdf=4
36 | gov.faa.ait.enroute.count.alaska.high.tiff=2
37 | gov.faa.ait.enroute.count.alaska.high.pdf=2
38 | gov.faa.ait.enroute.count.pacific.low.tiff=0
39 | gov.faa.ait.enroute.count.pacific.low.pdf=0
40 | gov.faa.ait.enroute.count.pacific.high.tiff=2
41 | gov.faa.ait.enroute.count.pacific.high.pdf=2
42 | gov.faa.ait.enroute.count.caribbean.area.pdf=4
43 | gov.faa.ait.enroute.count.caribbean.area.tiff=0
44 | gov.faa.ait.enroute.count.caribbean.low.pdf=6
45 | gov.faa.ait.enroute.count.caribbean.high.pdf=2
46 | gov.faa.ait.enroute.count.caribbean.low.tiff=0
47 | gov.faa.ait.enroute.count.caribbean.high.tiff=0
48 |
49 |
--------------------------------------------------------------------------------
/src/main/java/gov/faa/ait/apra/path/ProductPath.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Federal Aviation Administration (FAA) public work
3 | *
4 | * As a work of the United States Government, this project is in the
5 | * public domain within the United States. Additionally, we waive copyright
6 | * and related rights in the work worldwide
7 | * through the Creative Commons 0 (CC0) 1.0 Universal public domain dedication
8 | *
9 | * APRA is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 | *
13 | */
14 | package gov.faa.ait.apra.path;
15 |
16 | import java.util.ArrayList;
17 |
18 | /**
19 | * Represents a path to a file which contains multiple path elements such as directories or a file.
20 | * @author FAA
21 | *
22 | */
23 | public class ProductPath {
24 |
25 | private ArrayList path;
26 | private boolean complete = false;
27 |
28 | /**
29 | * Null constructor to create the default path
30 | */
31 | public ProductPath () {
32 | this.path = new ArrayList <> ();
33 | this.complete = false;
34 | }
35 |
36 | /**
37 | * Add a new path element to this path
38 | * @param pe the path element to add to this path
39 | */
40 | public void addPathElement (PathElement pe) {
41 | if (!complete) {
42 | if (pe.isFile()) {
43 | this.complete = true;
44 | }
45 | path.add(pe);
46 | }
47 |
48 | return;
49 | }
50 |
51 | /**
52 | * Add the final or last path element. Once the last path element is set, the path is immutable
53 | * @param pe
54 | */
55 | public void addLastElement (PathElement pe) {
56 |
57 | if (! complete) {
58 | this.addPathElement(pe);
59 | this.complete = true;
60 | }
61 |
62 | return;
63 | }
64 |
65 | /**
66 | * Get an external representation of the path using the standard / path separator character. Once the final element is reached, the path is
67 | * set and returned.
68 | * @return
69 | */
70 | public String getPathAsString () {
71 | StringBuilder pathString = new StringBuilder ("/");
72 | for (PathElement pe : path) {
73 | pathString = pathString.append(pe.getPathElement());
74 | if (pe.isDirectory()) {
75 | pathString = pathString.append ("/");
76 | }
77 | }
78 | return pathString.toString();
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/src/main/java/gov/faa/ait/apra/api/DownloadServiceApp.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Federal Aviation Administration (FAA) public work
3 | *
4 | * As a work of the United States Government, this project is in the
5 | * public domain within the United States. Additionally, we waive copyright
6 | * and related rights in the work worldwide
7 | * through the Creative Commons 0 (CC0) 1.0 Universal public domain dedication
8 | *
9 | * APRA is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 | *
13 | */
14 | package gov.faa.ait.apra.api;
15 |
16 | import java.util.HashSet;
17 | import java.util.Set;
18 |
19 | import javax.ws.rs.core.Application;
20 |
21 | import org.slf4j.Logger;
22 | import org.slf4j.LoggerFactory;
23 |
24 | import io.swagger.jaxrs.config.BeanConfig;
25 |
26 | /**
27 | * This is the base application for CIFP and represents the JAX-RS application for scanning of REST services through the classes that are specified.
28 | * @author FAA
29 | *
30 | */
31 | public class DownloadServiceApp extends Application {
32 | private static final Logger logger = LoggerFactory.getLogger(DownloadServiceApp.class);
33 |
34 | public DownloadServiceApp () {
35 | BeanConfig beanConfig = new BeanConfig();
36 | beanConfig.setTitle("FAA Aeronautic Product Release API");
37 | beanConfig.setVersion("1.1.0");
38 | beanConfig.setSchemes(new String [] {"https"});
39 | beanConfig.setHost("soa.smext.faa.gov");
40 | beanConfig.setBasePath("/apra");
41 | beanConfig.setResourcePackage("io.swagger.resources");
42 | beanConfig.setLicense("US Public Domain");
43 | beanConfig.setLicenseUrl("http://www.usa.gov/publicdomain/label/1.0/");
44 | beanConfig.setScan(true);
45 | }
46 |
47 | @Override
48 | public Set> getClasses() {
49 | if (logger.isDebugEnabled())
50 | logger.debug("Resource classes being retrieved from AirportStatus jersey application.");
51 | Set> s = new HashSet <>();
52 | s.add(gov.faa.ait.apra.api.CIFP.class);
53 | s.add(gov.faa.ait.apra.api.ProductApiListener.class);
54 | s.add(io.swagger.jaxrs.listing.ApiListingResource.class);
55 | s.add(io.swagger.jaxrs.listing.SwaggerSerializers.class);
56 |
57 | //Manually adding MOXyJSONFeature
58 | s.add(org.glassfish.jersey.moxy.json.MoxyJsonFeature.class);
59 |
60 | return s;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/test/java/gov/faa/ait/apra/test/VerifyValues.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Federal Aviation Administration (FAA) public work
3 | *
4 | * As a work of the United States Government, this project is in the
5 | * public domain within the United States. Additionally, we waive copyright
6 | * and related rights in the work worldwide
7 | * through the Creative Commons 0 (CC0) 1.0 Universal public domain dedication
8 | *
9 | * APRA is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 | *
13 | */
14 | package gov.faa.ait.apra.test;
15 |
16 | import java.io.IOException;
17 | import java.net.HttpURLConnection;
18 | import java.net.InetSocketAddress;
19 | import java.net.Proxy;
20 | import java.net.URL;
21 |
22 | import org.slf4j.Logger;
23 | import org.slf4j.LoggerFactory;
24 |
25 | import gov.faa.ait.apra.bootstrap.Config;
26 |
27 | public class VerifyValues {
28 | private final static Logger logger = LoggerFactory.getLogger(VerifyValues.class);
29 | private final static String EMPTY_STRING="";
30 |
31 | private VerifyValues () { }
32 |
33 | public static boolean verifyURL (String urlString) {
34 | boolean ok = false;
35 | HttpURLConnection connection = null;
36 | Proxy proxy = null;
37 |
38 | try {
39 | URL url = new URL(urlString);
40 | if (Config.getFAADMZProxyHost() != null && (! EMPTY_STRING.equals(Config.getFAADMZProxyHost())) ) {
41 | int port = Integer.parseInt(Config.getFAADMZProxyPort());
42 | InetSocketAddress proxyAddress = new InetSocketAddress(Config.getFAADMZProxyHost(), port);
43 | proxy = new Proxy(Proxy.Type.HTTP, proxyAddress);
44 | }
45 |
46 | if (proxy != null) {
47 | connection = (HttpURLConnection) url.openConnection(proxy);
48 | }
49 | else {
50 | connection = (HttpURLConnection) url.openConnection();
51 | }
52 |
53 | connection.setRequestMethod("HEAD");
54 | int responseCode = connection.getResponseCode();
55 | if (responseCode == 200 || responseCode == 302) {
56 | ok = true;
57 | }
58 | else {
59 | logger.warn("URL HEAD check returned response code "+responseCode+" for url "+url.toExternalForm());
60 | }
61 | }
62 | catch (IOException eio) {
63 | logger.error("HEAD heck failed!", eio);
64 | logger.error(eio.getMessage());
65 | ok = false;
66 | }
67 |
68 | if (connection != null)
69 | connection.disconnect();
70 |
71 | return ok;
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/src/main/java/gov/faa/ait/apra/util/URLCache.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Federal Aviation Administration (FAA) public work
3 | *
4 | * As a work of the United States Government, this project is in the
5 | * public domain within the United States. Additionally, we waive copyright
6 | * and related rights in the work worldwide
7 | * through the Creative Commons 0 (CC0) 1.0 Universal public domain dedication
8 | *
9 | * APRA is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 | *
13 | */
14 | package gov.faa.ait.apra.util;
15 |
16 | import java.util.Date;
17 | import java.util.GregorianCalendar;
18 | import java.util.HashSet;
19 | import java.util.TimeZone;
20 |
21 | import org.slf4j.Logger;
22 | import org.slf4j.LoggerFactory;
23 |
24 | public class URLCache {
25 | private static final Logger logger = LoggerFactory.getLogger(URLCache.class);
26 | private static URLCache instance;
27 | private static HashSet cache;
28 | private static Date lastFlush;
29 |
30 | private URLCache () {
31 | flush();
32 | }
33 |
34 | public static synchronized URLCache getInstance() {
35 | if(instance == null) {
36 | instance = new URLCache();
37 | URLCache.lastFlush = new Date (System.currentTimeMillis());
38 | }
39 |
40 | if (instance.isUpdateRequired()) {
41 | URLCache.flush();
42 | }
43 | return instance;
44 | }
45 |
46 | public boolean contains (String url) {
47 | return cache.contains(url);
48 | }
49 |
50 | public static void addUrl (String url) {
51 | if (URLCache.cache == null) {
52 | URLCache.cache = new HashSet<>();
53 | }
54 |
55 | cache.add(url);
56 | }
57 |
58 | public static synchronized void flush () {
59 | logger.info("URL cache is being flushed.");
60 | if (URLCache.cache == null) {
61 | URLCache.cache = new HashSet<>();
62 | }
63 |
64 | cache.clear();
65 | URLCache.lastFlush = new Date (System.currentTimeMillis());
66 | }
67 |
68 | private boolean isUpdateRequired () {
69 |
70 | CycleDateUtil cdu = new CycleDateUtil();
71 |
72 | GregorianCalendar cycle = new GregorianCalendar(TimeZone.getDefault());
73 | GregorianCalendar lastRefresh = new GregorianCalendar(TimeZone.getDefault());
74 |
75 | lastRefresh.setTime(URLCache.lastFlush);
76 | cycle.setTime(cdu.getCurrentCycle());
77 |
78 | if (cycle.after(lastRefresh)) {
79 | logger.info("URL cache requires a refresh");
80 | return true;
81 | }
82 |
83 | return false;
84 | }
85 |
86 | }
87 |
--------------------------------------------------------------------------------
/src/main/java/gov/faa/ait/apra/path/PathElement.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Federal Aviation Administration (FAA) public work
3 | *
4 | * As a work of the United States Government, this project is in the
5 | * public domain within the United States. Additionally, we waive copyright
6 | * and related rights in the work worldwide
7 | * through the Creative Commons 0 (CC0) 1.0 Universal public domain dedication
8 | *
9 | * APRA is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 | *
13 | */
14 | package gov.faa.ait.apra.path;
15 |
16 | /**
17 | * This is a convenience class to hold the element of a URL such as a folder, directory, or file
18 | * @author FAA
19 | *
20 | */
21 | public class PathElement {
22 |
23 | private String pathName;
24 | private boolean isFile;
25 |
26 | /**
27 | * Create a default path element with a directory
28 | * @param dir
29 | */
30 | public PathElement (String dir) {
31 | this.pathName = dir;
32 | this.isFile = false;
33 | }
34 |
35 | /**
36 | * The null constructor where the path element name can be set later
37 | */
38 | public PathElement () {
39 | this.pathName = "";
40 | this.isFile = false;
41 | }
42 |
43 | /**
44 | * Get the path element name
45 | * @return the name of the path element
46 | */
47 | public String getPathElement () {
48 | return pathName;
49 | }
50 |
51 | /**
52 | * Set or reset the path element name to some string
53 | * @param pe the string name of the path element to set
54 | * @return the path element to enable chaining of sets
55 | */
56 | public PathElement setPathElement (String pe) {
57 | this.pathName = pe;
58 | return this;
59 | }
60 |
61 | /**
62 | * The file is the last part of the path element. Setting this marks the path as complete and no further additions to the path are allowed.
63 | */
64 | public void setFile() {
65 | isFile = true;
66 | }
67 |
68 | /**
69 | * Returns true if this particular path element is a file marking the end of the path
70 | * @return true if a file, false otherwise
71 | */
72 | public boolean isFile () {
73 | return isFile;
74 | }
75 |
76 | /**
77 | * Marks this path element as a directory so additional path elements can be created and added to a path
78 | */
79 | public void setDirectory () {
80 | isFile = false;
81 | }
82 |
83 | /**
84 | * Returns true if this particular path element is a directory
85 | * @return true if a directory
86 | */
87 | public boolean isDirectory() {
88 | return ! isFile;
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/src/main/java/gov/faa/ait/apra/cycle/ChartCycleElementsJson.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Federal Aviation Administration (FAA) public work
3 | *
4 | * As a work of the United States Government, this project is in the
5 | * public domain within the United States. Additionally, we waive copyright
6 | * and related rights in the work worldwide
7 | * through the Creative Commons 0 (CC0) 1.0 Universal public domain dedication
8 | *
9 | * APRA is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 | *
13 | */
14 | package gov.faa.ait.apra.cycle;
15 |
16 | import java.util.Date;
17 |
18 | public class ChartCycleElementsJson {
19 | private String chart_cycle_period_code;
20 | private String chart_cycle_type_code;
21 | private Date chart_effective_date;
22 | private String chart_cycle_number;
23 | private String query_date;
24 | private String chart_city_name;
25 |
26 | public ChartCycleElementsJson () {
27 | /*
28 | chart_cycle_period_code = "";
29 | chart_cycle_type_code = "";
30 | chart_effective_date = new Date (System.currentTimeMillis());
31 | chart_cycle_number = "";
32 | query_date = "";
33 | chart_city_name = "";
34 | */
35 | }
36 |
37 | public String getChart_cycle_period_code() {
38 | return chart_cycle_period_code;
39 | }
40 | public void setChart_cycle_period_code(String chart_cycle_period_code) {
41 | this.chart_cycle_period_code = chart_cycle_period_code;
42 | }
43 | public String getChart_cycle_type_code() {
44 | return chart_cycle_type_code;
45 | }
46 | public void setChart_cycle_type_code(String chart_cycle_type_code) {
47 | this.chart_cycle_type_code = chart_cycle_type_code;
48 | }
49 | public Date getChart_effective_date() {
50 | if (chart_effective_date == null)
51 | return new Date(System.currentTimeMillis());
52 |
53 | return new Date (chart_effective_date.getTime());
54 | }
55 | public void setChart_effective_date(Date chart_effective_date) {
56 | if (chart_effective_date == null)
57 | return;
58 |
59 | this.chart_effective_date = new Date(chart_effective_date.getTime());
60 | }
61 | public String getChart_cycle_number() {
62 | return chart_cycle_number;
63 | }
64 | public void setChart_cycle_number(String chart_cycle_number) {
65 | this.chart_cycle_number = chart_cycle_number;
66 | }
67 | public String getQuery_date() {
68 | return query_date;
69 | }
70 | public void setQuery_date(String query_date) {
71 | this.query_date = query_date;
72 | }
73 | public String getChart_city_name() {
74 | return chart_city_name;
75 | }
76 | public void setChart_city_name(String chart_city_name) {
77 | this.chart_city_name = chart_city_name;
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/src/main/java/gov/faa/ait/apra/util/TACSpecialCase.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Federal Aviation Administration (FAA) public work
3 | *
4 | * As a work of the United States Government, this project is in the
5 | * public domain within the United States. Additionally, we waive copyright
6 | * and related rights in the work worldwide
7 | * through the Creative Commons 0 (CC0) 1.0 Universal public domain dedication
8 | *
9 | * APRA is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 | *
13 | */
14 | package gov.faa.ait.apra.util;
15 |
16 | import java.util.Locale;
17 |
18 | /**
19 | * This class covers special cases of TAC files that don't conform to naming conventions such as Denver-Colorado Springs being shortened to Denver in the file name.
20 | * As naming conventions become more consistent, it is hoped that this class is deprecated and no longer required.
21 | * @author FAA
22 | *
23 | */
24 | public class TACSpecialCase {
25 |
26 | private static final int PUERTO_RICO_VI = 0;
27 | private static final int DENVER_COLORADO_SPRINGS = 1;
28 | private static final int ANCHORAGE_FAIRBANKS = 3;
29 | private static final String ZIP = ".zip";
30 |
31 | private TACSpecialCase () { }
32 |
33 | public static String getTACFileName (int specialCase, String editionNumber, String format) {
34 |
35 | if ("pdf".equalsIgnoreCase(format)) {
36 | switch (specialCase) {
37 | case DENVER_COLORADO_SPRINGS:
38 | return "Denver_TAC_"+editionNumber+"_P.pdf";
39 |
40 | case ANCHORAGE_FAIRBANKS:
41 | return "Anchorage-Fairbanks_TAC_"+editionNumber+"_P.pdf";
42 |
43 | case PUERTO_RICO_VI:
44 | return "Puerto_Rico-VI_TAC_"+editionNumber+"_P.pdf";
45 |
46 | default:
47 | break;
48 |
49 | }
50 | }
51 | else if ("tiff".equalsIgnoreCase(format)) {
52 | switch (specialCase) {
53 | case DENVER_COLORADO_SPRINGS:
54 | return "Denver_TAC_"+editionNumber+ZIP;
55 |
56 | case ANCHORAGE_FAIRBANKS:
57 | return "Anchorage-Fairbanks_TAC_"+editionNumber+ZIP;
58 |
59 | case PUERTO_RICO_VI:
60 | return "Puerto_Rico-VI_TAC_"+editionNumber+ZIP;
61 |
62 | default:
63 | break;
64 |
65 | }
66 | }
67 |
68 | return "";
69 | }
70 |
71 | public static int getSpecialCase (String geoname) {
72 |
73 | if (geoname.toLowerCase(Locale.ENGLISH).startsWith("puerto")) {
74 | return PUERTO_RICO_VI;
75 | }
76 |
77 | if (geoname.toLowerCase(Locale.ENGLISH).startsWith("denver")) {
78 | return DENVER_COLORADO_SPRINGS;
79 | }
80 |
81 | if (geoname.toLowerCase(Locale.ENGLISH).startsWith("anchorage")) {
82 | return ANCHORAGE_FAIRBANKS;
83 | }
84 |
85 | return -1;
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/src/main/java/gov/faa/ait/apra/bootstrap/TPPVolume.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Federal Aviation Administration (FAA) public work
3 | *
4 | * As a work of the United States Government, this project is in the
5 | * public domain within the United States. Additionally, we waive copyright
6 | * and related rights in the work worldwide
7 | * through the Creative Commons 0 (CC0) 1.0 Universal public domain dedication
8 | *
9 | * APRA is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 | *
13 | */
14 | package gov.faa.ait.apra.bootstrap;
15 |
16 | import java.util.ArrayList;
17 | import java.util.List;
18 |
19 | /**
20 | * This is a convenience class to hold the TPP volumes and verify membership in the volume list
21 | * @author FAA
22 | *
23 | */
24 | public class TPPVolume {
25 |
26 | // Make the list a static final so it becomes immutable and cannot be set by another class.
27 | // Items within the list can be added and removed by this class only
28 | private static final List volumes = new ArrayList <> ();
29 |
30 | // A private null constructor to protect the volume list
31 | private TPPVolume () { }
32 |
33 | static {
34 | TPPVolume.initVolumes();
35 | }
36 |
37 | /**
38 | * Get the list TPP volumes contained within the reference data set
39 | * @return a new list TPP volumes
40 | */
41 | public static List getVolumeList () {
42 | // We don't want to return our list here because it is static and we don't want someone adding
43 | // new items to the list which could cause a memory leak or other bugs.
44 | return new ArrayList <> (volumes);
45 | }
46 |
47 | private static void initVolumes () {
48 | volumes.add("NE-1");
49 | volumes.add("NE-2");
50 | volumes.add("NE-3");
51 | volumes.add("NE-4");
52 | volumes.add("SE-1");
53 | volumes.add("SE-2");
54 | volumes.add("SE-3");
55 | volumes.add("SE-4");
56 | volumes.add("SC-1");
57 | volumes.add("SC-2");
58 | volumes.add("SC-3");
59 | volumes.add("SC-4");
60 | volumes.add("SC-5");
61 | volumes.add("EC-1");
62 | volumes.add("EC-2");
63 | volumes.add("EC-3");
64 | volumes.add("NC-1");
65 | volumes.add("NC-2");
66 | volumes.add("NC-3");
67 | volumes.add("SW-1");
68 | volumes.add("SW-2");
69 | volumes.add("SW-3");
70 | volumes.add("SW-4");
71 | volumes.add("NW-1");
72 | volumes.add("AK-1");
73 | volumes.add("PC-1");
74 | }
75 | /**
76 | * Determine if a volume passed to this method is one of the valid TPP volumes
77 | * @param volumeName the name of the volume to be checked and verified
78 | * @return true if the volume is valid, false otherwise
79 | */
80 | public static boolean isValidVolumeName (String volumeName) {
81 | return TPPVolume.volumes.contains(volumeName);
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/src/main/java/gov/faa/ait/apra/json/SupplementMetadata.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Federal Aviation Administration (FAA) public work
3 | *
4 | * As a work of the United States Government, this project is in the
5 | * public domain within the United States. Additionally, we waive copyright
6 | * and related rights in the work worldwide
7 | * through the Creative Commons 0 (CC0) 1.0 Universal public domain dedication
8 | *
9 | * APRA is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 | *
13 | */
14 | package gov.faa.ait.apra.json;
15 |
16 | /**
17 | * Supplement Metadata pojo object.
18 | *
19 | */
20 |
21 | public class SupplementMetadata {
22 |
23 | protected String state;
24 | protected String aptname;
25 | protected String aptcity;
26 | protected String aptid;
27 | protected String pdf;
28 | protected String navidname;
29 | protected String chartDate;
30 | protected String volumeAbbreviation;
31 | protected String volumeName;
32 |
33 | public SupplementMetadata () {
34 | state = "";
35 | aptname = "";
36 | aptcity = "";
37 | aptid = "";
38 | pdf = "";
39 | navidname = "";
40 | chartDate = "";
41 | volumeAbbreviation = "";
42 | volumeName = "";
43 | }
44 |
45 | public String getState() {
46 | return state;
47 | }
48 |
49 | public void setState(String value) {
50 | this.state = value;
51 | }
52 |
53 | public String getAptname() {
54 | return aptname;
55 | }
56 |
57 | public void setAptname(String value) {
58 | this.aptname = value;
59 | }
60 |
61 | public String getAptcity() {
62 | return aptcity;
63 | }
64 |
65 | public void setAptcity(String value) {
66 | this.aptcity = value;
67 | }
68 |
69 | public String getAptid() {
70 | return aptid;
71 | }
72 |
73 | public void setAptid(String value) {
74 | this.aptid = value;
75 | }
76 |
77 | public String getPdf() {
78 | return pdf;
79 | }
80 |
81 | public void setPdf(String value) {
82 | this.pdf = value;
83 | }
84 |
85 | public String getNavidname() {
86 | return navidname;
87 | }
88 |
89 | public void setNavidname(String value) {
90 | this.navidname = value;
91 | }
92 |
93 | public String getChartDate() {
94 | return chartDate;
95 | }
96 |
97 | public void setChartDate(String value) {
98 | this.chartDate = value;
99 | }
100 |
101 | public String getVolumeAbbreviation() {
102 | return volumeAbbreviation;
103 | }
104 |
105 | public void setVolumeAbbreviation(String value) {
106 | this.volumeAbbreviation = value;
107 | }
108 |
109 | public String getVolumeName() {
110 | return volumeName;
111 | }
112 |
113 | public void setVolumeName(String value) {
114 | this.volumeName = value;
115 | }
116 |
117 | }
118 |
--------------------------------------------------------------------------------
/src/test/java/gov/faa/ait/apra/test/SectionalChartTableTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Federal Aviation Administration (FAA) public work
3 | *
4 | * As a work of the United States Government, this project is in the
5 | * public domain within the United States. Additionally, we waive copyright
6 | * and related rights in the work worldwide
7 | * through the Creative Commons 0 (CC0) 1.0 Universal public domain dedication
8 | *
9 | * APRA is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 | *
13 | */
14 | package gov.faa.ait.apra.test;
15 |
16 | import static org.junit.Assert.assertTrue;
17 |
18 | import java.text.ParseException;
19 | import java.text.SimpleDateFormat;
20 |
21 | import org.junit.Test;
22 |
23 | import gov.faa.ait.apra.cycle.ChartCycleElementsJson;
24 | import gov.faa.ait.apra.cycle.ChartCycleData;
25 | import gov.faa.ait.apra.util.ChartInfoTable;
26 | import gov.faa.ait.apra.util.ChartInfoTableKey;
27 |
28 | public class SectionalChartTableTest {
29 |
30 | // @Test
31 | // public void testLoad() {
32 | // SectionalChartCycleJson jsonData = buildJson();
33 | // SectionalChartTable table = new SectionalChartTable(jsonData);
34 | // fail("Not yet implemented");
35 | // }
36 |
37 | @Test
38 | public void testContainsKey() throws ParseException {
39 | ChartCycleData jsonData = buildJson();
40 | ChartInfoTable table = new ChartInfoTable(jsonData);
41 | ChartInfoTableKey key = new ChartInfoTableKey("ALBUQUERQUE", "CURRENT", "SECTIONAL");
42 | assertTrue("Expected Key not found", table.containsKey(key));
43 | ChartInfoTableKey key2 = new ChartInfoTableKey("ALBUQUERQUE", "NEXT", "SECTIONAL");
44 | assertTrue("Expected Key not found", table.containsKey(key2));
45 |
46 | }
47 |
48 | private ChartCycleData buildJson() throws ParseException {
49 | ChartCycleData cc = new ChartCycleData();
50 | //SimpleDateFormat sdfUS = new SimpleDateFormat("MM/dd/yyyy");
51 | cc.setName("SECTIONAL");
52 | ChartCycleElementsJson element = buildElement("Albuquerque", "current", "Sectional");
53 | ChartCycleElementsJson[] elemArray = new ChartCycleElementsJson[2];
54 | elemArray[0] = element;
55 | ChartCycleElementsJson element2 = buildElement("Albuquerque", "next", "Sectional");
56 | elemArray[1] = element2;
57 | cc.setElements(elemArray);
58 | return cc;
59 | }
60 |
61 | private ChartCycleElementsJson buildElement(String city, String period, String type) throws ParseException {
62 | SimpleDateFormat sdfISO = new SimpleDateFormat("yyyy-dd-MM");
63 | ChartCycleElementsJson element = new ChartCycleElementsJson();
64 | element.setChart_city_name(city);
65 | element.setChart_cycle_number("97");
66 | element.setChart_cycle_period_code(period);
67 | element.setChart_cycle_type_code(type);
68 | element.setChart_effective_date(sdfISO.parse("2016-04-28"));
69 | element.setQuery_date("2016-06-16");
70 | return element;
71 | }
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/src/test/java/gov/faa/ait/apra/test/DERSTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Federal Aviation Administration (FAA) public work
3 | *
4 | * As a work of the United States Government, this project is in the
5 | * public domain within the United States. Additionally, we waive copyright
6 | * and related rights in the work worldwide
7 | * through the Creative Commons 0 (CC0) 1.0 Universal public domain dedication
8 | *
9 | * APRA is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 | *
13 | */
14 | package gov.faa.ait.apra.test;
15 |
16 | import static org.junit.Assert.assertEquals;
17 | import static org.junit.Assert.assertTrue;
18 | import static org.junit.Assert.fail;
19 |
20 | import javax.ws.rs.core.Response;
21 |
22 | import org.junit.Test;
23 | import org.slf4j.Logger;
24 | import org.slf4j.LoggerFactory;
25 |
26 | import gov.faa.ait.apra.api.DigitalEnrouteSupplementCharts;
27 | import gov.faa.ait.apra.cycle.ChartCycleClient;
28 | import gov.faa.ait.apra.jaxb.ProductSet;
29 |
30 | public class DERSTest {
31 | private DigitalEnrouteSupplementCharts ders;
32 | private static final Logger logger = LoggerFactory.getLogger(DERSTest.class);
33 |
34 | public DERSTest () {
35 | ChartCycleClient client = new ChartCycleClient();
36 | client.forceUpdate();
37 | }
38 |
39 | @Test
40 | public void testCurrentRelease() {
41 | ders = new DigitalEnrouteSupplementCharts();
42 | Response ps = ders.getDERSRelease("current");
43 | int code = ps.getStatus();
44 | assertEquals(404, code);
45 | }
46 |
47 | @Test
48 | public void testNextRelease() {
49 | ders = new DigitalEnrouteSupplementCharts();
50 | Response ps = ders.getDERSRelease("next");
51 | int code = ps.getStatus();
52 |
53 | // Have to allow for either a positive response or a not found due to the AJV release cycle. A "next" edition may
54 | // only be published 20 days in advance. Therefore, there is a time period when we may ask for "next", but it really hasn't
55 | // been put on the web site yet
56 | if (! (code == 200 || code == 404) ) {
57 | fail();
58 | }
59 | }
60 |
61 | @Test
62 | public void testCurrentEdition() {
63 | ders = new DigitalEnrouteSupplementCharts();
64 | Response ps = ders.getDERSEdition("current");
65 | int code = ps.getStatus();
66 | assertEquals(404, code);
67 | }
68 |
69 | @Test
70 | public void testNextEdition() {
71 | ders = new DigitalEnrouteSupplementCharts();
72 | Response ps = ders.getDERSEdition("next");
73 | int code = ps.getStatus();
74 | assertEquals(404, code);
75 | }
76 |
77 | @Test
78 | public void testBadRelease() {
79 | ders = new DigitalEnrouteSupplementCharts();
80 | Response ps = ders.getDERSRelease("bad");
81 | int code = ps.getStatus();
82 | assertEquals(404, code);
83 | }
84 |
85 | @Test
86 | public void testBadEdition() {
87 | ders = new DigitalEnrouteSupplementCharts();
88 | Response ps = ders.getDERSRelease("bad");
89 | int code = ps.getStatus();
90 | assertEquals(404, code);
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/src/main/webapp/WEB-INF/web.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 | gov.faa.ait.apra.api.DownloadServiceApp
7 |
8 | org.glassfish.jersey.servlet.ServletContainer
9 |
10 | javax.ws.rs.Application
11 | gov.faa.ait.apra.api.DownloadServiceApp
12 |
13 |
14 | jersey.config.server.provider.packages
15 | io.swagger.jaxrs.listing, gov.faa.ait.apra.api
16 |
17 |
18 | com.sun.jersey.config.feature.Debug
19 | true
20 |
21 |
35 | 1
36 |
37 |
38 |
39 | gov.faa.ait.apra.api.DownloadServiceApp
40 | /*
41 |
42 |
43 |
44 | DefaultJaxrsConfig
45 | io.swagger.jaxrs.config.DefaultJaxrsConfig
46 |
47 | api.version
48 | 2.0.0
49 |
50 |
51 | swagger.api.title
52 | Aeronautic Product Release API
53 |
54 |
55 | swagger.api.basepath
56 | https://soa.smext.faa.gov/apra
57 |
58 | 2
59 |
60 |
61 |
62 | APRA Security
63 |
64 | APRAInfo
65 | /foo/*
66 | GET
67 |
68 |
69 | *
70 |
71 |
72 | NONE
73 |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/src/test/java/gov/faa/ait/apra/test/NASRTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Federal Aviation Administration (FAA) public work
3 | *
4 | * As a work of the United States Government, this project is in the
5 | * public domain within the United States. Additionally, we waive copyright
6 | * and related rights in the work worldwide
7 | * through the Creative Commons 0 (CC0) 1.0 Universal public domain dedication
8 | *
9 | * APRA is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 | *
13 | */
14 | package gov.faa.ait.apra.test;
15 |
16 | import static org.junit.Assert.assertEquals;
17 | import static org.junit.Assert.assertTrue;
18 |
19 | import org.junit.Test;
20 | import org.slf4j.Logger;
21 | import org.slf4j.LoggerFactory;
22 |
23 | import gov.faa.ait.apra.api.NASRSubscription;
24 | import gov.faa.ait.apra.jaxb.ProductSet;
25 |
26 | public class NASRTest {
27 | private final static Logger logger = LoggerFactory.getLogger(NASRTest.class);
28 |
29 | @Test
30 | public void testDefaults() {
31 | NASRSubscription nasr = new NASRSubscription();
32 | ProductSet ps = (ProductSet) nasr.getNASRSubscription(null).getEntity();
33 | logger.info("NASR default test return url of "+ps.getEdition().get(0).getProduct().getUrl());
34 | int code = ps.getStatus().getCode().intValue();
35 | assertEquals(200, code);
36 | }
37 |
38 | @Test
39 | public void testCurrentRelease() {
40 | NASRSubscription nasr = new NASRSubscription();
41 | ProductSet ps = (ProductSet) nasr.getNASRSubscription("current").getEntity();
42 | logger.info("NASR default test return url of "+ps.getEdition().get(0).getProduct().getUrl());
43 | int code = ps.getStatus().getCode().intValue();
44 | assertEquals(200, code);
45 | }
46 |
47 | @Test
48 | public void testNextRelease() {
49 | NASRSubscription nasr = new NASRSubscription();
50 | ProductSet ps = (ProductSet) nasr.getNASRSubscription("next").getEntity();
51 | logger.info("NASR default test return url of "+ps.getEdition().get(0).getProduct().getUrl());
52 | }
53 |
54 | @Test
55 | public void testDefaultEdition() {
56 | NASRSubscription nasr = new NASRSubscription();
57 | ProductSet ps = (ProductSet) nasr.getNASREdition(null).getEntity();
58 | int code = ps.getStatus().getCode().intValue();
59 | assertEquals(200, code);
60 | }
61 |
62 | @Test
63 | public void testCurrentEdition() {
64 | NASRSubscription nasr = new NASRSubscription();
65 | ProductSet ps = (ProductSet) nasr.getNASREdition("current").getEntity();
66 | int code = ps.getStatus().getCode().intValue();
67 | assertEquals(200, code);
68 | }
69 |
70 | @Test
71 | public void testNextEdition() {
72 | NASRSubscription nasr = new NASRSubscription();
73 | ProductSet ps = (ProductSet) nasr.getNASRSubscription("next").getEntity();
74 | int code = ps.getStatus().getCode().intValue();
75 | assertEquals(200, code);
76 | }
77 |
78 | @Test
79 | public void testInvalidEdition() {
80 | NASRSubscription nasr = new NASRSubscription();
81 | ProductSet ps = (ProductSet) nasr.getNASRSubscription("Invalid").getEntity();
82 | int code = ps.getStatus().getCode().intValue();
83 | assertEquals(400, code);
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/src/main/java/gov/faa/ait/apra/api/ProductApiListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Federal Aviation Administration (FAA) public work
3 | *
4 | * As a work of the United States Government, this project is in the
5 | * public domain within the United States. Additionally, we waive copyright
6 | * and related rights in the work worldwide
7 | * through the Creative Commons 0 (CC0) 1.0 Universal public domain dedication
8 | *
9 | * APRA is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 | *
13 | */
14 | package gov.faa.ait.apra.api;
15 |
16 | import org.glassfish.jersey.server.monitoring.ApplicationEvent;
17 | import org.glassfish.jersey.server.monitoring.ApplicationEventListener;
18 | import org.glassfish.jersey.server.monitoring.RequestEvent;
19 | import org.glassfish.jersey.server.monitoring.RequestEventListener;
20 | import org.apache.logging.log4j.ThreadContext;
21 | import org.slf4j.Logger;
22 | import org.slf4j.LoggerFactory;
23 |
24 | /**
25 | * A product api listener class for all JAX-RS events
26 | * @author FAA
27 | *
28 | */
29 | public class ProductApiListener implements ApplicationEventListener {
30 | private static final Logger logger = LoggerFactory.getLogger(ProductApiListener.class);
31 | private volatile int requestCount = 0;
32 | @Override
33 | public void onEvent (ApplicationEvent appEvent) {
34 | switch (appEvent.getType()) {
35 | case INITIALIZATION_FINISHED:
36 | logger.info("FAA aeronautical product release API (APRA) started. Ready to service requests.");
37 | break;
38 | default:
39 | break;
40 | }
41 | }
42 |
43 | @Override
44 | public RequestEventListener onRequest (RequestEvent requestEvent) {
45 | requestCount++;
46 | return new ProductApiEventListener(requestCount);
47 | }
48 |
49 | /**
50 | * The API event listener for APRA. Current events which are captured and processed are the RESOURCE_START_METHOD and FINISHED events
51 | * @author Martin Hile
52 | *
53 | */
54 | public static class ProductApiEventListener implements RequestEventListener {
55 |
56 | private final int requestNumber;
57 | private final long startTime;
58 | private static final Logger logger = LoggerFactory.getLogger(ProductApiListener.class);
59 |
60 | /**
61 | * This event listener records the time spent processing a request to APRA
62 | * @param requestNumber the number of the request which is output to the log file. Incremented by 1 for each request processed
63 | */
64 | public ProductApiEventListener (int requestNumber) {
65 | this.requestNumber = requestNumber;
66 | this.startTime = System.currentTimeMillis();
67 | }
68 |
69 | @Override
70 | public void onEvent (RequestEvent event) {
71 | switch (event.getType()) {
72 | case RESOURCE_METHOD_START:
73 | // Output the start of a resource event so we get a request number logged
74 | ThreadContext.put("ID", "APRA-"+Integer.toString(requestNumber));
75 | logger.info("Resource method "+event.getUriInfo().getMatchedResourceMethod().getHttpMethod()+" started for request "+requestNumber);
76 | break;
77 | case FINISHED:
78 | // Mark the finish of the processing with the duration spent fulfilling the request. Useful for debugging performance problems.
79 | logger.info("Request "+requestNumber+" finished. Processing time "+ (System.currentTimeMillis() - startTime) + " ms.");
80 | ThreadContext.clearAll();
81 | break;
82 | default:
83 | break;
84 | }
85 | }
86 |
87 | }
88 |
89 | }
90 |
--------------------------------------------------------------------------------
/src/test/java/gov/faa/ait/apra/test/ChartCycleTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Federal Aviation Administration (FAA) public work
3 | *
4 | * As a work of the United States Government, this project is in the
5 | * public domain within the United States. Additionally, we waive copyright
6 | * and related rights in the work worldwide
7 | * through the Creative Commons 0 (CC0) 1.0 Universal public domain dedication
8 | *
9 | * APRA is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 | *
13 | */
14 | package gov.faa.ait.apra.test;
15 |
16 | import static org.junit.Assert.assertEquals;
17 | import static org.junit.Assert.assertNotNull;
18 |
19 | import java.text.ParseException;
20 | import java.text.SimpleDateFormat;
21 | import java.util.Arrays;
22 | import java.util.Date;
23 | import java.util.List;
24 |
25 | import org.junit.Before;
26 | import org.junit.Test;
27 | import org.junit.runner.RunWith;
28 | import org.junit.runners.Parameterized;
29 |
30 | import gov.faa.ait.apra.cycle.ChartCycleClient;
31 | import gov.faa.ait.apra.cycle.ChartCycleElementsJson;
32 |
33 | @RunWith(Parameterized.class)
34 | public class ChartCycleTest {
35 | private Date checkDate;
36 | private Integer expectedCycle;
37 | private ChartCycleClient client;
38 |
39 | public ChartCycleTest (Date date, Integer cycle) {
40 | this.checkDate = new Date(date.getTime());
41 | this.expectedCycle = cycle;
42 | }
43 |
44 | @Before
45 | public void initialize() {
46 | client = new ChartCycleClient();
47 | }
48 |
49 | @Parameterized.Parameters
50 | public static List