示例#1
0
        public static void ReadJavaUtilLoggingConfigFromClasspath()
        {
            var inputStream = ReflectUtil.GetResourceAsStream("logging.properties");

            try
            {
                if (inputStream != null)
                {
                    //LogManager.LogManager.readConfiguration(inputStream);

                    //string redirectCommons = LogManager.LogManager.getProperty("redirect.commons.logging");
                    //if ((!ReferenceEquals(redirectCommons, null)) &&
                    //    (!redirectCommons.Equals("false", StringComparison.CurrentCultureIgnoreCase)))
                    //{
                    //    System.setProperty("org.apache.commons.logging.Log",
                    //        "org.apache.commons.logging.impl.Jdk14Logger");
                    //}
                }
            }
            catch (System.Exception e)
            {
                throw new PvmException("couldn't initialize logging properly", e);
            }
            finally
            {
                IoUtil.CloseSilently(inputStream);
            }
        }
示例#2
0
        /// <summary>
        ///     Parse a camunda:resource attribute and loads the resource depending on the url scheme.
        ///     Supported Uri schemes are <code>classpath://</code> and <code>deployment://</code>.
        ///     If the scheme is omitted <code>classpath://</code> is assumed.
        /// </summary>
        /// <param name="resourcePath"> the path to the resource to load </param>
        /// <param name="deployment"> the deployment to load resources from </param>
        /// <returns> the resource content as <seealso cref="string" /> </returns>
        public static string LoadResourceContent(string resourcePath, DeploymentEntity deployment)
        {
            var pathSplit = resourcePath.Split("://", true);

            string resourceType;

            if (pathSplit.Length == 1)
            {
                resourceType = "classpath";
            }
            else
            {
                resourceType = pathSplit[0];
            }

            var resourceLocation = pathSplit[pathSplit.Length - 1];

            byte[] resourceBytes = null;

            if (resourceType.Equals("classpath"))
            {
                Stream resourceAsStream = null;
                try
                {
                    resourceAsStream = ReflectUtil.GetResourceAsStream(resourceLocation);
                    if (resourceAsStream != null)
                    {
                        resourceBytes = IoUtil.ReadInputStream(resourceAsStream, resourcePath);
                    }
                }
                finally
                {
                    IoUtil.CloseSilently(resourceAsStream);
                }
            }
            else if (resourceType.Equals("deployment"))
            {
                ResourceEntity resourceEntity = deployment.GetResource(resourceLocation);
                if (resourceEntity != null)
                {
                    resourceBytes = resourceEntity.Bytes;
                }
            }

            if (resourceBytes != null)
            {
                return(StringHelperClass.NewString(resourceBytes, Encoding.UTF8.ToString()));
            }
            throw Log.CannotFindResource(resourcePath);
        }
示例#3
0
        public virtual void TestProcessDiagramResource()
        {
            IProcessDefinition processDefinition = repositoryService.CreateProcessDefinitionQuery().First();

            Assert.AreEqual("resources/Bpmn/Deployment/BpmnDeploymentTest.TestProcessDiagramResource.bpmn20.xml".ToLower(), processDefinition.ResourceName.ToLower());
            Assert.True(processDefinition.GetHasStartFormKey());

            string diagramResourceName = processDefinition.DiagramResourceName;

            Assert.AreEqual("resources/Bpmn/Deployment/BpmnDeploymentTest.TestProcessDiagramResource.jpg".ToLower(), diagramResourceName.ToLower());

            System.IO.Stream diagramStream = repositoryService.GetResourceAsStream(DeploymentId, "resources/Bpmn/Deployment/BpmnDeploymentTest.TestProcessDiagramResource.jpg");
            byte[]           diagramBytes  = IoUtil.ReadInputStream(diagramStream, "diagram stream");
            Assert.AreEqual(33343, diagramBytes.Length);
        }
示例#4
0
 private string ReadInputStreamToString(System.IO.Stream inputStream)
 {
     byte[] bytes = IoUtil.ReadInputStream(inputStream, "input stream");
     return(StringHelperClass.NewString(bytes));
 }