当前位置: 首页>>代码示例>>Java>>正文


Java ADMValidator类代码示例

本文整理汇总了Java中org.oscm.validator.ADMValidator的典型用法代码示例。如果您正苦于以下问题:Java ADMValidator类的具体用法?Java ADMValidator怎么用?Java ADMValidator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ADMValidator类属于org.oscm.validator包,在下文中一共展示了ADMValidator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toUserGroup_tooLongDescription

import org.oscm.validator.ADMValidator; //导入依赖的package包/类
@Test
public void toUserGroup_tooLongDescription() throws Exception {
    // given
    POUserGroup poUserGroup = new POUserGroup();
    poUserGroup.setGroupName("Group name");
    poUserGroup
            .setGroupDescription(longText(ADMValidator.LENGTH_DESCRIPTION + 1));
    // when
    try {
        POUserGroupAssembler.toUserGroup(poUserGroup);
        fail("ValidationException expected");
    } catch (ValidationException ve) {
        // then
        assertEquals("Wrong reason", ReasonEnum.LENGTH, ve.getReason());
        assertEquals("Wrong parameter", "groupDescription", ve.getMember());
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:18,代码来源:POUserGroupAssemblerTest.java

示例2: toUserGroup_tooLongReferenceId

import org.oscm.validator.ADMValidator; //导入依赖的package包/类
@Test
public void toUserGroup_tooLongReferenceId() throws Exception {
    // given
    POUserGroup poUserGroup = new POUserGroup();
    poUserGroup.setGroupName("Group name");
    poUserGroup
            .setGroupReferenceId(longText(ADMValidator.LENGTH_DESCRIPTION + 1));

    // when
    try {
        POUserGroupAssembler.toUserGroup(poUserGroup);
        fail("ValidationException expected");
    } catch (ValidationException ve) {
        // then
        assertEquals("Wrong reason", ReasonEnum.LENGTH, ve.getReason());
        assertEquals("Wrong parameter", "groupReferenceId", ve.getMember());
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:19,代码来源:POUserGroupAssemblerTest.java

示例3: testToTagsMaxLength

import org.oscm.validator.ADMValidator; //导入依赖的package包/类
@Test(expected = ValidationException.class)
public void testToTagsMaxLength() throws Exception {
    List<String> tags = new ArrayList<String>();
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < ADMValidator.LENGTH_TAG + 1; i++)
        sb.append('x');
    tags.add(sb.toString());
    try {
        TagAssembler.toTags(tags, "en");
    } catch (ValidationException e) {
        assertEquals(ReasonEnum.LENGTH, e.getReason());
        assertEquals("value", e.getMember());
        assertEquals(Integer.valueOf(ADMValidator.LENGTH_TAG).toString(),
                e.getMessageParams()[1]);
        throw e;
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:18,代码来源:TagAssemblerTest.java

示例4: doTestModify

import org.oscm.validator.ADMValidator; //导入依赖的package包/类
private void doTestModify(boolean isValidDesc) {
    UserGroup oldUserGroup = (UserGroup) domObjects.get(0);
    assertNotNull("Old UserGroup expected", oldUserGroup);
    UserGroup userGroup = mgr.find(UserGroup.class, oldUserGroup.getKey());
    assertNotNull("UserGroup expected", userGroup);

    if (isValidDesc) {
        userGroup.setDescription("1234567890#new#");
    } else {
        String testString = fillString('x', ADMValidator.LENGTH_USERID + 1);
        userGroup.setDescription(testString);
    }

    domObjects.clear();
    domObjects.add((UserGroup) ReflectiveClone.clone(userGroup));
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:17,代码来源:UserGroupIT.java

示例5: getSubscriptionUrl

import org.oscm.validator.ADMValidator; //导入依赖的package包/类
/**
 * Gets the URL to access the subscription.
 * 
 * @param subscription
 *            the subscription for which we want to know the URL
 * @return the URL to access the subscription
 */
String getSubscriptionUrl(Subscription subscription) {
    StringBuilder url = new StringBuilder();
    String baseUrl = cfgService.getBaseURL();
    String technicalProductBaseUrl = subscription.getProduct()
            .getTechnicalProduct().getBaseURL();

    if (ADMValidator.isHttpsScheme(technicalProductBaseUrl)) {
        baseUrl = cfgService
                .getConfigurationSetting(ConfigurationKey.BASE_URL_HTTPS,
                        Configuration.GLOBAL_CONTEXT)
                .getValue();
    }

    url.append(baseUrl);
    if (url.length() == 0 || url.charAt(url.length() - 1) != '/') {
        url.append('/');
    }
    url.append("opt/");
    url.append(Long.toHexString(subscription.getKey()));
    url.append('/');
    return url.toString();
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:30,代码来源:SubscriptionServiceBean.java

示例6: validate

import org.oscm.validator.ADMValidator; //导入依赖的package包/类
/**
 * Validates that the given value is a relative or absolute URL
 * 
 * @param context
 *            FacesContext for the request we are processing
 * @param component
 *            UIComponent we are checking for correctness
 * @param value
 *            the value to validate
 * @throws ValidatorException
 *             if validation fails
 */
public void validate(FacesContext facesContext, UIComponent component,
        Object value) throws ValidatorException {
    if (value == null) {
        return;
    }
    String str = value.toString();
    if (str.length() == 0) {
        return;
    }

    if (ADMValidator.isAbsoluteOrRelativeUrl(str)) {
        return;
    }
    Object[] args = null;
    String label = JSFUtils.getLabel(component);
    if (label != null) {
        args = new Object[] { label };
    }
    ValidationException e = new ValidationException(
            ValidationException.ReasonEnum.URL, label, null);
    String text = JSFUtils.getText(e.getMessageKey(), args, facesContext);
    throw new ValidatorException(new FacesMessage(
            FacesMessage.SEVERITY_ERROR, text, null));
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:37,代码来源:AbsOrRelUrlValidator.java

示例7: validate

import org.oscm.validator.ADMValidator; //导入依赖的package包/类
/**
 * Validates that the given value is an URL
 * 
 * @param context
 *            FacesContext for the request we are processing
 * @param component
 *            UIComponent we are checking for correctness
 * @param value
 *            the value to validate
 * @throws ValidatorException
 *             if validation fails
 */
public void validate(FacesContext facesContext, UIComponent component,
        Object value) throws ValidatorException {
    if (value == null) {
        return;
    }
    String str = value.toString();
    if (str.length() == 0) {
        return;
    }

    if (ADMValidator.isUrl(str)) {
        return;
    }
    Object[] args = null;
    String label = JSFUtils.getLabel(component);
    if (label != null) {
        args = new Object[] { label };
    }
    ValidationException e = new ValidationException(
            ValidationException.ReasonEnum.URL, label, null);
    String text = JSFUtils.getText(e.getMessageKey(), args, facesContext);
    throw new ValidatorException(new FacesMessage(
            FacesMessage.SEVERITY_ERROR, text, null));
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:37,代码来源:UrlValidator.java

示例8: validate

import org.oscm.validator.ADMValidator; //导入依赖的package包/类
/**
 * Validates that the given value contains an email address.
 * 
 * @param context
 *            FacesContext for the request we are processing
 * @param component
 *            UIComponent we are checking for correctness
 * @param value
 *            the value to validate
 * @throws ValidatorException
 *             if validation fails
 */
public void validate(FacesContext facesContext, UIComponent component,
        Object value) throws ValidatorException {
    if (value == null) {
        return;
    }
    String email = value.toString();
    if (email.length() == 0) {
        return;
    }
    if (!ADMValidator.isEmail(email)) {
        Object[] args = null;
        String label = JSFUtils.getLabel(component);
        if (label != null) {
            args = new Object[] { label };
        }
        ValidationException e = new ValidationException(
                ValidationException.ReasonEnum.EMAIL, label, null);
        String text = JSFUtils.getText(e.getMessageKey(), args,
                facesContext);
        throw new ValidatorException(new FacesMessage(
                FacesMessage.SEVERITY_ERROR, text, null));
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:36,代码来源:EmailValidator.java

示例9: generateNewId

import org.oscm.validator.ADMValidator; //导入依赖的package包/类
/**
 * Generates a new id based on the set prefix and base id excluding the ones
 * in the exclude set. The schema is
 * &lt;prefix&gt;&lt;baseId&gt;[(&lt;n&gt;)] where n is a number from 2 up
 * to {@link Short#MAX_VALUE}, The number will only be appended if the value
 * without brackets and number is excluded. The result will be trimmed to
 * match the restrictions for id constraints.
 * 
 * @return the generated id
 */
public String generateNewId() {
    String temp = (prefix + baseId).trim();
    if (temp.length() > ADMValidator.LENGTH_ID) {
        temp = temp.substring(0, ADMValidator.LENGTH_ID);
    }
    String template = temp + "%s";
    if (temp.length() > (ADMValidator.LENGTH_ID - 7)) {
        template = template.substring(0, ADMValidator.LENGTH_ID - 7) + "%s";
    }
    for (int index = 2; index < Short.MAX_VALUE
            && excludedIds.contains(temp); index++) {
        temp = String.format(template, "(" + index + ")");
    }
    return temp;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:26,代码来源:IdGenerator.java

示例10: getAccessUrl

import org.oscm.validator.ADMValidator; //导入依赖的package包/类
/**
 * Gets the URL to access a subscribed service.
 *
 * @param subscription
 * @return
 */
protected String getAccessUrl(POSubscription subscription) {
    if (subscription.getServiceAccessType() == ServiceAccessType.USER
            || subscription.getServiceAccessType() == ServiceAccessType.DIRECT) {
        if (subscription.getServiceBaseURL() == null) {
            return "";
        }

        return subscription.getServiceBaseURL();
    } else {
        String serviceBaseUrl = subscription.getServiceBaseURL();
        String serverBaseUrl;
        if (ADMValidator.isHttpsScheme(serviceBaseUrl)) {
            serverBaseUrl = applicationBean.getServerBaseUrlHttps();
        } else {
            serverBaseUrl = applicationBean.getServerBaseUrl();
        }

        return ADMStringUtils.removeEndingSlash(serverBaseUrl)
                + Constants.SERVICE_BASE_URI + "/"
                + subscription.getHexKey() + "/";
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:29,代码来源:MySubscriptionsLazyDataModel.java

示例11: getAccessUrl

import org.oscm.validator.ADMValidator; //导入依赖的package包/类
String getAccessUrl(POLandingpageEntry entry) {
    if (entry.getServiceAccessType() == ServiceAccessType.USER
            || entry.getServiceAccessType() == ServiceAccessType.DIRECT) {
        return entry.getServiceAccessURL();
    } else {
        String serviceBaseUrl = entry.getServiceAccessURL();
        String serverBaseUrl;
        if (ADMValidator.isHttpsScheme(serviceBaseUrl)) {
            serverBaseUrl = getApplicationBean().getServerBaseUrlHttps();
        } else {
            serverBaseUrl = getApplicationBean().getServerBaseUrl();
        }

        return ADMStringUtils.removeEndingSlash(serverBaseUrl)
                + Constants.SERVICE_BASE_URI + "/"
                + Long.toHexString(entry.getSubscriptionKey()) + "/";
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:19,代码来源:EnterpriseLandingpageCtrl.java

示例12: validateImprint

import org.oscm.validator.ADMValidator; //导入依赖的package包/类
public void validateImprint(final FacesContext context,
        final UIComponent component, final Object valueObj) {

    // skip if no value
    if (valueObj == null) {
        return;
    }
    String value = valueObj.toString();
    if (value.length() == 0) {
        return;
    }

    // the imprint value must contain a valid URL or a default text
    if (ADMValidator.isUrl(value)) {
        return;
    }
    if (checkIfDefaultText(value)) {
        return;
    }

    // validation failed
    throw constructValidatorException(context, component);
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:24,代码来源:TranslationBean.java

示例13: validate

import org.oscm.validator.ADMValidator; //导入依赖的package包/类
@Override
public void validate(Object obj) throws ValidationException {
    super.validate(obj);
    VOParameter parameter = (VOParameter) obj;

    if(isOptionalAndNullOrEmpty(parameter)) {
        return;
    }
    
    if (!ADMValidator.isBoolean(parameter.getValue())) {
        throw new ValidationException(
                ValidationException.ReasonEnum.BOOLEAN, null,
                new Object[] { parameter.getParameterDefinition()
                        .getParameterId() });
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:17,代码来源:BooleanParameterValidator.java

示例14: getSubscriptionUrl

import org.oscm.validator.ADMValidator; //导入依赖的package包/类
/**
 * Gets the URL to access the subscription.
 * 
 * @param subscription
 *            the subscription for which we want to know the URL
 * @return the URL to access the subscription
 */
String getSubscriptionUrl(Subscription subscription) {
    StringBuffer url = new StringBuffer();
    String baseUrl = serviceFacade.getConfigurationService().getBaseURL();
    String technicalProductBaseUrl = subscription.getProduct()
            .getTechnicalProduct().getBaseURL();

    if (ADMValidator.isHttpsScheme(technicalProductBaseUrl)) {
        baseUrl = serviceFacade
                .getConfigurationService()
                .getConfigurationSetting(ConfigurationKey.BASE_URL_HTTPS,
                        Configuration.GLOBAL_CONTEXT).getValue();
    }

    url.append(baseUrl);
    if (url.length() == 0 || url.charAt(url.length() - 1) != '/') {
        url.append('/');
    }
    url.append("opt/");
    url.append(Long.toHexString(subscription.getKey()));
    url.append('/');
    return url.toString();
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:30,代码来源:NotifyProvisioningServiceHandler.java

示例15: generateNewId_Service_CopyCopyToLong

import org.oscm.validator.ADMValidator; //导入依赖的package包/类
@Test
public void generateNewId_Service_CopyCopyToLong() throws Exception {
    String baseId = BaseAdmUmTest.TOO_LONG_ID;
    sd.setServiceId(baseId);
    gen = new IdGenerator(COPY_OF_PREFIX, sd, services);

    String expected = (COPY_OF_PREFIX + baseId).substring(0,
            ADMValidator.LENGTH_ID);
    String genId = gen.generateNewId();
    assertEquals(expected, genId);

    sd.setServiceId(genId);
    gen = new IdGenerator(COPY_OF_PREFIX, sd, excludeService(genId,
            services));
    expected = (COPY_OF_PREFIX + COPY_OF_PREFIX + baseId).substring(0,
            ADMValidator.LENGTH_ID);
    genId = gen.generateNewId();
    assertEquals(expected, genId);
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:20,代码来源:IdGeneratorTest.java


注:本文中的org.oscm.validator.ADMValidator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。