Search in sources :

Example 1 with CamelRouteTO

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);
}
Also used : CamelRouteTO(org.apache.syncope.common.lib.to.CamelRouteTO)

Example 2 with CamelRouteTO

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;
}
Also used : CamelRouteTO(org.apache.syncope.common.lib.to.CamelRouteTO)

Example 3 with CamelRouteTO

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());
    }
}
Also used : PlainSchemaTO(org.apache.syncope.common.lib.to.PlainSchemaTO) UserTO(org.apache.syncope.common.lib.to.UserTO) CamelRouteTO(org.apache.syncope.common.lib.to.CamelRouteTO) AnyTypeClassTO(org.apache.syncope.common.lib.to.AnyTypeClassTO) Test(org.junit.jupiter.api.Test)

Example 4 with CamelRouteTO

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());
    }
}
Also used : CamelRouteTO(org.apache.syncope.common.lib.to.CamelRouteTO) Test(org.junit.jupiter.api.Test)

Example 5 with CamelRouteTO

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());
    }
}
Also used : CamelRouteTO(org.apache.syncope.common.lib.to.CamelRouteTO) Test(org.junit.jupiter.api.Test)

Aggregations

CamelRouteTO (org.apache.syncope.common.lib.to.CamelRouteTO)5 Test (org.junit.jupiter.api.Test)3 AnyTypeClassTO (org.apache.syncope.common.lib.to.AnyTypeClassTO)1 PlainSchemaTO (org.apache.syncope.common.lib.to.PlainSchemaTO)1 UserTO (org.apache.syncope.common.lib.to.UserTO)1