use of org.apache.syncope.common.lib.to.CamelRouteTO in project syncope by apache.
the class CamelRouteITCase method doUpdate.
private CamelRouteTO doUpdate(final AnyTypeKind anyTypeKind, final String key, final String content) {
CamelRouteTO route = camelRouteService.read(anyTypeKind, key);
route.setContent(content);
camelRouteService.update(anyTypeKind, route);
// getting new route definition
return camelRouteService.read(anyTypeKind, key);
}
use of org.apache.syncope.common.lib.to.CamelRouteTO in project syncope by apache.
the class CamelRouteDataBinderImpl method getRouteTO.
@Override
public CamelRouteTO getRouteTO(final CamelRoute route) {
CamelRouteTO routeTO = new CamelRouteTO();
BeanUtils.copyProperties(route, routeTO);
return routeTO;
}
use of org.apache.syncope.common.lib.to.CamelRouteTO in project syncope by apache.
the class CamelRouteITCase method scriptingUpdate.
@Test
public void scriptingUpdate() {
assumeTrue(CamelDetector.isCamelEnabledForUsers(syncopeService));
CamelRouteTO oldRoute = camelRouteService.read(AnyTypeKind.USER, "createUser");
// updating route content including new attribute management
String routeContent = "" + " <route id=\"createUser\">\n" + " <from uri=\"direct:createUser\"/>\n" + " <setProperty propertyName=\"actual\">\n" + " <simple>${body}</simple>\n" + " </setProperty>\n" + " <setBody>\n" + " <groovy>\n" + "request.body.getPlainAttr(\"camelAttribute\").get().getValues().set(0,\"true\")\n" + " return request.body\n" + " </groovy>\n" + " </setBody>\n" + " <doTry>\n" + " <bean ref=\"uwfAdapter\" method=\"create(${body},${property.disablePwdPolicyCheck},\n" + " ${property.enabled},${property.storePassword})\"/>\n" + " <to uri=\"propagate:create?anyTypeKind=USER\"/>\n" + " <to uri=\"direct:createPort\"/>\n" + " <doCatch> \n" + " <exception>java.lang.RuntimeException</exception>\n" + " <handled>\n" + " <constant>false</constant>\n" + " </handled>\n" + " <to uri=\"direct:createPort\"/>\n" + " </doCatch>\n" + " </doTry>\n" + " </route> ";
try {
doUpdate(AnyTypeKind.USER, "createUser", routeContent);
// creating new schema attribute for user
PlainSchemaTO schemaTO = new PlainSchemaTO();
schemaTO.setKey("camelAttribute");
schemaTO.setType(AttrSchemaType.String);
createSchema(SchemaType.PLAIN, schemaTO);
AnyTypeClassTO typeClass = new AnyTypeClassTO();
typeClass.setKey("camelAttribute");
typeClass.getPlainSchemas().add(schemaTO.getKey());
anyTypeClassService.create(typeClass);
UserTO userTO = new UserTO();
userTO.setRealm(SyncopeConstants.ROOT_REALM);
userTO.getAuxClasses().add(typeClass.getKey());
String userId = getUUIDString() + "camelUser@syncope.apache.org";
userTO.setUsername(userId);
userTO.setPassword("password123");
userTO.getPlainAttrs().add(attrTO("userId", userId));
userTO.getPlainAttrs().add(attrTO("fullname", userId));
userTO.getPlainAttrs().add(attrTO("surname", userId));
userTO.getPlainAttrs().add(attrTO("camelAttribute", "false"));
userTO = createUser(userTO).getEntity();
assertNotNull(userTO);
assertEquals("true", userTO.getPlainAttr("camelAttribute").get().getValues().get(0));
} finally {
doUpdate(AnyTypeKind.USER, oldRoute.getKey(), oldRoute.getContent());
}
}
use of org.apache.syncope.common.lib.to.CamelRouteTO in project syncope by apache.
the class CamelRouteITCase method issueSYNCOPE931.
@Test
public void issueSYNCOPE931() {
assumeTrue(CamelDetector.isCamelEnabledForUsers(syncopeService));
CamelRouteTO oldRoute = camelRouteService.read(AnyTypeKind.USER, "createUser");
assertNotNull(oldRoute);
String routeContent = "<route id=\"createUser\">\n" + " <from uri=\"direct:createUser\"/>\n" + " <setProperty propertyName=\"actual\">\n" + " <simple>${body}</simple>\n" + " </setProperty>\n" + " <doTry>\n" + " <bean ref=\"uwfAdapter\" method=\"create(${body},${property.disablePwdPolicyCheck},\n" + " ${property.enabled},${property.storePassword})\"/>\n" + " <to uri=\"propagate:create123?anyTypeKind=USER\"/>\n" + " <to uri=\"direct:createPort\"/>\n" + " <to uri=\"log:myLog\"/>\n" + " <doCatch> \n" + " <exception>java.lang.RuntimeException</exception>\n" + " <handled>\n" + " <constant>false</constant>\n" + " </handled>\n" + " <to uri=\"direct:createPort\"/>\n" + " </doCatch>\n" + " </doTry>\n" + "</route>";
// Try to update a route with an incorrect propagation type
try {
doUpdate(AnyTypeKind.USER, "createUser", routeContent);
fail("Error expected on an incorrect propagation type");
} catch (Exception ex) {
// Expected
}
// Now update the route again with the correct propagation type
routeContent = routeContent.replaceFirst("create123", "create");
try {
CamelRouteTO route = doUpdate(AnyTypeKind.USER, "createUser", routeContent);
assertEquals(routeContent, route.getContent());
} finally {
doUpdate(AnyTypeKind.USER, oldRoute.getKey(), oldRoute.getContent());
}
}
use of org.apache.syncope.common.lib.to.CamelRouteTO in project syncope by apache.
the class CamelRouteITCase method update.
@Test
public void update() {
assumeTrue(CamelDetector.isCamelEnabledForUsers(syncopeService));
CamelRouteTO oldRoute = camelRouteService.read(AnyTypeKind.USER, "createUser");
assertNotNull(oldRoute);
String routeContent = "<route id=\"createUser\">\n" + " <from uri=\"direct:createUser\"/>\n" + " <setProperty propertyName=\"actual\">\n" + " <simple>${body}</simple>\n" + " </setProperty>\n" + " <doTry>\n" + " <bean ref=\"uwfAdapter\" method=\"create(${body},${property.disablePwdPolicyCheck},\n" + " ${property.enabled},${property.storePassword})\"/>\n" + " <to uri=\"propagate:create?anyTypeKind=USER\"/>\n" + " <to uri=\"direct:createPort\"/>\n" + " <to uri=\"log:myLog\"/>\n" + " <doCatch> \n" + " <exception>java.lang.RuntimeException</exception>\n" + " <handled>\n" + " <constant>false</constant>\n" + " </handled>\n" + " <to uri=\"direct:createPort\"/>\n" + " </doCatch>\n" + " </doTry>\n" + "</route>";
try {
CamelRouteTO route = doUpdate(AnyTypeKind.USER, "createUser", routeContent);
assertEquals(routeContent, route.getContent());
} finally {
doUpdate(AnyTypeKind.USER, oldRoute.getKey(), oldRoute.getContent());
}
}
Aggregations