|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.cip4.jdflib.util.UrlUtil
org.cip4.jdflib.util.MimeUtil
public class MimeUtil
MIME utilities for reading and writing MIME/MULTIPART/RELATED streams
| Nested Class Summary | |
|---|---|
static class |
MimeUtil.ByteArrayDataSource
data source for binary files |
static class |
MimeUtil.MIMEDetails
helper class to set mime details |
| Nested classes/interfaces inherited from class org.cip4.jdflib.util.UrlUtil |
|---|
UrlUtil.HTTPDetails, UrlUtil.URLProtocol |
| Field Summary | |
|---|---|
static String |
MULTIPART_RELATED
commonly used strings |
| Fields inherited from class org.cip4.jdflib.util.UrlUtil |
|---|
APPLICATION_PDF, APPLICATION_XML, APPLICATION_XZIP, APPLICATION_ZIP, BASE64, BINARY, CONTENT_ID, CONTENT_LENGTH, CONTENT_TRANSFER_ENCODING, CONTENT_TYPE, GET, HEAD, KEEPALIVE, m_UNCEscape, m_URIEscape, POST, TEXT_CSV, TEXT_HTML, TEXT_PLAIN, TEXT_UNKNOWN, TEXT_XML, VND_JDF, VND_JMF |
| Constructor Summary | |
|---|---|
MimeUtil()
|
|
| Method Summary | |
|---|---|
static javax.mail.Multipart |
buildMimePackage(JDFDoc docJMF,
JDFDoc docJDF)
Deprecated. use 3 parameter version |
static javax.mail.Multipart |
buildMimePackage(JDFDoc docJMF,
XMLDoc docJDF,
boolean extendReferenced)
build a MIME package that contains all references in all FileSpecs of a given JDFDoc the doc is modified so that all URLs are cids |
static javax.mail.Multipart |
buildMimePackage(Vector<? extends XMLDoc> vXMLDocs)
Builds a MIME package. |
static javax.mail.BodyPart[] |
extractMultipartMime(InputStream mimeStream)
Extracts all the parts of a multipart MIME message and returns an array of InputStream for each of the separate MIME parts. |
static javax.mail.BodyPart[] |
getBodyParts(javax.mail.Multipart mp)
get all the parts of of a multipart an |
static String |
getContentID(javax.mail.BodyPart bp)
get the ContentID header of a bodypart a string |
static javax.mail.BodyPart |
getCreatePartByCID(javax.mail.Multipart mp,
String cid)
get the MIME BodyPart from a multiPart package with a given cid create one if it does not exist; |
static String |
getFileName(javax.mail.BodyPart bp)
get the filename header of a bodypart a string if no file name is set, a unique filename is generated from cid and content type |
static JDFDoc |
getJDFDoc(javax.mail.BodyPart bp)
get the JDF Doc from a given body part |
static JDFDoc |
getJDFDoc(InputStream stream,
int index)
get the JDF Doc from a stream, also handle non mime streams gracefully |
static JDFDoc[] |
getJMFSubmission(javax.mail.Multipart mp)
gets the JMF document of a submitqueueentry or returnqueuentry and the attached jdf document |
static String |
getMimeTypeFromExt(String fileName)
Deprecated. use UrlUtil.getMimeTypeFromURL(fileName); |
static javax.mail.Multipart |
getMultiPart(InputStream mimeStream)
create a root multipart from an input stream |
static javax.mail.Multipart |
getMultiPart(String fileName)
helper to create a root multipart from a file |
static javax.mail.BodyPart |
getPartByCID(javax.mail.Multipart mp,
String cid)
get the MIME BodyPart from a multiPart package with a given cid |
static boolean |
isJDFMimeType(String mimeType)
checks whether the mime type corresponds to one of "application/vnd.cip4-jdf+xml"; "application/vnd.cip4-jmf+xml"; "text/xml"; |
static boolean |
isMimeMultiPart(String contentType)
|
static boolean |
isMimeType(String toCheck,
String mimeType)
checks whether the mime type corresponds to mimetyoe |
static boolean |
matchesCID(javax.mail.BodyPart bp,
String cid)
check if a BodyPart matches a given cid |
static void |
setContent(javax.mail.BodyPart messageBodyPart,
XMLDoc xmlDoc)
sets the content of a bodypart to the xmlDoc - correctly handling non-ascii features and setting the correct content type |
static void |
setContentID(javax.mail.BodyPart bp,
String cid)
|
static void |
setFileName(javax.mail.BodyPart bp,
String path)
set the filename header of a bodypart to a string |
static javax.mail.BodyPart |
updateXMLMultipart(javax.mail.Multipart multipart,
XMLDoc xmlDoc,
String cid)
|
static String |
urlToCid(String urlString)
|
static void |
writeBodyPartToFile(javax.mail.BodyPart bp,
File directory)
|
static void |
writeToDir(javax.mail.Multipart mp,
File directory)
write a Message to a directory |
static File |
writeToFile(javax.mail.Multipart m,
String fileName)
Deprecated. |
static File |
writeToFile(javax.mail.Multipart m,
String fileName,
MimeUtil.MIMEDetails md)
write a Multipart to an output file |
static JDFDoc |
writeToQueue(JDFDoc docJMF,
JDFDoc docJDF,
String strUrl,
MimeUtil.MIMEDetails urlDet)
submit a multipart file to a queue |
static void |
writeToStream(javax.mail.Multipart m,
OutputStream outStream)
Deprecated. |
static void |
writeToStream(javax.mail.Multipart m,
OutputStream outStream,
MimeUtil.MIMEDetails md)
write a Multipart to a Stream |
static HttpURLConnection |
writeToURL(javax.mail.Multipart mp,
String strUrl)
write a Multipart to an output URL File: and http: are currently supported Use HttpURLConnection.getInputStream() to retrieve the http response |
static HttpURLConnection |
writeToURL(javax.mail.Multipart mp,
String strUrl,
MimeUtil.MIMEDetails mimeDetails)
write a Multipart to an output URL File: and http: are currently supported Use HttpURLConnection.getInputStream() to retrieve the http response |
| Methods inherited from class org.cip4.jdflib.util.UrlUtil |
|---|
addParameter, addPath, cleanDots, cleanHttpURL, createHttpUrl, escape, extension, fileToUrl, getBytesFromIP, getCidURLStream, getCreateDirectory, getFileName, getIPFromBytes, getLocalURL, getMimeTypeFromURL, getProtocol, getRelativePath, getRelativeURL, getURLInputStream, getURLInputStream, getURLParts, getURLWithDirectory, isCID, isEscaped, isFile, isFileOK, isHttp, isHttps, isIRL, isMIME, isMIMEExtenstension, isNotCID, isRelativeURL, isUNC, isURL, isWindowsLocalPath, isXMLType, isZIPType, moveToDir, moveToDir, newExtension, normalize, prefix, removeExtension, removeProtocol, stringToURL, uncToUrl, unEscape, urlToFile, urlToFileName, urlToString, urlToUNC, writeToURL |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String MULTIPART_RELATED
| Constructor Detail |
|---|
public MimeUtil()
| Method Detail |
|---|
public static void setContentID(javax.mail.BodyPart bp,
String cid)
bp - cid -
public static void setFileName(javax.mail.BodyPart bp,
String path)
bp - the bodypartpath - the path to setpublic static String getFileName(javax.mail.BodyPart bp)
bp - the bodypart
public static String getContentID(javax.mail.BodyPart bp)
bp - the bodypart
public static javax.mail.BodyPart[] extractMultipartMime(InputStream mimeStream)
mimeStream -
public static javax.mail.BodyPart[] getBodyParts(javax.mail.Multipart mp)
mp - the multiPart to extract
public static javax.mail.BodyPart getPartByCID(javax.mail.Multipart mp,
String cid)
mp - the multipart package to search incid - the cid of the requested bodypart
public static javax.mail.BodyPart getCreatePartByCID(javax.mail.Multipart mp,
String cid)
mp - the multipart package to search incid - the cid of the requested bodypart
public static JDFDoc getJDFDoc(InputStream stream,
int index)
stream - the stream to search inindex - the index of the body part to search
public static JDFDoc getJDFDoc(javax.mail.BodyPart bp)
bp - the BodyPart to search in
public static boolean matchesCID(javax.mail.BodyPart bp,
String cid)
bp - the bodyPart to checkcid - the cid string any '<' '>' or 'cid:' prefixes are removed if null, anything matches
public static javax.mail.Multipart getMultiPart(String fileName)
fileName - the name of the file used as input
public static javax.mail.Multipart getMultiPart(InputStream mimeStream)
mimeStream - the input stream
@Deprecated public static String getMimeTypeFromExt(String fileName)
fileName - the string to test
public static boolean isJDFMimeType(String mimeType)
mimeType - the string to test
public static boolean isMimeType(String toCheck,
String mimeType)
toCheck - the string to check againstmimeType - the mime type
@Deprecated
public static javax.mail.Multipart buildMimePackage(JDFDoc docJMF,
JDFDoc docJDF)
docJMF - docJDF -
public static javax.mail.Multipart buildMimePackage(JDFDoc docJMF,
XMLDoc docJDF,
boolean extendReferenced)
docJMF - the JDFDoc representation of the JMF that references the jdf to package, if null only the jdf is packaged note that the URL of docJDF must
already be specified as a CIDdocJDF - the JDFDoc representation of the JDF to packageextendReferenced - if true, also package any further referenced files
public static String urlToCid(String urlString)
urlString -
public static javax.mail.Multipart buildMimePackage(Vector<? extends XMLDoc> vXMLDocs)
vXMLDocs - the Vector of XMLDoc representing the JMF and JDFs to be stored as the first part of the package t
public static javax.mail.BodyPart updateXMLMultipart(javax.mail.Multipart multipart,
XMLDoc xmlDoc,
String cid)
multipart - xmlDoc - cid -
public static void setContent(javax.mail.BodyPart messageBodyPart,
XMLDoc xmlDoc)
throws javax.mail.MessagingException,
IOException
messageBodyPart - the BodyPart to fillxmlDoc - the xmlDoc to fill in
javax.mail.MessagingException
IOException
public static HttpURLConnection writeToURL(javax.mail.Multipart mp,
String strUrl)
throws IOException,
javax.mail.MessagingException
mp - the mime MultiPart to writestrUrl - the URL to write to
HttpURLConnection the opened http connection, null in case of error or file
IOException
javax.mail.MessagingException
public static HttpURLConnection writeToURL(javax.mail.Multipart mp,
String strUrl,
MimeUtil.MIMEDetails mimeDetails)
throws IOException,
javax.mail.MessagingException
mp - the mime MultiPart to writestrUrl - the URL to write tomimeDetails -
HttpURLConnection the opened http connection, null in case of error or file
IOException
javax.mail.MessagingException
public static JDFDoc writeToQueue(JDFDoc docJMF,
JDFDoc docJDF,
String strUrl,
MimeUtil.MIMEDetails urlDet)
throws IOException,
javax.mail.MessagingException
docJMF - the jmf document containing the submitqueueentry or resubmitqueueentrydocJDF - the jdf to submitstrUrl - the url to submit tourlDet - url details
IOException
javax.mail.MessagingException
@Deprecated
public static File writeToFile(javax.mail.Multipart m,
String fileName)
m - fileName -
public static File writeToFile(javax.mail.Multipart m,
String fileName,
MimeUtil.MIMEDetails md)
m - the mime MultiPart to writefileName - the file namemd -
@Deprecated
public static void writeToStream(javax.mail.Multipart m,
OutputStream outStream)
throws IOException,
javax.mail.MessagingException
m - outStream -
IOException
javax.mail.MessagingException
public static void writeToStream(javax.mail.Multipart m,
OutputStream outStream,
MimeUtil.MIMEDetails md)
throws IOException,
javax.mail.MessagingException
m - the mime MultiPart to writeoutStream - the existing output stream, note that a buffered output stream is created in case outStream is unbufferedmd - details for messaging
IOException
javax.mail.MessagingException
public static void writeToDir(javax.mail.Multipart mp,
File directory)
throws javax.mail.MessagingException,
IOException
mp - the mime Message to writedirectory - the directory to use as '.' for writing the mime parts
javax.mail.MessagingException
IOException
javax.mail.MessagingException
public static void writeBodyPartToFile(javax.mail.BodyPart bp,
File directory)
throws IOException,
javax.mail.MessagingException
bp - directory -
javax.mail.MessagingException
IOExceptionpublic static JDFDoc[] getJMFSubmission(javax.mail.Multipart mp)
mp - the Multipart to search
public static boolean isMimeMultiPart(String contentType)
contentType -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||