* Licensed 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.
} else {
className = nameOrContentType;
}
-
+
// No Void.class in aaf.v2_0 package causing errors when trying to use a newVoidv2_0
// method similar to others in this class. This makes it work, but is it right?
if ("Void".equals(className))
return "";
-
+
if ("1.1".equals(version)) {
version = "v1_0";
} else if (version!=null) {
} else {
version = "v2_0";
}
-
+
Class<?> cls=null;
- int minorIdx = version.indexOf('_');
- if(minorIdx<0) {
- throw new APIException("Invalid Interface Version " + version);
- }
- int minor = Integer.parseInt(version.substring(minorIdx+1));
- String vprefix=version.substring(0, minorIdx+1);
- while(cls==null && minor>=0) {
- try {
- cls = Examples.class.getClassLoader().loadClass("aaf."+vprefix+minor+'.'+className);
+ int minorIdx = version.indexOf('_');
+ if(minorIdx<0) {
+ throw new APIException("Invalid Interface Version " + version);
+ }
+ int minor = Integer.parseInt(version.substring(minorIdx+1));
+ String vprefix=version.substring(0, minorIdx+1);
+ while(cls==null && minor>=0) {
+ try {
+ cls = Examples.class.getClassLoader().loadClass("aaf."+vprefix+minor+'.'+className);
} catch (ClassNotFoundException e) {
- if(--minor<0) {
- throw new APIException("No Example for Version " + version + " found.");
- }
+ if(--minor<0) {
+ throw new APIException("No Example for Version " + version + " found.");
+ }
}
- }
-
+ }
+
+ if(cls==null) {
+ throw new APIException("ERROR: " + "aaf."+vprefix+"X not found.");
+ }
+
Method meth;
try {
meth = Examples.class.getDeclaredMethod("new"+cls.getSimpleName()+vprefix+minor,boolean.class);
} catch (Exception e) {
throw new APIException("ERROR: " + cls.getName() + " does not have an Example in Code. Request from AAF Developers");
}
-
+
RosettaDF<C> df = env.newDataFactory(cls);
df.option(Data.PRETTY);
-
+
Object data = meth.invoke(null,optional);
-
+
@SuppressWarnings("unchecked")
String rv = df.newData().load((C)data).out(type).asString();
// Object obj = df.newData().in(type).load(rv).asObject();
return rv;
}
-
+
/*
* Set Base Class Request (easier than coding over and over)
*/
gc.add(GregorianCalendar.MONTH, 6);
req.setEnd(Chrono.timeStamp(gc));
// req.setForce("false");
-
+
}
-
+
@SuppressWarnings("unused")
private static Request newRequestv2_0(boolean optional) {
Request r = new Request();
if (optional)setOptional(rpr);
return rpr;
}
-
+
@SuppressWarnings("unused")
private static Roles newRolesv2_0(boolean optional) {
Role r;
return rs;
}
-
-
+
+
@SuppressWarnings("unused")
private static PermRequest newPermRequestv2_0(boolean optional) {
PermRequest pr = new PermRequest();
pr.setAction("myAction");
if (optional) {
pr.setDescription("Short and meaningful verbiage about the Permission");
-
+
setOptional(pr);
}
return pr;
}
-
+
@SuppressWarnings("unused")
private static Perm newPermv2_0(boolean optional) {
Perm pr = new Perm();
pr.setAction("myAction");
return pr;
}
-
+
@SuppressWarnings("unused")
private static Perms newPermsv2_0(boolean optional) {
Perms perms = new Perms();
p.getRoles().add("org.osaaf.myns.myRole2");
return perms;
-
+
}
-
+
@SuppressWarnings("unused")
private static UserRoleRequest newUserRoleRequestv2_0(boolean optional) {
UserRoleRequest urr = new UserRoleRequest();
if (optional) setOptional(urr);
return urr;
}
-
+
@SuppressWarnings("unused")
private static NsRequest newNsRequestv2_0(boolean optional) {
NsRequest nr = new NsRequest();
nr.getResponsible().add("ab1234@people.osaaf.org");
nr.getResponsible().add("cd5678@people.osaaf.org");
nr.getAdmin().add("zy9876@people.osaaf.org");
- nr.getAdmin().add("xw5432@people.osaaf.org");
+ nr.getAdmin().add("xw5432@people.osaaf.org");
if (optional) {
nr.setDescription("This is my Namespace to set up");
nr.setType("APP");
}
return nr;
}
-
-
+
+
@SuppressWarnings("unused")
private static Nss newNssv2_0(boolean optional) {
Ns ns;
-
+
Nss nss = new Nss();
- nss.getNs().add(ns = new Nss.Ns());
+ ns = new Nss.Ns();
+ nss.getNs().add(ns);
ns.setName("org.osaaf.myns");
ns.getResponsible().add("ab1234@people.osaaf.org");
ns.getResponsible().add("cd5678@people.osaaf.org");
ns.getAdmin().add("zy9876@people.osaaf.org");
ns.getAdmin().add("xw5432@people.osaaf.org");
ns.setDescription("This is my Namespace to set up");
-
- nss.getNs().add(ns = new Nss.Ns());
+ ns = new Nss.Ns();
+ nss.getNs().add(ns);
ns.setName("org.osaaf.myOtherNs");
ns.getResponsible().add("ab1234@people.osaaf.org");
ns.getResponsible().add("cd5678@people.osaaf.org");
ns.getAdmin().add("zy9876@people.osaaf.org");
- ns.getAdmin().add("xw5432@people.osaaf.org");
-
+ ns.getAdmin().add("xw5432@people.osaaf.org");
+
return nss;
}
@SuppressWarnings("unused")
return cr;
}
-
+
@SuppressWarnings("unused")
private static Users newUsersv2_0(boolean optional) {
User user;
-
+
Users users = new Users();
user = new Users.User();
users.getUser().add(user);
- user.setId("ab1234@people.osaaf.org");
+ user.setId("ab1234@people.osaaf.org");
GregorianCalendar gc = new GregorianCalendar();
user.setExpires(Chrono.timeStamp(gc));
user = new Users.User();
users.getUser().add(user);
- user.setId("zy9876@people.osaaf.org");
- user.setExpires(Chrono.timeStamp(gc));
-
+ user.setId("zy9876@people.osaaf.org");
+ user.setExpires(Chrono.timeStamp(gc));
+
return users;
}
ur.setRole("com.test.myapp.myRole");
ur.setExpires(Chrono.timeStamp());
urs.getUserRole().add(ur);
-
+
ur = new UserRole();
ur.setUser("yx4321");
ur.setRole("com.test.yourapp.yourRole");
return a;
}
-
+
@SuppressWarnings("unused")
private static aaf.v2_0.Error newErrorv2_0(boolean optional) {