Skip to content

Commit

Permalink
URI Encoding, Filename Adjustment (#561)
Browse files Browse the repository at this point in the history
* [DPO3DPKRT-746] fix/large file upload failure (#543)
- switched to streaming approach for file uploads
- removed body size check for Nginx to remove filesize cap when uploading
- added 'Name' to WorkflowReport to assist with identification and file generation
- change 'Name' property of WorkflowReport to standard varchar(512)
- updated GLTF dependencies to v2.5.1 (current: 3.5.1)

* DPO3DPKRT-760/new edan publishing api (#549)
- EDAN has new endpoints that need to be reflected deprecating previous configurations.
new: https://console.si.edu/apis/3d-api-dev/api/v1.0/admin/upsertResource

Note: all developers need to update their environment variables and
related scripts (e.g. env.DEV.bat) to point to the new EDAN server.

    PACKRAT_EDAN_3D_API = https://console.si.edu/apis/3d-api-dev/

Additionally, if doing development against EDAN update the dev
environment variables for the EDAN server.

    PACKRAT_EDAN_SERVER = https://edandev.si.edu/

* Fixes DPO3DPKRT-764 allowing for easier local Proxy operation
- updated nginx-dev.conf to avoid CORS conflicts in modern browsers when running locally in proxy mode.

* Temporarily bypass Generate Downloads while development wraps up
- Stakeholders require publishing capability but an issue with the
generate downloads process pollutes the system with duplicates. this
temporary fix is only for while that development is wrapped up (active)

* DPO3DPKRT-768/Update LDAP Environment Vars (#554)
- LDAP/LDAPS endpoints have been updated to better enforce compliance and correct configurations. All environment variables (.env.dev, .env.prod, etc.) need to be updated to use the new endpoint/port for authentication against ActiveDirectory to work. No code has been committed as the environment files sit outside of source control.

PACKRAT_LDAP_SERVER=ldap://si-hdc-usdc01.US.SINET.SI.EDU:389

Note: that this will need to be updated further as the port (389) is not their preferred port (636), but that is currently not working as expected and will require deeper configuration and testing.

* DPO3DPKRT-767/Support Multiple Cook Resources (#555)
- 'resources/cook' endpoint for getting best fit for job type. looks
at stored support for a specific job type, how many jobs are waiting,
and how many jobs are running. include 'job' query param. accepted
values: inspect, scene_generation, generate_downloads, photogrammetry.

Note: developers will need to add the new tables to their local db. Refer to Packrat.ALTER.sql

* DPO3DPKRT-770/URI Encoding and Filename Cleanup
- improved name sanitizing for ingest titles to avoid conflicts with
other systems (e.g. Voyager, Cook, etc.). replaces all special
characters with '-' except for -, _, and .
- proper use of encodeURI vs. encodeURIComponent for Voyager references
  • Loading branch information
EMaslowskiQ authored Dec 13, 2023
1 parent 12b9b02 commit eb9c381
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function VoyagerExplorer(props: VoyagerExplorerProps): React.ReactElement {
// this is the script required to run voyager-explorer component
useScript(Config.voyager.explorerJS);

return <voyager-explorer id='Voyager-Explorer' root={root} document={document} style={{ width: width || '300px', height: height || '300px', display: 'block', position: 'relative' }} />;
return <voyager-explorer id='Voyager-Explorer' root={root} document={encodeURIComponent(document)} style={{ width: width || '300px', height: height || '300px', display: 'block', position: 'relative' }} />;
}

export default VoyagerExplorer;
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function VoyagerStory(props: VoyagerStoryProps): React.ReactElement {
<voyager-story
id='Voyager-Story'
root={root}
document={document}
document={encodeURIComponent(document)}
mode={mode}
style={{ width: width || '300px', height: height || '300px', display: 'block', position: 'relative' }}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function DetailsThumbnail(props: DetailsThumbnailProps): React.ReactElement {
return;

const { data: { getVoyagerParams: { path, document, idSystemObjectScene } } } = await getVoyagerParams(idSystemObject);
// console.log(`getVoyagerParams path: ${path}, document: ${document}, idSystemObjectScene ${idSystemObjectScene}`);
// console.log(`getVoyagerParams (path: ${path}, document: ${document}, idSystemObjectScene ${idSystemObjectScene})`);

if (document) {
const root: string = getRootSceneDownloadUrlForVoyager(serverEndpoint, idSystemObjectScene, path, eMode);
Expand Down Expand Up @@ -95,7 +95,7 @@ function DetailsThumbnail(props: DetailsThumbnailProps): React.ReactElement {
variant='contained'
color='primary'
disableElevation
href={getVoyagerStoryUrl(serverEndpoint, idSystemObject ?? 0, documentLink, pathLink, eVoyagerStoryMode.eEdit)}
href={getVoyagerStoryUrl(serverEndpoint, idSystemObject ?? 0, encodeURIComponent(documentLink), pathLink, eVoyagerStoryMode.eEdit)}
target='_blank'
rel='noopener noreferrer'
>
Expand Down
9 changes: 6 additions & 3 deletions client/src/utils/repository.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -341,18 +341,21 @@ export function getRootSceneDownloadUrlForVoyager(serverEndPoint: string | undef
case eVoyagerStoryMode.eAuthor: dlPath='webdav'; break;
case eVoyagerStoryMode.eExpert: dlPath='webdav'; break;
}
return `${serverEndPoint}/${dlPath}/idSystemObject-${idSystemObject}/${path ? path + '/' : ''}`;
const uri: string = `${serverEndPoint}/${dlPath}/idSystemObject-${idSystemObject}/${path ? path + '/' : ''}`;
// console.log(`>>> getVoyagerStoryURL (document: ${document} | dlPath: ${dlPath} | uri: ${uri} | path: ${path})`);
return uri;
}

export function getVoyagerStoryUrl(serverEndPoint: string | undefined, idSystemObject: number,
document: string, path: string, eMode?: eVoyagerStoryMode | undefined): string {

const mode: string = getModeForVoyager(eMode);
const root: string = getRootSceneDownloadUrlForVoyager(serverEndPoint, idSystemObject, path, eMode);
return `/repository/voyager/${idSystemObject}?mode=${mode}&root=${root}&document=${document}`;
const uri: string = `/repository/voyager/${idSystemObject}?mode=${mode}&root=${root}&document=${document}`;
// console.log(`>>> getVoyagerStoryURL (document: ${document} | root: ${root} | uri: ${uri} | path: ${path})`);
return uri;
}


// prettier-ignore
export function getTreeViewStyleHeight(isExpanded: boolean, isModal: boolean, breakpoint: Breakpoint): string {
const isSmallScreen: boolean = breakpoint === 'lg';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import * as DBAPI from '../../../../../db';
import * as LOG from '../../../../../utils/logger';

export default async function getIngestTitle(_: Parent, args: QueryGetIngestTitleArgs, _context: Context): Promise<GetIngestTitleResult> {

// The ingest title is tied to the MediaGroup's (item) name and is pulled from EDAN
// when first ingesting. Here we build our title and sanitize it as needed.

const { item, sourceObjects } = args.input;
if (item) {
let itemDB: DBAPI.Item | null = null;
Expand Down
5 changes: 3 additions & 2 deletions server/job/impl/Cook/CookResource.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable camelcase */
/* eslint-disable @typescript-eslint/no-explicit-any */
import axios, { AxiosResponse } from 'axios';
import * as LOG from '../../../utils/logger';
import * as DBAPI from '../../../db';
Expand Down Expand Up @@ -67,8 +68,8 @@ const getCookResourceStatus = async (address: string, port: number): Promise<Coo
};
return result;

} catch (error) {
return { success: false, error: JSON.stringify(error), address, };
} catch (error: any) {
return { success: false, error: (error.message)?error.message:JSON.stringify(error), address, };
}
};
const verifyCookResourceCapability = (job: string, resource: DBAPI.CookResource): number => {
Expand Down
8 changes: 4 additions & 4 deletions server/job/impl/Cook/JobCook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ export abstract class JobCook<T> extends JobPackrat {
while (true) {
try {
LOG.info(`JobCook [${this.name()}] creating job: ${requestUrl} body ${JSON.stringify(jobCookPostBody, H.Helpers.saferStringify)}`, LOG.LS.eJOB);
const axiosResponse: AxiosResponse<any> | null = await axios.post(requestUrl, jobCookPostBody);
const axiosResponse: AxiosResponse<any> | null = await axios.post(encodeURI(requestUrl), jobCookPostBody);

if (axiosResponse?.status === 201)
break; // success, continue
Expand Down Expand Up @@ -302,7 +302,7 @@ export abstract class JobCook<T> extends JobPackrat {
while (true) {
try {
LOG.info(`JobCook [${this.name()}] running job: ${requestUrl}`, LOG.LS.eJOB);
const axiosResponse = await axios.patch(requestUrl);
const axiosResponse = await axios.patch(encodeURI(requestUrl));
if (axiosResponse.status === 202)
break; // success, continue
res = { success: false, error: `JobCook [${this.name()}] patch ${requestUrl} failed: ${JSON.stringify(axiosResponse)}` };
Expand Down Expand Up @@ -338,7 +338,7 @@ export abstract class JobCook<T> extends JobPackrat {
LOG.info(`JobCook [${this.name()}] cancelling job: ${requestUrl}`, LOG.LS.eJOB);
while (true) {
try {
const axiosResponse = await axios.patch(requestUrl);
const axiosResponse = await axios.patch(encodeURI(requestUrl));
if (axiosResponse.status !== 200)
res = { success: false, error: `JobCook [${this.name()}] patch ${requestUrl} failed: ${JSON.stringify(axiosResponse)}` };
} catch (error) {
Expand All @@ -365,7 +365,7 @@ export abstract class JobCook<T> extends JobPackrat {
// Get job report via GET to /clients/<CLIENTID>/jobs/<JOBID>/report
const requestUrl: string = this.CookServerURL() + `clients/${this._configuration.clientId}/jobs/${this._configuration.jobId}/report`;
try {
const axiosResponse = await axios.get(requestUrl);
const axiosResponse = await axios.get(encodeURI(requestUrl));
if (axiosResponse.status !== 200) {
// only log errors after first attempt, as job creation may not be complete on Cook server
const error: string = JSON.stringify(axiosResponse);
Expand Down
3 changes: 2 additions & 1 deletion server/utils/nameHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ export class NameHelpers {
}

static sanitizeFileName(fileName: string): string {
return sanitize(fileName.replace(/:/g, '-').replace(/ /g, '_'), { replacement: '_' });
return sanitize(fileName.replace(/[\s,]/g, '_').replace(/[^a-zA-Z0-9\-_.]/g, '-'));
//legacy: return sanitize(fileName.replace(/:/g, '-').replace(/ /g, '_'), { replacement: '_' });
}

static computeBaseTitle(name: string, subtitle: string | undefined | null): string {
Expand Down

0 comments on commit eb9c381

Please sign in to comment.