public StaticDocumentMetaData( final ResourceManager resourceManager, final ResourceKey bundleKey ) throws ResourceException { if ( resourceManager == null ) { throw new NullPointerException(); } if ( bundleKey == null ) { throw new NullPointerException(); } this.resourceManager = resourceManager; this.bundleKey = bundleKey; // A bundle without a manifest is not valid. final ResourceKey manifestDataKey = resourceManager.deriveKey( bundleKey, "/META-INF/manifest.xml" ); final Resource manifestDataResource = resourceManager.create( manifestDataKey, null, BundleManifest.class ); manifest = (BundleManifest) manifestDataResource.getResource(); metaData = createMetaData( resourceManager, bundleKey ); bundleType = readBundleType(); if ( bundleType == null ) { bundleType = manifest.getMimeType( "/" ); } // bundle type can still be null. }
public String getEntryMimeType( final String name ) { if ( name == null ) { throw new NullPointerException(); } final String definedMimeType = documentMetaData.getEntryMimeType( name ); if ( definedMimeType != null ) { return definedMimeType; } try { final String[] splitName = RepositoryUtilities.split( name, "/" ); final ContentEntity contentEntity = RepositoryUtilities.getEntity( repository, splitName ); if ( contentEntity instanceof ContentItem ) { final ContentItem contentItem = (ContentItem) contentEntity; return contentItem.getMimeType(); } } catch ( ContentIOException cioe ) { // ignored. if ( logger.isDebugEnabled() ) { logger.debug( "Failed to lookup entry mime-type for entry " + name, cioe ); } } return ""; }
public StaticDocumentBundle( final Repository repository, final ResourceManager resourceManager, final ResourceKey outsideContextKey ) throws ResourceException { if ( repository == null ) { throw new NullPointerException(); } if ( resourceManager == null ) { throw new NullPointerException(); } this.repository = repository; final BundleResourceManagerBackend backend = new BundleResourceManagerBackend( repository, resourceManager.getBackend(), outsideContextKey ); this.bundleKey = backend.getBundleMainKey(); this.resourceManager = new ResourceManager( resourceManager, backend ); this.documentMetaData = new StaticDocumentMetaData( this.resourceManager, this.bundleKey ); }