@@ -376,47 +376,6 @@ protected ManagementServerHostVO getSourceManagementServer(Long managementServer
376376 return msHost ;
377377 }
378378
379- protected Path resolvePathWithinExtension (Extension extension , String relativePath ) {
380- Path root = extensionsFilesystemManager .getExtensionRootPath (extension );
381- String normalizedPath = StringUtils .defaultString (relativePath ).replace ("\\ " , "/" ).trim ();
382- if (StringUtils .isBlank (normalizedPath )) {
383- return root ;
384- }
385- while (normalizedPath .startsWith ("/" )) {
386- normalizedPath = normalizedPath .substring (1 );
387- }
388- Path resolved = root .resolve (normalizedPath ).normalize ();
389- if (!resolved .startsWith (root )) {
390- throw new InvalidParameterValueException ("File path must remain within extension directory" );
391- }
392- return resolved ;
393- }
394-
395- protected String toRelativeExtensionPath (Extension extension , Path path ) {
396- Path root = extensionsFilesystemManager .getExtensionRootPath (extension );
397- Path normalizedPath = path .toAbsolutePath ().normalize ();
398- if (normalizedPath .equals (root )) {
399- return "." ;
400- }
401- return root .relativize (normalizedPath ).toString ().replace (File .separatorChar , '/' );
402- }
403-
404- protected ExtensionFileResult toExtensionFileResult (Extension extension , Path path , String content ) {
405- ExtensionFileResult result = new ExtensionFileResult ();
406- result .path = toRelativeExtensionPath (extension , path );
407- result .name = path .getFileName () == null ? Extension .getDirectoryName (extension .getName ()) : path .getFileName ().toString ();
408- result .directory = Files .isDirectory (path );
409- try {
410- result .size = result .directory ? null : Files .size (path );
411- result .lastModified = new Date (Files .getLastModifiedTime (path ).toMillis ());
412- } catch (Exception e ) {
413- result .size = null ;
414- result .lastModified = null ;
415- }
416- result .content = content ;
417- return result ;
418- }
419-
420379 protected ExtensionFileResponse toExtensionFileResponse (ExtensionFileResult result ) {
421380 ExtensionFileResponse response = new ExtensionFileResponse ();
422381 response .setPath (result .path );
0 commit comments