/** * Return the object as an XML input stream in the internal serialization * format. */ @Override public InputStream GetObjectXML() throws ObjectIntegrityException, StreamIOException, UnsupportedTranslationException, ServerException { ReadableByteArrayOutputStream bytes = new ReadableByteArrayOutputStream(4096); m_translator.serialize(m_obj, bytes, m_storageFormat, "UTF-8", DOTranslationUtility.SERIALIZE_STORAGE_INTERNAL); return bytes.toInputStream(); }
baos = new ReadableByteArrayOutputStream(); b64os = new Base64.OutputStream(baos, ENCODE | options); oos = new java.io.ObjectOutputStream(b64os); baos.close(); } catch (Exception e) { return baos.getString(Charset.forName(PREFERRED_ENCODING)); return new String(baos.toByteArray());
private MIMETypedStream noMethodIndexMsg() throws GeneralException { ReadableByteArrayOutputStream bytes = new ReadableByteArrayOutputStream(1024); PrintWriter sb = new PrintWriter( new OutputStreamWriter(bytes, Charset.forName("UTF-8"))); sb .append("<html><head><title>Dissemination Index Not Available</title></head>" + "<body><center>" + "<table width=\"784\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">" + "<tr><td width=\"141\" height=\"134\" valign=\"top\"><img src=\"/") .append(context .getEnvironmentValue(Constants.FEDORA_APP_CONTEXT_NAME)) .append("/images/newlogo2.jpg\" width=\"141\" height=\"134\"/></td>" + "<td width=\"643\" valign=\"top\">" + "<center><h2>Fedora Repository</h2>" + "<h3>Dissemination Index</h3>" + "</center></td></tr></table><p>"); sb.append("The Dissemination Index is not available" + " for Content Model objects, \n or Service Definition objects or Service Deployment objects.\n" + " The addition of this feature is not currently scheduled."); sb.append("</p></body></html>"); sb.close(); InputStream in = bytes.toInputStream(); return new MIMETypedStream("text/html", in, null, bytes.length()); }
/** * Simple encoding method that returns the text-encoded version of * this attribute with no formatting. * * @return the text-encoded XML */ @Override public String encode() { ReadableByteArrayOutputStream out = new ReadableByteArrayOutputStream(); encode(out); return out.toString(); }
private void prettyPrint(DigitalObject obj, OutputStream destination) throws Exception { ReadableByteArrayOutputStream outBuf = new ReadableByteArrayOutputStream(4096); m_serializer.serialize(obj, outBuf, ENCODING, DOTranslationUtility.AS_IS); outBuf.close(); prettyPrint(outBuf.toInputStream(), destination); }
ReadableByteArrayOutputStream out = new ReadableByteArrayOutputStream(2048); this.getXML(existing.getContentStream(), out, addXMLHeader); out.close(); byteContent = out.toInputStream(); byteLength = out.length(); } else {
params.put(name, request.getParameter(name)); ReadableByteArrayOutputStream out = new ReadableByteArrayOutputStream(); Context context = ReadOnlyContext.getContext(Constants.HTTP_REQUEST.REST.uri, try { getResponder().respond(context, params, out); out.close(); } catch (AuthzException ae) { throw RootException.getServletException(ae, response.getWriter().print(out.getString(Charset.forName("UTF-8"))); } catch (Throwable t) { throw new InternalError500Exception("",
new TupleArrayTripleIterator(new ArrayList<RelationshipTuple>(Arrays .asList(tuples))); ReadableByteArrayOutputStream os = new ReadableByteArrayOutputStream(); try { iter.toStream(os, RDFFormat.NOTATION_3, false); e.printStackTrace(); term = os.getString(Charset.forName("UTF-8")); } else if (javaType != null && javaType.equals("java.lang.String")) { term = (String) obj;
public static byte[] fedoraXMLHashFormat(byte[] data) throws Exception { ReadableCharArrayWriter writer = new ReadableCharArrayWriter(); DocumentBuilder builder = XmlTransformUtility.borrowDocumentBuilder(); try { Document doc = builder.parse(new ByteArrayInputStream(data)); XercesXmlSerializers.writeXmlNoSpace(doc, "UTF-8", writer); writer.close(); } finally { XmlTransformUtility.returnDocumentBuilder(builder); } BufferedReader br = new BufferedReader(writer.toReader()); String line = null; ReadableByteArrayOutputStream outStream = new ReadableByteArrayOutputStream(); OutputStreamWriter sb = new OutputStreamWriter(outStream, "UTF-8"); while ((line = br.readLine()) != null) { line = line.trim(); sb.write(line); } sb.close(); return outStream.toByteArray(); }
/** * {@inheritDoc} */ @Override public void characters(char[] ch, int start, int length) throws SAXException { // read entire inline XML metadata chunks into a buffer if (m_inXMLMetadata && !m_gotAudit) { // since this data is encoded straight back to xml, // we need to make sure special characters &, <, >, ", and ' // are re-converted to the xml-acceptable equivalents. ensureInlineXmlCharBuffer(); StreamUtility.enc(ch, start, length, m_dsXMLBuffer); } else if (m_gotAudit || m_readingBinaryContent){ // Use a separate buffer to deal with the special case // of AUDIT datastreams, which may be inline, but need to // retrieve individual element content to deserialize correctly // append element content into a byte buffer; or b64-encoded // binary content if (m_elementContent == null) { m_elementContent = new ReadableByteArrayOutputStream(); } CharBuffer chars = CharBuffer.wrap(ch, start, length); ByteBuffer bytes = Charset.forName(m_characterEncoding).encode(chars); m_elementContent.write(bytes.array(), bytes.arrayOffset(), bytes.limit()); } }
m_elementContent.toString() : ""; m_elementContent.toString() : ""; } else if (localName.equals("responsibility")) { m_auditResponsibility = (m_elementContent != null) ? m_elementContent.toString() : ""; } else if (localName.equals("date")) { m_auditDate = (m_elementContent != null) ? m_elementContent.toString() : ""; } else if (localName.equals("justification")) { m_auditJustification = (m_elementContent != null) ? m_elementContent.toString() : ""; } else if (localName.equals("record")) { new FileOutputStream(m_binaryContentTempFile); byte elementBytes[] = Base64.decode(m_elementContent.toInputStream()); os.write(elementBytes); os.close();
ReadableByteArrayOutputStream out = new ReadableByteArrayOutputStream(2048); this.getXML(existing.getContentStream(), out, addXMLHeader); out.close(); byteContent = out.toInputStream(); byteLength = out.length(); } else {
private void prettyPrint(DigitalObject obj, OutputStream destination) throws Exception { ReadableByteArrayOutputStream outBuf = new ReadableByteArrayOutputStream(4096); m_serializer.serialize(obj, outBuf, ENCODING, DOTranslationUtility.AS_IS); outBuf.close(); prettyPrint(outBuf.toInputStream(), destination); }
params.put(name, request.getParameter(name)); ReadableByteArrayOutputStream out = new ReadableByteArrayOutputStream(); Context context = ReadOnlyContext.getContext(Constants.HTTP_REQUEST.REST.uri, try { getResponder().respond(context, params, out); out.close(); } catch (AuthzException ae) { throw RootException.getServletException(ae, response.getWriter().print(out.getString(Charset.forName("UTF-8"))); } catch (Throwable t) { throw new InternalError500Exception("",
new TupleArrayTripleIterator(new ArrayList<RelationshipTuple>(Arrays .asList(tuples))); ReadableByteArrayOutputStream os = new ReadableByteArrayOutputStream(); try { iter.toStream(os, RDFFormat.NOTATION_3, false); e.printStackTrace(); term = os.getString(Charset.forName("UTF-8")); } else if (javaType != null && javaType.equals("java.lang.String")) { term = (String) obj;
/** * Simple encoding method that returns the text-encoded version of * this attribute with no formatting. * * @return the text-encoded XML */ @Override public String encode() { ReadableByteArrayOutputStream out = new ReadableByteArrayOutputStream(); encode(out); return out.toString(); }
/** * {@inheritDoc} */ @Override public void characters(char[] ch, int start, int length) throws SAXException { // read entire inline XML metadata chunks into a buffer if (m_inXMLMetadata && !m_gotAudit) { // since this data is encoded straight back to xml, // we need to make sure special characters &, <, >, ", and ' // are re-converted to the xml-acceptable equivalents. ensureInlineXmlCharBuffer(); StreamUtility.enc(ch, start, length, m_dsXMLBuffer); } else if (m_gotAudit || m_readingBinaryContent){ // Use a separate buffer to deal with the special case // of AUDIT datastreams, which may be inline, but need to // retrieve individual element content to deserialize correctly // append element content into a byte buffer; or b64-encoded // binary content if (m_elementContent == null) { m_elementContent = new ReadableByteArrayOutputStream(); } CharBuffer chars = CharBuffer.wrap(ch, start, length); ByteBuffer bytes = Charset.forName(m_characterEncoding).encode(chars); m_elementContent.write(bytes.array(), bytes.arrayOffset(), bytes.limit()); } }
m_elementContent.toString() : ""; m_elementContent.toString() : ""; } else if (localName.equals("responsibility")) { m_auditResponsibility = (m_elementContent != null) ? m_elementContent.toString() : ""; } else if (localName.equals("date")) { m_auditDate = (m_elementContent != null) ? m_elementContent.toString() : ""; } else if (localName.equals("justification")) { m_auditJustification = (m_elementContent != null) ? m_elementContent.toString() : ""; } else if (localName.equals("record")) { new FileOutputStream(m_binaryContentTempFile); byte elementBytes[] = Base64.decode(m_elementContent.toInputStream()); os.write(elementBytes); os.close();
/** * Return the object as an XML input stream in the internal serialization * format. */ @Override public InputStream GetObjectXML() throws ObjectIntegrityException, StreamIOException, UnsupportedTranslationException, ServerException { ReadableByteArrayOutputStream bytes = new ReadableByteArrayOutputStream(4096); m_translator.serialize(m_obj, bytes, m_storageFormat, "UTF-8", DOTranslationUtility.SERIALIZE_STORAGE_INTERNAL); return bytes.toInputStream(); }
private MIMETypedStream noMethodIndexMsg() throws GeneralException { ReadableByteArrayOutputStream bytes = new ReadableByteArrayOutputStream(1024); PrintWriter sb = new PrintWriter( new OutputStreamWriter(bytes, Charset.forName("UTF-8"))); sb .append("<html><head><title>Dissemination Index Not Available</title></head>" + "<body><center>" + "<table width=\"784\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">" + "<tr><td width=\"141\" height=\"134\" valign=\"top\"><img src=\"/") .append(context .getEnvironmentValue(Constants.FEDORA_APP_CONTEXT_NAME)) .append("/images/newlogo2.jpg\" width=\"141\" height=\"134\"/></td>" + "<td width=\"643\" valign=\"top\">" + "<center><h2>Fedora Repository</h2>" + "<h3>Dissemination Index</h3>" + "</center></td></tr></table><p>"); sb.append("The Dissemination Index is not available" + " for Content Model objects, \n or Service Definition objects or Service Deployment objects.\n" + " The addition of this feature is not currently scheduled."); sb.append("</p></body></html>"); sb.close(); InputStream in = bytes.toInputStream(); return new MIMETypedStream("text/html", in, null, bytes.length()); }