BitstreamFormat exists = bitstreamFormatService.findByMIMEType(context, mimeType); exists = bitstreamFormatService.findByShortDescription(context, shortDesc); BitstreamFormat format = bitstreamFormatService.create(context); bitstreamFormatService.setShortDescription(context, format, shortDesc); format.setDescription(desc); format.setSupportLevel(supportLevel); bitstreamFormatService.update(context, format);
protected void setFormatToMIMEType(Context context, Bitstream bs, String mimeType) throws SQLException { List<BitstreamFormat> bf = bitstreamFormatService.findNonInternal(context); for (BitstreamFormat aBf : bf) { if (aBf.getMIMEType().equalsIgnoreCase(mimeType)) { bs.setFormat(context, aBf); break; } } }
@Override public BitstreamFormat getFormat(Context context, Bitstream bitstream) throws SQLException { if (bitstream.getBitstreamFormat() == null) { return bitstreamFormatService.findUnknown(context); } else { return bitstream.getBitstreamFormat(); } }
private void formatResults() throws IOException { try { StringBuilder sb = new StringBuilder(); for (String fmt : fmtTable.keySet()) { BitstreamFormat bsf = bitstreamFormatService.findByShortDescription(Curator.curationContext(), fmt); sb.append(String.format("%6d", fmtTable.get(fmt))).append(" ("). append(bitstreamFormatService.getSupportLevelText(bsf).charAt(0)).append(") "). append(bsf.getDescription()).append("\n"); } report(sb.toString()); setResult(sb.toString()); } catch (SQLException sqlE) { throw new IOException(sqlE.getMessage(), sqlE); } } }
int supportLevel, boolean internal) throws SQLException, AuthorizeException { BitstreamFormat bsf = bitstreamFormatService.findByShortDescription(context, shortDesc); bsf = bitstreamFormatService.create(context); bsf.setShortDescription(context, shortDesc); bsf.setMIMEType(MIMEType); bsf.setSupportLevel(supportLevel); bsf.setInternal(internal); bitstreamFormatService.update(context, bsf);
throws DSpaceSWORDException { try { BitstreamFormat bf = bitstreamFormatService.findByMIMEType( context, deposit.getContentType()); List<String> exts = null;
BitstreamFormat unknownFormat = bitstreamFormatService.findUnknown(context); bitstreamService.setFormat(context, dspaceBitstream, unknownFormat); } else { BitstreamFormat guessedFormat = bitstreamFormatService .findByMIMEType(context, getMimeType(bitstream.getName())); bitstreamService.setFormat(context, dspaceBitstream, guessedFormat);
BitstreamFormat unknownFormat = bitstreamFormatService.findUnknown(context); : bitstreamFormatService.findByMIMEType(context, mimeType); if (bf == null) { bf = bitstreamFormatService.guessFormat(context, bitstream);
bitstreamFormatService.findByMIMEType(context, MIMEType); if (bf == null) { bf = bitstreamFormatService.guessFormat(context, bitstream);
@Override public void setLicenseRDF(Context context, Item item, String licenseRdf) throws SQLException, IOException, AuthorizeException { Bundle bundle = getCcBundle(context, item); // set the format BitstreamFormat bs_rdf_format = bitstreamFormatService.findByShortDescription(context, "RDF XML"); // set the RDF bitstream setBitstreamFromBytes(context, item, bundle, BSN_LICENSE_RDF, bs_rdf_format, licenseRdf.getBytes()); }
BitstreamFormat bf = bitstreamFormatService.findByShortDescription(context, "License"); if (bf == null) { bf = bitstreamFormatService.guessFormat(context, lbs);
bsfMIMEType = value; } else if (dcField.equals("format.supportlevel")) { int sl = bitstreamFormatService.getSupportLevelID(value); if (sl < 0) { throw new MetadataValidationException( BitstreamFormat bsf = bitstreamFormatService.findByShortDescription(context, bsfShortName); if (bsf == null && bsfMIMEType != null) { bsf = PackageUtils.findOrCreateBitstreamFormat(context,
protected BitstreamFormat getFormat(Context context, String fileName) throws SQLException { String fext = null; int lastDot = fileName.lastIndexOf("."); if (lastDot > -1) { fext = fileName.substring(lastDot + 1); } if (fext == null) { return null; } List<BitstreamFormat> formats = bitstreamFormatService.findAll(context); for (BitstreamFormat format : formats) { List<String> extensions = format.getExtensions(); for (String ext : extensions) { if (ext.equals(fext)) { return format; } } } return null; }
try { BitstreamFormat bf = bitstreamFormatService .findByMIMEType(context, deposit.getMimeType()); List<String> exts = null; if (bf != null) {
dspaceBitstream.setFormat(context, bitstreamFormatService.findUnknown(context)); } else { bitstreamService.setFormat(context, dspaceBitstream, bitstreamFormatService .findByMIMEType(context, BitstreamResource.getMimeType(name)));
BitstreamFormat bsFormat = bitstreamFormatService.findByMIMEType(context, mimeString); if (bsFormat == null) { bsFormat = bitstreamFormatService.guessFormat(context, newBitstream);
@Override public void setLicense(Context context, Item item, InputStream licenseStm, String mimeType) throws SQLException, IOException, AuthorizeException { Bundle bundle = getCcBundle(context, item); // set the format BitstreamFormat bs_format; if (mimeType.equalsIgnoreCase("text/xml")) { bs_format = bitstreamFormatService.findByShortDescription(context, "CC License"); } else if (mimeType.equalsIgnoreCase("text/rdf")) { bs_format = bitstreamFormatService.findByShortDescription(context, "RDF XML"); } else { bs_format = bitstreamFormatService.findByShortDescription(context, "License"); } Bitstream bs = bitstreamService.create(context, bundle, licenseStm); bs.setSource(context, CC_BS_SOURCE); bs.setName(context, (mimeType != null && (mimeType.equalsIgnoreCase("text/xml") || mimeType.equalsIgnoreCase("text/rdf"))) ? BSN_LICENSE_RDF : BSN_LICENSE_TEXT); bs.setFormat(context, bs_format); bitstreamService.update(context, bs); }
.findByMIMEType(context, "application/xml"); if (bf != null) { entryBitstream.setFormat(context, bf); .findByMIMEType(context, deposit.getMimeType()); if (bf != null) { bitstream.setFormat(context, bf);
/** * Get the list of MIME types that the given DSpace object will * accept as packages. * * @param context The relevant DSpace Context. * @param dso target DSpace object * @return the list of MIME types that the given DSpace object will * accept as packages. * @throws DSpaceSWORDException can be thrown by the internals of the DSpace SWORD implementation */ public List<String> getAccepts(Context context, DSpaceObject dso) throws DSpaceSWORDException { try { List<String> accepts = new ArrayList<String>(); if (dso instanceof Collection) { for (String format : swordaccepts) { accepts.add(format); } } else if (dso instanceof Item) { List<BitstreamFormat> bfs = bitstreamFormatService .findNonInternal(context); for (BitstreamFormat bf : bfs) { accepts.add(bf.getMIMEType()); } } return accepts; } catch (SQLException e) { throw new DSpaceSWORDException(e); } }
@Override public void setFormat(Context context, Bitstream bitstream, BitstreamFormat bitstreamFormat) throws SQLException { // FIXME: Would be better if this didn't throw an SQLException, // but we need to find the unknown format! if (bitstreamFormat == null) { // Use "Unknown" format bitstreamFormat = bitstreamFormatService.findUnknown(context); } // Remove user type description clearMetadata(context, bitstream, MetadataSchema.DC_SCHEMA, "format", null, Item.ANY); // Update the ID in the table row bitstream.setFormat(bitstreamFormat); }