Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherrypicking #364

Open
wants to merge 51 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
e712a34
defaulting target file name of bundle upload
sheldonabrown May 5, 2024
3030583
adding config option to bypass push to cloudwatch
sheldonabrown May 9, 2024
a04108e
BUSETA-33 cleanup of bundle building
sheldonabrown May 14, 2024
5a31f44
minor fix on BUSETA-33
sheldonabrown May 14, 2024
bce96a3
trying multi-threaded bundle build again
sheldonabrown May 14, 2024
da01828
BUSETA-33 improvements to bundle deploy tab
sheldonabrown May 16, 2024
29ac4c2
quieting hibernate logging
sheldonabrown May 17, 2024
77511fd
debugging staging request
sheldonabrown May 17, 2024
2483d95
bug with staging a bundle
sheldonabrown May 17, 2024
41562f7
adding some comments
sheldonabrown May 17, 2024
f43dad8
refactor of bundle javascript
sheldonabrown May 18, 2024
6caca72
refactor of init portion of bundle
sheldonabrown May 19, 2024
e17dff3
Cleanup up bundle build upload
sheldonabrown May 20, 2024
6474606
Cleanup up bundle file upload and staging
sheldonabrown May 20, 2024
9964cd7
fixing license headers.
sheldonabrown May 20, 2024
c9956ab
missing import fix
sheldonabrown May 20, 2024
a076ec3
fixing file upload, needs to be synchronous
sheldonabrown May 21, 2024
d943049
bug fix on deploy delete
sheldonabrown May 21, 2024
007f3fa
giving hint to unused tabs
sheldonabrown May 22, 2024
f79f795
adding link to mobility data validator
sheldonabrown May 22, 2024
320a3b4
adding color for status of deploy bundle
sheldonabrown May 22, 2024
88b5e3a
cleanup from last commit
sheldonabrown May 22, 2024
06e97b1
remove old text message
sheldonabrown May 22, 2024
a2363ac
sorting deployed bundles
sheldonabrown May 23, 2024
db22d98
removing unused div
sheldonabrown May 23, 2024
3f720ee
adding inUse column to existing dataset
sheldonabrown May 23, 2024
78eecc9
removing unused element
sheldonabrown May 23, 2024
c25f90c
putting back deploy message wrongfully removed
sheldonabrown May 23, 2024
678b649
improving time support for ArrivalsAndDeparturesForLocationAction
sheldonabrown May 23, 2024
b415d73
configurable protocol for nextbus api configUtil
sheldonabrown Jun 7, 2024
b60e784
MOTP-2144 fuzzy matching of short trip real-time to long-trip schedule
sheldonabrown Jun 11, 2024
d7cd777
more fuzzy matching for MOTP-2144
sheldonabrown Jun 12, 2024
f13601e
service date logic for MOTP-2144
sheldonabrown Jun 13, 2024
5aded4e
handling empty results better for MOTP-2144
sheldonabrown Jun 13, 2024
ef1f84e
cleanup up support for realtime and schedule tripid regexes / MOTP-2144
sheldonabrown Jun 13, 2024
94c6757
is_assigned fix for MTA-148
sheldonabrown Jun 27, 2024
42fab6a
MTA-151 back out last stop checks on pattern changes
sheldonabrown Jun 28, 2024
c514379
Fixing BlockFinder refresh
sheldonabrown Jul 1, 2024
cd5808b
BUSETA-72 support alternative prediction API
sheldonabrown Jul 2, 2024
025f509
[BUSETA-63] Upgrade jquery to 1.9, add jquery-migrate-1.4.1 plugin te…
AlexAndradeCS Jul 3, 2024
998d5fb
MTA-152 fix fuzzy matching after bundle swap
sheldonabrown Jul 3, 2024
2ee2a23
test fixes
sheldonabrown Jul 9, 2024
f63213c
bug fix on applying predictions. Spotted from BUSETA-74
sheldonabrown Jul 9, 2024
e6f8ef0
[BUSETA-63] Upgrade jquery to 1.12.4, remove browser sniffing and rep…
AlexAndradeCS Jul 10, 2024
9ac125c
BUSETA-72 bug fix
sheldonabrown Jul 10, 2024
828b692
[BUSETA-63] Upgrade jquery to 3.7.1 and jquery-ui to 1.13.3
AlexAndradeCS Jul 11, 2024
fcbe66b
BUSETA-76 impl and BUSETA-72 bug fix
sheldonabrown Jul 12, 2024
b768673
another BUSETA-72 bug fix
sheldonabrown Jul 12, 2024
e644f81
BUSETA-77 increase desktop web polling interval
sheldonabrown Jul 12, 2024
093c4dc
Hopefully fix broken tests
aaronbrethorst Jul 14, 2024
c1baef7
Updates GH Actions versions to fix CI issue
aaronbrethorst Jul 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'
Expand Down
5 changes: 5 additions & 0 deletions onebusaway-admin-webapp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@
<artifactId>jersey-spring5</artifactId>
<version>2.31</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
<version>2.31</version>
</dependency>

<!-- this is for struts 2.5 on java 11 -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@ public interface BundleDeployerService {

public Response deploy(String environment);

public Response deployName(String name);

public Response deployStatus(String id);

public Response getBundleFile(String bundleId, String relativeFilename);

public Response getBundleList();

public Response delete(String name);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Copyright (C) 2024 Cambridge Systematics, Inc.
*
* 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 org.onebusaway.admin.service;

import javax.ws.rs.core.Response;
import java.io.InputStream;

public interface BundleUploadService {
Response register(String agencyId, String bundleDir, String uploadType, String uploadUrl);
Response accept(String agencyId, String bundleDir, String uploadType, InputStream agencySourceFile);
Response query(String agencyId, String bundleDir);
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@

import org.onebusaway.transit_data_federation.bundle.model.BundleStatus;

import javax.ws.rs.core.Response;


public interface BundleDeployer {
void setup();
void deploy(BundleStatus status, String path);
void deploy(BundleStatus status, String path, String nameFilter);
List<String> listStagedBundles(String path);
Response delete(String name);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,25 @@
package org.onebusaway.admin.service.bundle.api;

import javax.servlet.ServletContext;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.onebusaway.admin.service.BundleArchiverService;
import org.onebusaway.admin.service.BundleDeployerService;
import org.onebusaway.admin.service.BundleStagerService;
import org.onebusaway.admin.service.RemoteConnectionService;
import org.onebusaway.util.services.configuration.ConfigurationServiceClient;
import org.onebusaway.admin.service.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.web.context.ServletContextAware;

import java.io.InputStream;

@Path("/bundle")
@Component
public class BundleResource extends AuthenticatedResource implements ServletContextAware{
Expand All @@ -52,6 +54,8 @@ public class BundleResource extends AuthenticatedResource implements ServletCont
@Autowired
@Qualifier("tdmRemoteBundleDeployerImpl")
private BundleDeployerService _tdmBundleDeployer;
@Autowired
private BundleUploadService _uploadService;

private String tdmURL;

Expand All @@ -68,23 +72,12 @@ public Response stage(@PathParam("environment")
String environment, @PathParam("bundleDir")
String bundleDir, @PathParam("bundleName")
String bundleName) {
// TODO this should follow the deployer pattern with an async response
// object
if (!isAuthorized()) {
return Response.noContent().build();
}


_log.info("stage request env={} dir={} bundle-{}", environment, bundleDir, bundleName);
return _localBundleStager.stage(environment, bundleDir, bundleName);

/*String json = "{ERROR}";
try {
_bundleStager.stage(environment, bundleDir, bundleName);
_bundleStager.notifyOTP(bundleName);
json = "{SUCCESS}";
} catch (Exception any) {
_log.error("stage failed:", any);
}
return Response.ok(json).build();*/
}

@Path("/stage/status/{id}/list")
Expand Down Expand Up @@ -195,6 +188,34 @@ public Response deploy(@PathParam("environment")
}
return _localBundleDeployer.deploy(environment);
}

@Path("/deploy/name/{name}")
@GET
public Response deployNamedBundle(@PathParam("name")
String name) {
if (!isAuthorized()) {
return Response.noContent().build();
}

if(isTdm()){
return Response.noContent().build();
}
return _localBundleDeployer.deployName(name);
}

@Path("/deploy/delete/{name}")
@GET
public Response deployDelete(@PathParam("name")
String name) {
if (!isAuthorized()) {
return Response.noContent().build();
}
if (isTdm()) {
// not supported
return Response.noContent().build();
}
return _localBundleDeployer.delete(name);
}

@Path("/deploy/status/{id}/list")
@GET
Expand Down Expand Up @@ -227,8 +248,32 @@ public Response getBundleFile(@PathParam("bundleId") String bundleId,
}
return _localBundleDeployer.getBundleFile(bundleId, relativeFilename);
}



@Path("/upload/register/{agencyId}/{bundleDir}/{uploadType}")
@POST
public Response doUploadAsync(@PathParam("agencyId") String agencyId,
@PathParam("bundleDir") String bundleDir,
@PathParam("uploadType") String uploadType,
@FormParam("url") String uploadUrl) {
return _uploadService.register(agencyId, bundleDir, uploadType, uploadUrl);
}

@Path("/upload/accept/{agencyId}/{bundleDir}/{uploadType}")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@POST
public Response doAccept(@PathParam("agencyId") String agencyId,
@PathParam("bundleDir") String bundleDir,
@PathParam("uploadType") String uploadType,
InputStream agencySourceFile) {
return _uploadService.accept(agencyId, bundleDir, uploadType, agencySourceFile);
}

@Path("/upload/status/{agencyId}/{bundleDir}")
@GET
public Response query(@PathParam("agencyId") String agencyId,
@PathParam("bundleDir") String bundleDir) {
return _uploadService.query(agencyId, bundleDir);
}
private boolean isTdm() {
if (isTdm != null)
return isTdm;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
import java.util.List;

import javax.annotation.PostConstruct;
import javax.ws.rs.core.Response;

import org.apache.commons.io.FileUtils;
import org.onebusaway.transit_data_federation.bundle.model.BundleStatus;
import org.onebusaway.admin.service.bundle.BundleDeployer;
import org.onebusaway.admin.util.NYCFileUtils;
Expand All @@ -38,6 +40,7 @@ public class DirectoryBundleDeployerImpl implements BundleDeployer {
private FileUtility _fileUtil;
private NYCFileUtils _nycFileUtils;
private String _deployBundleDirectory;
private boolean _cleanupDeployEnabled = false;

public void setDeployBundleDirectory(String localBundlePath) {
_deployBundleDirectory = localBundlePath;
Expand All @@ -58,7 +61,32 @@ public List<String> listStagedBundles(String path) {
}
return bundleFiles;
}


@Override
/**
* Delete a single deployed bundle from the deploy directory
* @param name
* @return
*/
public Response delete(String name) {
String path = this._deployBundleDirectory + File.separator;
String bundleDir = path + name;
File dirToDelete = new File(bundleDir);
if (!dirToDelete.exists() || !dirToDelete.isDirectory()) {
_log.error("bad request to delete deploy dir {}", bundleDir);
return Response.serverError().build();
}
try {
FileUtils.deleteDirectory(dirToDelete);
return Response.ok().build();
} catch (Exception e) {
_log.error("exception deleting name {}:", name, e, e);
}
return Response.serverError().build();

}


private List<String> listFiles(String directory, int maxResults){
File bundleDir = new File(directory);
int fileCount = 1;
Expand Down Expand Up @@ -90,23 +118,30 @@ private List<String> listFiles(String directory, int maxResults){
* Copy the bundle from Staging to the Admin Server's bundle serving location, and arrange
* as necessary.
*/
private int deployBundleForServing(BundleStatus status, String path) throws Exception{
private int deployBundleForServing(BundleStatus status, String path, String nameFilter) throws Exception{
_log.info("deployBundleForServing(" + path + ")");

int bundlesDownloaded = 0;
// list bundles at given path
List<String> bundles = listFiles(path, MAX_RESULTS);

if (bundles != null && !bundles.isEmpty()) {
clearBundleDeployDirectory();
if (_cleanupDeployEnabled) {
clearBundleDeployDirectory();
}
} else {
_log.error("no bundles found at path=" + path);
return bundlesDownloaded;
}

for (String bundle : bundles) {
String bundleFilename = _nycFileUtils.parseFileName(bundle, File.separator);
// retreive bundle and add it to the list of bundles
if (nameFilter != null && !nameFilter.equals(bundleFilename)) {
// filter specified, only deploy if it matches
continue;
}

// retrieve bundle and add it to the list of bundles
try{
_log.info("getting bundle = " + bundle);
get(bundle, _deployBundleDirectory);
Expand Down Expand Up @@ -158,10 +193,10 @@ public String get(String bundlePath, String destinationDirectory) throws Excepti
/**
* Transfer bundles from staging directory to active bundles directory for serving
*/
public void deploy(BundleStatus status, String path) {
public void deploy(BundleStatus status, String path, String nameFilter) {
try {
status.setStatus(BundleStatus.STATUS_STARTED);
deployBundleForServing(status, path);
deployBundleForServing(status, path, nameFilter);
status.setStatus(BundleStatus.STATUS_COMPLETE);
} catch (Exception e) {
status.setStatus(BundleStatus.STATUS_ERROR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class DirectoryBundleStagerImpl implements BundleStager {

private String _builtBundleDirectory;
private String _stagingDirectory;
private boolean _cleanupStagingEnabled = true;

private FileUtility _fileUtil;

Expand Down Expand Up @@ -80,13 +81,14 @@ private void stageBundle(BundleStatus status, String environment, String bundleD
File srcFile = new File(srcDir, bundleName + ".tar.gz");
File destDir = new File(this.getStagedBundleDirectory());
_log.info("deleting " + destDir);
// cleanup from past run
try {
FileUtils.deleteDirectory(destDir);
} catch (Exception any) {
_log.error("deleteDir failed with :", any);
if (_cleanupStagingEnabled) {
// cleanup from past run
try {
FileUtils.deleteDirectory(destDir);
} catch (Exception any) {
_log.error("deleteDir failed with :", any);
}
}

try{
_log.info("making directory" + destDir);
destDir.mkdir();
Expand Down
Loading
Loading