@Test public void testNativePathBadRequestBlank() throws Exception { ManagedRepositoryContent repository = createManagedRepo( "default" ); try { repoRequest.toNativePath( ""); fail( "Should have thrown an exception about an blank request." ); } catch ( LayoutException e ) { } }
public String toNativePath( String requestedPath) throws LayoutException { if ( StringUtils.isBlank( requestedPath ) ) { throw new LayoutException( "Request Path is blank." ); } String referencedResource = requestedPath; String supportfile = ""; if ( isSupportFile( requestedPath ) ) { int idx = requestedPath.lastIndexOf( '.' ); referencedResource = requestedPath.substring( 0, idx ); supportfile = requestedPath.substring( idx ); } if ( isMetadata( referencedResource ) ) { if (requestedPath.startsWith( "/" )) { return requestedPath; } else { return "/"+requestedPath; } } String adjustedPath = repository.getContent( ).toPath( repository.getContent( ).toItem( requestedPath ) ); return adjustedPath + supportfile; }
MavenRepositoryRequestInfo implements RepositoryRequestInfo { public String toNativePath( String requestedPath) throws LayoutException { if ( StringUtils.isBlank( requestedPath ) ) { throw new LayoutException( "Request Path is blank." ); } String referencedResource = requestedPath; String supportfile = ""; if ( isSupportFile( requestedPath ) ) { int idx = requestedPath.lastIndexOf( '.' ); referencedResource = requestedPath.substring( 0, idx ); supportfile = requestedPath.substring( idx ); } if ( isMetadata( referencedResource ) ) { if (requestedPath.startsWith( "/" )) { return requestedPath; } else { return "/"+requestedPath; } } String adjustedPath = repository.getContent( ).toPath( repository.getContent( ).toItem( requestedPath ) ); return adjustedPath + supportfile; } }
MavenRepositoryRequestInfo implements RepositoryRequestInfo { public String toNativePath( String requestedPath) throws LayoutException { if ( StringUtils.isBlank( requestedPath ) ) { throw new LayoutException( "Request Path is blank." ); } String referencedResource = requestedPath; String supportfile = ""; if ( isSupportFile( requestedPath ) ) { int idx = requestedPath.lastIndexOf( '.' ); referencedResource = requestedPath.substring( 0, idx ); supportfile = requestedPath.substring( idx ); } if ( isMetadata( referencedResource ) ) { if (requestedPath.startsWith( "/" )) { return requestedPath; } else { return "/"+requestedPath; } } String adjustedPath = repository.getContent( ).toPath( repository.getContent( ).toItem( requestedPath ) ); return adjustedPath + supportfile; } MavenRepositoryRequestInfo(ManagedRepository repository); }
MavenRepositoryRequestInfo implements RepositoryRequestInfo { public String toNativePath( String requestedPath) throws LayoutException { if ( StringUtils.isBlank( requestedPath ) ) { throw new LayoutException( "Request Path is blank." ); } String referencedResource = requestedPath; String supportfile = ""; if ( isSupportFile( requestedPath ) ) { int idx = requestedPath.lastIndexOf( '.' ); referencedResource = requestedPath.substring( 0, idx ); supportfile = requestedPath.substring( idx ); } if ( isMetadata( referencedResource ) ) { if (requestedPath.startsWith( "/" )) { return requestedPath; } else { return "/"+requestedPath; } } String adjustedPath = repository.getContent( ).toPath( repository.getContent( ).toItem( requestedPath ) ); return adjustedPath + supportfile; } MavenRepositoryRequestInfo(ManagedRepository repository); @Override ItemSelector toItemSelector( String requestPath ); boolean isMetadata( String requestedPath ); boolean isArchetypeCatalog( String requestedPath ); boolean isSupportFile( String requestedPath ); boolean isMetadataSupportFile( String requestedPath ); @Override String getLayout(String requestPath); String toNativePath( String requestedPath); @Override RepositoryFeature<T> getFeature(Class<T> clazz); @Override boolean supportsFeature(Class<T> clazz); }
MavenRepositoryRequestInfo implements RepositoryRequestInfo { public String toNativePath( String requestedPath) throws LayoutException { if ( StringUtils.isBlank( requestedPath ) ) { throw new LayoutException( "Request Path is blank." ); } String referencedResource = requestedPath; String supportfile = ""; if ( isSupportFile( requestedPath ) ) { int idx = requestedPath.lastIndexOf( '.' ); referencedResource = requestedPath.substring( 0, idx ); supportfile = requestedPath.substring( idx ); } if ( isMetadata( referencedResource ) ) { if (requestedPath.startsWith( "/" )) { return requestedPath; } else { return "/"+requestedPath; } } String adjustedPath = repository.getContent( ).toPath( repository.getContent( ).toItem( requestedPath ) ); return adjustedPath + supportfile; } MavenRepositoryRequestInfo(ManagedRepository repository); @Override ItemSelector toItemSelector( String requestPath ); boolean isMetadata( String requestedPath ); boolean isArchetypeCatalog( String requestedPath ); boolean isSupportFile( String requestedPath ); boolean isMetadataSupportFile( String requestedPath ); @Override String getLayout(String requestPath); String toNativePath( String requestedPath); @Override RepositoryFeature<T> getFeature(Class<T> clazz); @Override boolean supportsFeature(Class<T> clazz);  }