Author: virag
Date: Fri Apr 19 22:11:58 2013
New Revision: 1470063

URL: http://svn.apache.org/r1470063
Log:
OOZIE-1331 URIHandlerService not allowing relative path for URI's (virag)

Added:
    
oozie/branches/branch-4.0/core/src/test/resources/coord-job-for-matd-relative.xml
Modified:
    
oozie/branches/branch-4.0/core/src/main/java/org/apache/oozie/service/URIHandlerService.java
    
oozie/branches/branch-4.0/core/src/test/java/org/apache/oozie/command/coord/TestCoordMaterializeTransitionXCommand.java
    
oozie/branches/branch-4.0/core/src/test/java/org/apache/oozie/dependency/TestURIHandlerService.java
    oozie/branches/branch-4.0/release-log.txt

Modified: 
oozie/branches/branch-4.0/core/src/main/java/org/apache/oozie/service/URIHandlerService.java
URL: 
http://svn.apache.org/viewvc/oozie/branches/branch-4.0/core/src/main/java/org/apache/oozie/service/URIHandlerService.java?rev=1470063&r1=1470062&r2=1470063&view=diff
==============================================================================
--- 
oozie/branches/branch-4.0/core/src/main/java/org/apache/oozie/service/URIHandlerService.java
 (original)
+++ 
oozie/branches/branch-4.0/core/src/main/java/org/apache/oozie/service/URIHandlerService.java
 Fri Apr 19 22:11:58 2013
@@ -196,10 +196,11 @@ public class URIHandlerService implement
      */
     public URI getAuthorityWithScheme(String uri) throws URIHandlerException {
         int index = uri.indexOf("://");
-        if (index == -1) {
-            throw new URIHandlerException(ErrorCode.E0905, uri);
-        }
         try {
+            if (index == -1) {
+                LOG.trace("Relative path for uri-template "+uri);
+                return new URI("/");
+            }
             if (uri.indexOf(":///") != -1) {
                 return new URI(uri.substring(0, index + 4));
             }

Modified: 
oozie/branches/branch-4.0/core/src/test/java/org/apache/oozie/command/coord/TestCoordMaterializeTransitionXCommand.java
URL: 
http://svn.apache.org/viewvc/oozie/branches/branch-4.0/core/src/test/java/org/apache/oozie/command/coord/TestCoordMaterializeTransitionXCommand.java?rev=1470063&r1=1470062&r2=1470063&view=diff
==============================================================================
--- 
oozie/branches/branch-4.0/core/src/test/java/org/apache/oozie/command/coord/TestCoordMaterializeTransitionXCommand.java
 (original)
+++ 
oozie/branches/branch-4.0/core/src/test/java/org/apache/oozie/command/coord/TestCoordMaterializeTransitionXCommand.java
 Fri Apr 19 22:11:58 2013
@@ -103,6 +103,14 @@ public class TestCoordMaterializeTransit
         }
     }
 
+    public void testActionMaterForHcatalogRelativePath() throws Exception {
+        Date startTime = DateUtils.parseDateOozieTZ("2009-03-06T010:00Z");
+        Date endTime = DateUtils.parseDateOozieTZ("2009-03-11T10:00Z");
+        CoordinatorJobBean job = 
addRecordToCoordJobTableForWaiting("coord-job-for-matd-relative.xml",
+                CoordinatorJob.Status.RUNNING, startTime, endTime, false, 
false, 0);
+        new CoordMaterializeTransitionXCommand(job.getId(), 3600).call();
+    }
+
     public void testActionMaterWithPauseTime1() throws Exception {
         Date startTime = DateUtils.parseDateOozieTZ("2009-03-06T10:00Z");
         Date endTime = DateUtils.parseDateOozieTZ("2009-03-06T10:14Z");

Modified: 
oozie/branches/branch-4.0/core/src/test/java/org/apache/oozie/dependency/TestURIHandlerService.java
URL: 
http://svn.apache.org/viewvc/oozie/branches/branch-4.0/core/src/test/java/org/apache/oozie/dependency/TestURIHandlerService.java?rev=1470063&r1=1470062&r2=1470063&view=diff
==============================================================================
--- 
oozie/branches/branch-4.0/core/src/test/java/org/apache/oozie/dependency/TestURIHandlerService.java
 (original)
+++ 
oozie/branches/branch-4.0/core/src/test/java/org/apache/oozie/dependency/TestURIHandlerService.java
 Fri Apr 19 22:11:58 2013
@@ -17,16 +17,30 @@
  */
 package org.apache.oozie.dependency;
 
-import static org.junit.Assert.assertEquals;
-
 import java.net.URI;
 
-import org.apache.oozie.ErrorCode;
+import org.apache.oozie.service.Services;
 import org.apache.oozie.service.URIHandlerService;
-import org.junit.Assert;
+import org.apache.oozie.test.XTestCase;
 import org.junit.Test;
 
-public class TestURIHandlerService {
+public class TestURIHandlerService extends XTestCase {
+
+    private Services services;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        services = new Services();
+        services.init();
+
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        services.destroy();
+        super.tearDown();
+    }
 
     @Test
     public void testGetAuthorityWithScheme() throws Exception {
@@ -41,14 +55,16 @@ public class TestURIHandlerService {
         assertEquals("hdfs:///", uri.toString());
         uri = uriService.getAuthorityWithScheme("hdfs:///tmp/file");
         assertEquals("hdfs:///", uri.toString());
+        uri = uriService.getAuthorityWithScheme("/tmp/file");
+        assertEquals("/", uri.toString());
+    }
 
-        try {
-            uri = uriService.getAuthorityWithScheme("/tmp/file");
-            Assert.fail();
-        }
-        catch (URIHandlerException e) {
-            assertEquals(ErrorCode.E0905, e.getErrorCode());
-        }
+    @Test
+    public void testGetURIHandler() throws Exception {
+        URIHandlerService uriService = services.get(URIHandlerService.class);
+        URI uri = uriService.getAuthorityWithScheme("/tmp/file");
+        URIHandler uriHandler = uriService.getURIHandler(uri);
+        assertTrue(uriHandler instanceof FSURIHandler);
     }
 
 }

Added: 
oozie/branches/branch-4.0/core/src/test/resources/coord-job-for-matd-relative.xml
URL: 
http://svn.apache.org/viewvc/oozie/branches/branch-4.0/core/src/test/resources/coord-job-for-matd-relative.xml?rev=1470063&view=auto
==============================================================================
--- 
oozie/branches/branch-4.0/core/src/test/resources/coord-job-for-matd-relative.xml
 (added)
+++ 
oozie/branches/branch-4.0/core/src/test/resources/coord-job-for-matd-relative.xml
 Fri Apr 19 22:11:58 2013
@@ -0,0 +1,41 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<coordinator-app xmlns='uri:oozie:coordinator:0.2' name='NAME'
+frequency="1" start='2009-02-01T01:00Z' end='2009-02-03T23:59Z'
+timezone='UTC' freq_timeunit='DAY' end_of_duration='NONE'>
+    <controls>
+        <timeout>10</timeout>
+        <concurrency>2</concurrency>
+        <execution>LIFO</execution>
+    </controls>
+    <input-events>
+        <data-in name='D' dataset='d'>
+        <dataset name='d' frequency='7' initial-instance='2009-01-01T01:00Z'
+            timezone='UTC' freq_timeunit='DAY' end_of_duration='NONE'>
+            <uri-template>user/abc/${YEAR}/${MONTH}</uri-template>
+        </dataset>
+        <instance>${coord:current(0)}</instance>
+        </data-in>
+        </input-events>
+
+        <action>
+            <workflow>
+                <app-path>hdfs:///tmp/workflows/</app-path>
+            </workflow>
+        </action>
+</coordinator-app>

Modified: oozie/branches/branch-4.0/release-log.txt
URL: 
http://svn.apache.org/viewvc/oozie/branches/branch-4.0/release-log.txt?rev=1470063&r1=1470062&r2=1470063&view=diff
==============================================================================
--- oozie/branches/branch-4.0/release-log.txt (original)
+++ oozie/branches/branch-4.0/release-log.txt Fri Apr 19 22:11:58 2013
@@ -1,5 +1,6 @@
 -- Oozie 4.0.0 (unreleased)
 
+OOZIE-1331 URIHandlerService not allowing relative path for URI's (virag)
 OOZIE-1332 Flakey test 
TestActionCheckXCommand.testActionCheckTransientDuringMRAction (rkanter)
 OOZIE-1150 DB upgrade scripts for hcat changes (ryota via virag)
 OOZIE-1323 HTTPS docs lists the same step twice for creating a self-signed 
certificate (rkanter)


Reply via email to