Ejemplo n.º 1
0
  /** @param userPath */
  public static String formatUrl(String userPath) {

    ManagementContainer mc = ManagementContainer.getInstance();
    String prefix = mc.getClientSupportManager().getUrlPrefix();
    StringBuilder sb = new StringBuilder(80);
    sb.append(prefix);
    sb.append(userPath);
    return sb.toString();
  }
Ejemplo n.º 2
0
 protected static void logPoliciesUsingRemovedTopologyObjs(
     String operation,
     String topologyType,
     Collection<Integer> deletedNodes,
     final String constraintName,
     Connection c)
     throws SQLException {
   String query =
       "select sets.customer_id, p.policy_name, pc.policy_id, sets.user_set_id, sets.constraint_value "
           + " from policies p, policy_criteria pc, dat_saved_user_sets sets "
           + " where sets.constraint_name = "
           + QueryUtils.literal(constraintName)
           + " and "
           + QueryUtils.dbCast("sets.constraint_value", QueryUtils.CastType.INTEGER)
           + " in "
           + QueryUtils.literal(deletedNodes)
           + " and sets.user_set_id = pc.userset_id and pc.policy_id = p.policy_id";
   s_logger.debug(query);
   Statement s = null;
   ResultSet rs = null;
   try {
     s = c.createStatement();
     rs = s.executeQuery(query);
     while (rs.next()) {
       int custID = rs.getInt(1);
       String policyName = rs.getString(2);
       int policyID = rs.getInt(3);
       int userSetID = rs.getInt(4);
       int nodeID = rs.getInt(5);
       StringBuilder bld =
           new StringBuilder(operation)
               .append(" ")
               .append(topologyType)
               .append(" ")
               .append(nodeID)
               .append(" which is refered to by userset ")
               .append(userSetID)
               .append(" in policy ")
               .append(policyName)
               .append(" with id ")
               .append(policyID)
               .append(" for customer ")
               .append(custID);
       s_logger.warn(bld.toString());
     }
   } finally {
     if (s != null) s.close();
     if (rs != null) rs.close();
   }
 }
Ejemplo n.º 3
0
  @SuppressWarnings("unchecked")
  @Test
  public void testAppendConstraints() throws Exception {
    CustomerDAO dao =
        EasyMock.createMockBuilder(CustomerDAO.class)
            .addMockedMethod("appendDomainConstraint")
            .addMockedMethod("appendCloudServiceGuidConstraint")
            .addMockedMethod("appendCustomerPrefixConstraint")
            .addMockedMethod("appendUserStateConstraint")
            .createStrictMock();
    List<SearchConstraint> constraints = new LinkedList<SearchConstraint>();

    // domain constraint
    SearchConstraint sc =
        new SearchConstraint(
            ICustomerService.PROP_DOMAINS, SearchConstraintOperator.CONSTRAINT_EQUALS, "blah");
    constraints.add(sc);
    EasyMock.expect(dao.appendDomainConstraint(EasyMock.eq(sc))).andReturn("a");

    // cloud service guid
    sc =
        new SearchConstraint(
            ICustomerService.PROP_CLOUD_SERVICE_GUID,
            SearchConstraintOperator.CONSTRAINT_EQUALS,
            "blah");
    constraints.add(sc);
    EasyMock.expect(dao.appendCloudServiceGuidConstraint(EasyMock.eq(sc))).andReturn("b");
    sc =
        new SearchConstraint(
            ICustomerService.PROP_CLOUD_SERVICE_ANY_GUID,
            SearchConstraintOperator.CONSTRAINT_EQUALS,
            "blah");
    constraints.add(sc);
    EasyMock.expect(dao.appendCloudServiceGuidConstraint(EasyMock.eq(sc))).andReturn("c");

    // customer prefix
    sc =
        new SearchConstraint(
            ICustomerService.PROP_CUST_CAPABILITY_PREFIX,
            SearchConstraintOperator.CONSTRAINT_EQUALS,
            "blah");
    constraints.add(sc);
    dao.appendCustomerPrefixConstraint(EasyMock.eq(sc), EasyMock.isA(StringBuffer.class));
    EasyMock.expectLastCall();

    // users in state
    sc =
        new SearchConstraint(
            ICustomerService.PROP_USERS_IN_STATE,
            SearchConstraintOperator.CONSTRAINT_EQUALS,
            "blah");
    constraints.add(sc);
    EasyMock.expect(dao.appendUserStateConstraint(EasyMock.eq(sc))).andReturn("d");

    // users NOT in state
    sc =
        new SearchConstraint(
            ICustomerService.PROP_NO_USERS_IN_STATE,
            SearchConstraintOperator.CONSTRAINT_EQUALS,
            "blah");
    constraints.add(sc);
    EasyMock.expect(dao.appendUserStateConstraint(EasyMock.eq(sc))).andReturn("e");

    StringBuilder whereClause = new StringBuilder();
    EasyMock.replay(dao);
    dao.appendConstraints(constraints, whereClause);
    EasyMock.verify(dao);

    String expected = " and (a) and (b) and (c) and (not )";
    assertEquals("Wrong where clause returned.", expected, whereClause.toString());
  }