Esempio n. 1
0
        ///
        ///	 <summary> * generates the correct MIMEType for a given URL and sets it
        ///	 *  </summary>
        ///	 * <param name="url"> </param>
        ///
        public static string getMimeTypeFromURL(string url)
        {
            if (mimeMap == null)
            {
                mimeMap = new Dictionary <string, string>();
                mimeMap.Add("pdf", JDFConstants.MIME_PDF);
                mimeMap.Add("ps", JDFConstants.MIME_PS);

                mimeMap.Add("ppf", JDFConstants.MIME_CIP3);
                mimeMap.Add("ppml", JDFConstants.MIME_PPML);
                mimeMap.Add("jdf", JDFConstants.MIME_JDF);
                mimeMap.Add("jmf", JDFConstants.MIME_JMF);

                mimeMap.Add("xml", JDFConstants.MIME_TEXTXML);

                mimeMap.Add("jpg", JDFConstants.MIME_JPG);
                mimeMap.Add("jpeg", JDFConstants.MIME_JPG);
                mimeMap.Add("tif", JDFConstants.MIME_TIFF);
                mimeMap.Add("tiff", JDFConstants.MIME_TIFF);
            }
            string extension = UrlUtil.extension(url);
            string value     = null;

            if (!String.IsNullOrEmpty(extension))
            {
                mimeMap.TryGetValue(extension.ToLower(), out value);
            }
            return(value);
        }
Esempio n. 2
0
        public static void submitMimeToHDM(JDFNode n)
        {
            // build SubmitQueueEntry
            JDFDoc     docJMF = new JDFDoc("JMF");
            JDFJMF     jmf    = docJMF.getJMFRoot();
            JDFCommand com    = (JDFCommand)jmf.appendMessageElement(JDFMessage.EnumFamily.Command, JDFMessage.EnumType.SubmitQueueEntry);

            com.appendQueueSubmissionParams().setURL("dummy");
            System.Net.Mail.AttachmentCollection mp = MimeUtil.buildMimePackage(docJMF, n.getOwnerDocument_JDFElement(), true);

            try
            {
                MIMEDetails md = new MIMEDetails();
                md.transferEncoding      = UrlUtil.BASE64;
                md.httpDetails.chunkSize = -1;
                HttpWebRequest response = MimeUtil.writeToURL(mp, "http://192.168.40.71:8889/jmfportal", md);
                // Java to C# Converstion - What is the ResponseCode for HttpWebRequest?
                //Assert.AreEqual(200, response.GetResponse().getResponseCode());
                MimeUtil.writeToURL(mp, UrlUtil.fileToUrl(new FileInfo("C:\\data\\test.mim"), false), md);
            }
            catch (Exception e)
            {
                Assert.Fail(e.Message); // fail on exception
            }
        }
Esempio n. 3
0
 ///
 ///	 * <param name="_schemaLocation"> the schema location </param>
 ///
 public virtual void setJDFSchemaLocation(FileInfo _schemaLocation)
 {
     if (_schemaLocation != null && _schemaLocation.Length != 0)
     {
         string fileToUrl = UrlUtil.fileToUrl(_schemaLocation, false);
         m_SchemaLocation = "http://www.CIP4.org/JDFSchema_1_1 " + fileToUrl;
     }
 }
Esempio n. 4
0
 ///
 ///	 * <param name="parent"> </param>
 ///
 private void setup()
 {
     if (grayBox)
     {
         setCategory(MISCPS_PRINTING);
     }
     //		theStatusCounter.addIgnorePart(EnumPartIDKey.Side);
     theStatusCounter.addIgnorePart(EnumPartIDKey.Separation);
     previewShare = UrlUtil.fileToUrl(new FileInfo("\\\\Share\\Dir\\Preview_"), false);
 }
Esempio n. 5
0
        ///
        ///	 <summary> * get the input stream that reads from URL
        ///	 *  </summary>
        ///	 * <returns> InputStream the input stream that the url points to, null if the
        ///	 *         url is inaccessible </returns>
        ///
        public virtual Stream getURLInputStream()
        {
            string url = getURL();

            if (url.Equals(JDFConstants.EMPTYSTRING))
            {
                return(null);
            }
            return(UrlUtil.getURLInputStream(getURL(), getOwnerDocument_KElement().getBodyPart()));
        }
Esempio n. 6
0
        ///
        ///	 * <param name="previewLeaf"> </param>
        ///
        private void setPreviewURL(JDFPreview previewLeaf)
        {
            DirectoryInfo share = UrlUtil.urlToFile(previewShare).Directory;
            FileInfo      file;

            if (bPPF)
            {
                file = new FileInfo(previewLeaf.getSheetName() + ".ppf");
            }
            else
            {
                file = new FileInfo(previewLeaf.getSheetName() + "_" + previewLeaf.getSide().getName().Substring(0, 1) + "_" + previewLeaf.getSeparation() + ".png");
            }
            file = FileUtil.getFileInDirectory(share, file);
            previewLeaf.setURL(UrlUtil.fileToUrl(file, false));
            previewLeaf.setPreviewUsage(EnumPreviewUsage.Separation);
            previewLeaf.setPreviewFileType(EnumPreviewFileType.CIP3Single);
        }
Esempio n. 7
0
        ///
        ///     <summary> *  </summary>
        ///
        protected internal virtual void initJDF()
        {
            string icsTag = "Base_L" + baseICSLevel + "-" + theVersion.getName();

            theNode.appendAttribute(AttributeName.ICSVERSIONS, icsTag, null, " ", true);
            theNode.setVersion(theVersion);
            theNode.setMaxVersion(theVersion);
            theNode.setStatus(EnumNodeStatus.Waiting);
            if (!theNode.hasAttribute(AttributeName.DESCRIPTIVENAME))
            {
                theNode.setDescriptiveName("Base Golden Ticket Example Job - version: " + JDFAudit.software());
            }

            if (theParentNode == null && !theNode.hasAttribute(AttributeName.COMMENTURL))
            {
                theNode.setCommentURL(UrlUtil.StringToURL("http://www.example.com").ToString());
            }
        }
Esempio n. 8
0
        private string parseArgs(string[] commandLineArgs)
        {
            MyArgs args = new MyArgs(commandLineArgs, "?cmqPQvVntwU", "dlfLuhpTxX", null);

            if (args.boolParameter('?', false))
            {
                sysOut.println("JDFValidator:\n" + version + '\n' + usage);
                Application.Exit();
            }
            bWarning         = args.boolParameter('w', false);
            bTiming          = args.boolParameter('t', false);
            bQuiet           = args.boolParameter('q', false);
            bWarnDanglingURL = args.boolParameter('U', false);

            this.setPrint(!args.boolParameter('Q', false));
            xmlOutputName = args.parameterString('x');
            xslStyleSheet = args.parameterString('X');
            getTranslation(args);
            pOut = new XMLDoc("CheckOutput", null);
            KElement xmlRoot = pOut.getRoot();

            xmlRoot.setAttribute("Language", "EN");

            bool bVersion = !bQuiet || args.boolParameter('V', false);

            if (bVersion)
            {
                sysOut.println('\n' + version + '\n');
                sysOut.println(args.ToString());
                xmlRoot.setAttribute("Arguments", StringUtil.setvString(commandLineArgs, " ", null, null));
            }

            bPrintNameSpace = args.boolParameter('n', false);
            bMultiID        = args.boolParameter('m', false);

            if (args.hasParameter('h'))
            {
                proxyHost = args.parameterString('h');
                proxyPort = args.parameterString('p');
            }

            if (args.hasParameter('c'))
            {
                if (args.boolParameter('c', false))
                {
                    level = EnumValidationLevel.Complete;
                }
                else
                {
                    level = EnumValidationLevel.Incomplete;
                }
            }

            string parameterString = args.parameterString('L');

            if (parameterString != null)
            {
                setJDFSchemaLocation(new FileInfo(parameterString));
            }

            string schemaLocation0 = args.parameterString('l');

            // convert "," to blank
            if (schemaLocation0 != null)
            {
                VString vs = new VString(schemaLocation0, JDFConstants.COMMA);
                if (vs.Count % 2 != 0)
                {
                    sysOut.println("error in schema location: format is \"NameSpaceURI1,Location1,NameSpaceURI2,Location2\"\n - bailing out!" + usage);
                    Application.Exit();
                }
                schemaLocation0 = StringUtil.setvString(vs, JDFConstants.BLANK, JDFConstants.EMPTYSTRING, JDFConstants.EMPTYSTRING);
                schemaLocation += schemaLocation0;
            }

            if (args.hasParameter('d'))
            {
                devCapFile = args.parameterString('d');
                FileInfo fDC = UrlUtil.urlToFile(devCapFile);
                if (fDC == null || !fDC.Exists)
                {
                    sysOut.println("Error reading devcap file: " + devCapFile + "\n - bailing out!\n" + usage);
                    Application.Exit();
                }
            }

            bValidate = (args.boolParameter('v', false)) || (schemaLocation != null);
            string jdfVersion = args.parameterString('f');

            if (jdfVersion != null)
            {
                EnumVersion v = EnumVersion.getEnum(jdfVersion);
                JDFElement.setDefaultJDFVersion(v);
                JDFVersions.ForceVersion = true;
            }

            if (args.nargs() == 0)
            {
                sysOut.println(args.usage(usage));
                Application.Exit();
            }

            testlists = EnumFitsValue.Allowed;
            if (args.boolParameter('P', false))
            {
                testlists = EnumFitsValue.Present;
            }

            string url = args.parameterString('u');

            setAllFiles(args);
            return(url);
        }
Esempio n. 9
0
        ///
        ///	 <summary> * sets the URL attribute to an absolute file IRL (internationalized)
        ///	 *  </summary>
        ///	 * <param name="f">
        ///	 *            the file to set the URL to </param>
        ///	 * <param name="baseDir">
        ///	 *            the File representing the relative location. if null use
        ///	 *            current working dir </param>
        ///	 * <param name="boolean"> bEscape128 if true, escape chars>128 (URL) else don't
        ///	 *        escape (IRL) </param>
        ///
        public virtual void setRelativeURL(FileInfo f, FileInfo baseDir, bool bEscape128)
        {
            string s = UrlUtil.getRelativeURL(f, baseDir, bEscape128);

            setMimeURL(s);
        }
Esempio n. 10
0
        ///
        ///	 <summary> * sets the URL attribute to an absolute file IRL (internationalized)
        ///	 *  </summary>
        ///	 * <param name="f">
        ///	 *            the file to set the URL to </param>
        ///	 * <param name="boolean"> bEscape128 if true, escape chars>128 (URL) else don't
        ///	 *        escape (IRL) </param>
        ///
        public virtual void setAbsoluteFileURL(FileInfo f, bool bEscape128)
        {
            string s = UrlUtil.fileToUrl(f, bEscape128);

            setMimeURL(s);
        }
Esempio n. 11
0
        //public Element createElementNode(QName element)
        //{
        //   if (fCurrentNode.getLocalName() != null)
        //   {
        //      ((DocumentJDFImpl)(this.fDocument)).setParentNode(fCurrentNode);
        //   }

        //   Element e = super.createElementNode(element);
        //   ((DocumentJDFImpl)(this.fDocument)).setParentNode(null);
        //   return e;

        //}

        ///
        ///	 <summary> * parseFile - parse a file specified by strFile
        ///	 *  </summary>
        ///	 * <param name="strFile"> link to the document to parse, may be either a file path or a url </param>
        ///	 * <returns> JDFDoc or null if File not found </returns>
        ///
        public virtual JDFDoc parseFile(string strFile)
        {
            FileInfo file = UrlUtil.urlToFile(strFile);

            return(parseFile(file));
        }
Esempio n. 12
0
        public static bool validStringForType(string val, EnumAttributeType iType, ValuedEnum enu)
        {
            if (val == null)
            {
                return(false);
            }

            try
            {
                if (iType == AttributeInfo.EnumAttributeType.Any)
                {
                    return(true);
                }
                if (iType == AttributeInfo.EnumAttributeType.string_)
                {
                    return(val.Length < 1024);
                }
                if (iType == AttributeInfo.EnumAttributeType.shortString)
                {
                    return(val.Length < 64);
                }
                if (iType == AttributeInfo.EnumAttributeType.ID)
                {
                    return(StringUtil.isID(val));
                }
                if (iType == AttributeInfo.EnumAttributeType.NMTOKEN)
                {
                    return(StringUtil.isNMTOKEN(val));
                }
                if (iType == AttributeInfo.EnumAttributeType.NMTOKENS)
                {
                    return(StringUtil.isNMTOKENS(val, false));
                }
                if (iType == AttributeInfo.EnumAttributeType.IDREF)
                {
                    return(StringUtil.isID(val));
                }
                if (iType == AttributeInfo.EnumAttributeType.IDREFS)
                {
                    return(StringUtil.isNMTOKENS(val, true));
                }
                if (iType == AttributeInfo.EnumAttributeType.boolean_)
                {
                    return(StringUtil.isBoolean(val));
                }
                if (iType == AttributeInfo.EnumAttributeType.double_)
                {
                    return(StringUtil.isNumber(val));
                }
                if (iType == AttributeInfo.EnumAttributeType.integer)
                {
                    return(StringUtil.isInteger(val));
                }
                // integer or unbounded
                if (iType == AttributeInfo.EnumAttributeType.unbounded)
                {
                    return(JDFConstants.UNBOUNDED.Equals(val) || StringUtil.isInteger(val));
                }

                if ((iType == AttributeInfo.EnumAttributeType.URI) || (iType == AttributeInfo.EnumAttributeType.URL))
                {
                    return(UrlUtil.isIRL(val));
                }
                else if (iType == AttributeInfo.EnumAttributeType.RegExp)
                {
                    return(true);
                }

                else if ((iType == AttributeInfo.EnumAttributeType.enumeration) || (iType == AttributeInfo.EnumAttributeType.JDFJMFVersion))
                {
                    if (enu != null)
                    {
                        ValuedEnum ve = (ValuedEnum)EnumUtils.getEnum(enu.GetType(), val);
                        return(ve != null);
                    }
                    // limp along if something went wrong
                    return(StringUtil.isNMTOKEN(val));
                }
                else if (iType == AttributeInfo.EnumAttributeType.enumerations)
                {
                    if (enu != null)
                    {
                        VString vs = new VString(StringUtil.tokenize(val, JDFConstants.BLANK, false));
                        for (int i = 0; i < vs.Count; i++)
                        {
                            ValuedEnum ve = (ValuedEnum)EnumUtils.getEnum(enu.GetType(), vs.stringAt(i));
                            // there was an invalid token
                            if (ve == null)
                            {
                                return(false);
                            }
                        }
                        // all were ok
                        return(true);
                    }
                    // limp along if something went wrong
                    return(StringUtil.isNMTOKENS(val, false));
                }
                else if (iType == AttributeInfo.EnumAttributeType.IntegerRange)
                {
                    new JDFIntegerRange(val);
                    return(true);
                }
                else if (iType == AttributeInfo.EnumAttributeType.IntegerList)
                {
                    new JDFIntegerList(val);
                    return(true);
                }
                else if (iType == AttributeInfo.EnumAttributeType.IntegerRangeList)
                {
                    new JDFIntegerRangeList(val);
                    return(true);
                }
                else if (iType == AttributeInfo.EnumAttributeType.NumberRange)
                {
                    new JDFNumberRange(val);
                    return(true);
                }
                else if (iType == AttributeInfo.EnumAttributeType.NumberRangeList)
                {
                    new JDFNumberRangeList(val);
                    return(true);
                }
                else if (iType == AttributeInfo.EnumAttributeType.NumberList)
                {
                    new JDFNumberList(val);
                    return(true);
                }
                else if (iType == AttributeInfo.EnumAttributeType.matrix)
                {
                    new JDFMatrix(val);
                    return(true);
                }
                else if (iType == AttributeInfo.EnumAttributeType.rectangle)
                {
                    new JDFRectangle(val);
                    return(true);
                }
                else if (iType == AttributeInfo.EnumAttributeType.shape)
                {
                    new JDFShape(val);
                    return(true);
                }
                else if (iType == AttributeInfo.EnumAttributeType.XYPair)
                {
                    new JDFXYPair(val);
                    return(true);
                }
                else if (iType == AttributeInfo.EnumAttributeType.XYPairRange)
                {
                    new JDFXYPairRange(val);
                    return(true);
                }
                else if (iType == AttributeInfo.EnumAttributeType.XYPairRangeList)
                {
                    new JDFXYPairRangeList(val);
                    return(true);
                }
                else if (iType == AttributeInfo.EnumAttributeType.dateTime)
                {
                    new JDFDate(val);
                    return(val.IndexOf("T") == 10); // pure dates are not valid
                }
                else if (iType == AttributeInfo.EnumAttributeType.duration)
                {
                    new JDFDuration(val);
                    return(true);
                }
                else if (iType == AttributeInfo.EnumAttributeType.DurationRangeList)
                {
                    new JDFDurationRangeList(val);
                    return(true);
                }
                else if (iType == AttributeInfo.EnumAttributeType.DateTimeRangeList)
                {
                    new JDFDateTimeRangeList(val);
                    return(true);
                }
                else if (iType == AttributeInfo.EnumAttributeType.RectangleRangeList)
                {
                    new JDFRectangleRangeList(val);
                    return(true);
                }
                else if (iType == AttributeInfo.EnumAttributeType.ShapeRangeList)
                {
                    new JDFShapeRangeList(val);
                    return(true);
                }
                else if (iType == AttributeInfo.EnumAttributeType.CMYKColor)
                {
                    new JDFCMYKColor(val);
                    return(true);
                }
                else if (iType == AttributeInfo.EnumAttributeType.LabColor)
                {
                    new JDFLabColor(val);
                    return(true);
                }
                else if (iType == AttributeInfo.EnumAttributeType.RGBColor)
                {
                    new JDFRGBColor(val);
                    return(true);
                }
                else if (iType == AttributeInfo.EnumAttributeType.language)
                {
                    return(validLanguageString(val));
                }
                else if (iType == AttributeInfo.EnumAttributeType.languages)
                {
                    VString v = new VString(StringUtil.tokenize(val, JDFConstants.BLANK, false));
                    for (int i = 0; i < v.Count; i++)
                    {
                        if (!validLanguageString(v[i]))
                        {
                            return(false);
                        }
                    }
                    return(true);
                }
                else if (iType == AttributeInfo.EnumAttributeType.PDFPath)
                {
                    // TODO better regexp
                    return(true);
                }
                else if (iType == AttributeInfo.EnumAttributeType.XPath)
                {
                    // TODO better regexp
                    return(true);
                }
                else if (iType == AttributeInfo.EnumAttributeType.hexBinary)
                {
                    return(StringUtil.matches(val, JDFConstants.REGEXP_HEXBINARY));
                }
                else if (iType == AttributeInfo.EnumAttributeType.TransferFunction)
                {
                    JDFNumberList nl = new JDFNumberList(val);
                    return(nl.Count % 2 == 0);
                }
                else
                {
                    // TODO check if we are complete
                    Console.WriteLine("validStringForType: unknown type:" + iType.getName());
                    return(false);
                }
            }
            catch (FormatException)
            {
                return(false);
            }
        }