private static void assertValidName(String name) { // use the same check as used on datasets when they're created, since the output name can be any dataset name Preconditions.checkArgument(EntityId.isValidId(name), "Name '%s' must consist only of ASCII letters, numbers, _, or -.", name); }
private static void assertValidName(String name) { // use the same check as used on datasets when they're created, since the output name can be any dataset name Preconditions.checkArgument(EntityId.isValidId(name), "Name '%s' must consist only of ASCII letters, numbers, _, or -.", name); }
public static void ensureValidId(String propertyName, String name) { if (!isValidId(name)) { throw new IllegalArgumentException(String.format("Invalid %s ID: %s. Should only contain alphanumeric " + "characters and _ or -.", propertyName, name)); } }
public static void ensureValidId(String propertyName, String name) { if (!isValidId(name)) { throw new IllegalArgumentException(String.format("Invalid %s ID: %s. Should only contain alphanumeric " + "characters and _ or -.", propertyName, name)); } }
@Override public VerifyResult verify(ApplicationId appId, T input) { // Checks if DataSet name is an ID String name = getName(input); if (!EntityId.isValidId(name)) { return VerifyResult.failure(Err.NOT_AN_ID, name); } return VerifyResult.success(); } protected abstract String getName(T input);
@Override public VerifyResult verify(ApplicationId appId, T input) { // Checks if DataSet name is an ID String name = getName(input); if (!EntityId.isValidId(name)) { return VerifyResult.failure(Err.NOT_AN_ID, name); } return VerifyResult.success(); } protected abstract String getName(T input);
private NamespaceId validateNamespace(String namespaceId) throws BadRequestException, NamespaceNotFoundException { NamespaceId namespace; if (namespaceId == null) { throw new BadRequestException("Path parameter namespace-id cannot be empty"); } if (EntityId.isValidId(namespaceId)) { namespace = new NamespaceId(namespaceId); } else { throw new BadRequestException(String.format("Invalid namespace '%s'", namespaceId)); } try { if (!namespace.equals(NamespaceId.SYSTEM)) { namespaceQueryAdmin.get(namespace); } } catch (NamespaceNotFoundException e) { throw e; } catch (Exception e) { // This can only happen when NamespaceAdmin uses HTTP calls to interact with namespaces. // In AppFabricServer, NamespaceAdmin is bound to DefaultNamespaceAdmin, which interacts directly with the MDS. // Hence, this exception will never be thrown throw Throwables.propagate(e); } return namespace; }
private NamespaceId validateNamespace(String namespaceId) throws BadRequestException, NamespaceNotFoundException { NamespaceId namespace; if (namespaceId == null) { throw new BadRequestException("Path parameter namespace-id cannot be empty"); } if (EntityId.isValidId(namespaceId)) { namespace = new NamespaceId(namespaceId); } else { throw new BadRequestException(String.format("Invalid namespace '%s'", namespaceId)); } try { if (!namespace.equals(NamespaceId.SYSTEM)) { namespaceQueryAdmin.get(namespace); } } catch (NamespaceNotFoundException e) { throw e; } catch (Exception e) { // This can only happen when NamespaceAdmin uses HTTP calls to interact with namespaces. // In AppFabricServer, NamespaceAdmin is bound to DefaultNamespaceAdmin, which interacts directly with the MDS. // Hence, this exception will never be thrown throw Throwables.propagate(e); } return namespace; }
private ApplicationId validateApplicationVersionId(String namespaceId, String appId, String versionId) throws BadRequestException, NamespaceNotFoundException { NamespaceId namespace = validateNamespace(namespaceId); if (appId == null) { throw new BadRequestException("Path parameter app-id cannot be empty"); } if (!EntityId.isValidId(appId)) { throw new BadRequestException(String.format("Invalid app name '%s'", appId)); } if (versionId == null) { throw new BadRequestException("Path parameter version-id cannot be empty"); } if (EntityId.isValidVersionId(versionId)) { return namespace.app(appId, versionId); } throw new BadRequestException(String.format("Invalid version '%s'", versionId)); } }
private ApplicationId validateApplicationVersionId(String namespaceId, String appId, String versionId) throws BadRequestException, NamespaceNotFoundException { NamespaceId namespace = validateNamespace(namespaceId); if (appId == null) { throw new BadRequestException("Path parameter app-id cannot be empty"); } if (!EntityId.isValidId(appId)) { throw new BadRequestException(String.format("Invalid app name '%s'", appId)); } if (versionId == null) { throw new BadRequestException("Path parameter version-id cannot be empty"); } if (EntityId.isValidVersionId(versionId)) { return namespace.app(appId, versionId); } throw new BadRequestException(String.format("Invalid version '%s'", versionId)); } }
if (!EntityId.isValidId(defn.getFlowletSpec().getName())) { return VerifyResult.failure(Err.NOT_AN_ID, flowName + ":" + flowletName);