public Object getAttribute( final String key ) { if ( key == null ) { throw new NullPointerException(); } if ( contentItem == null ) { return null; } if ( ResourceData.CONTENT_TYPE.equals( key ) ) { try { return contentItem.getMimeType(); } catch ( ContentIOException e ) { return null; } } else if ( ResourceData.CONTENT_LENGTH.equals( key ) ) { return contentItem.getAttribute( LibRepositoryBoot.REPOSITORY_DOMAIN, LibRepositoryBoot.SIZE_ATTRIBUTE ); } else if ( ResourceData.FILENAME.equals( key ) ) { return contentItem.getName(); } return 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 String getEntryMimeType( final String name ) { if ( name == null ) { throw new NullPointerException(); } final String definedMimeType = metaData.getEntryMimeType( name ); if ( definedMimeType != null ) { return definedMimeType; } try { final String[] splitName = RepositoryUtilities.split( name, "/" ); final ContentEntity contentEntity = RepositoryUtilities.getEntity( zipRepository, splitName ); if ( contentEntity instanceof ContentItem ) { final ContentItem contentItem = (ContentItem) contentEntity; return contentItem.getMimeType(); } return ""; // for directories .. } catch ( ContentIOException cioe ) { // ignored. if ( logger.isDebugEnabled() ) { logger.debug( "Failed to lookup entry mime-type for entry " + name, cioe ); } return null; } }