private ArtifactId validateAndGetArtifactId(NamespaceId namespace, String name, String version) throws BadRequestException { try { return namespace.artifact(name, version); } catch (Exception e) { throw new BadRequestException(e.getMessage()); } }
private ArtifactId validateAndGetArtifactId(NamespaceId namespace, String name, String version) throws BadRequestException { try { return namespace.artifact(name, version); } catch (Exception e) { throw new BadRequestException(e.getMessage()); } }
@Override public EntityId apply(ArtifactInfo input) { return namespace.artifact(input.getName(), input.getVersion()); } },
@Override public EntityId apply(ArtifactSummary input) { return namespace.artifact(input.getName(), input.getVersion()); } },
@Override public EntityId apply(ArtifactSummary input) { return namespace.artifact(input.getName(), input.getVersion()); } },
@Override public EntityId apply(ArtifactInfo input) { return namespace.artifact(input.getName(), input.getVersion()); } },
/** * Converts a {@link ArtifactId} to {@link co.cask.cdap.proto.id.ArtifactId}. * * @param namespaceId the user namespace to use * @param artifactId the artifact id to convert */ public static co.cask.cdap.proto.id.ArtifactId toArtifactId(NamespaceId namespaceId, ArtifactId artifactId) { ArtifactScope scope = artifactId.getScope(); NamespaceId artifactNamespace = scope == ArtifactScope.SYSTEM ? NamespaceId.SYSTEM : namespaceId; return artifactNamespace.artifact(artifactId.getName(), artifactId.getVersion().getVersion()); }
/** * Converts a {@link ArtifactId} to {@link co.cask.cdap.proto.id.ArtifactId}. * * @param namespaceId the user namespace to use * @param artifactId the artifact id to convert */ public static co.cask.cdap.proto.id.ArtifactId toArtifactId(NamespaceId namespaceId, ArtifactId artifactId) { ArtifactScope scope = artifactId.getScope(); NamespaceId artifactNamespace = scope == ArtifactScope.SYSTEM ? NamespaceId.SYSTEM : namespaceId; return artifactNamespace.artifact(artifactId.getName(), artifactId.getVersion().getVersion()); }
@Override public void perform(Arguments arguments, PrintStream output) throws Exception { String artifactName = arguments.get(ArgumentName.ARTIFACT_NAME.toString()); String artifactVersion = arguments.get(ArgumentName.ARTIFACT_VERSION.toString()); ArtifactId artifactId = cliConfig.getCurrentNamespace().artifact(artifactName, artifactVersion); artifactClient.delete(artifactId); output.printf("Successfully deleted artifact\n"); }
@Override public EntityId apply(ArtifactDetail input) { co.cask.cdap.api.artifact.ArtifactId artifactId = input.getDescriptor().getArtifactId(); return namespaceId.artifact(artifactId.getName(), artifactId.getVersion().getVersion()); } }, null);
@Override public EntityId apply(ArtifactDetail input) { co.cask.cdap.api.artifact.ArtifactId artifactId = input.getDescriptor().getArtifactId(); return namespaceId.artifact(artifactId.getName(), artifactId.getVersion().getVersion()); } }, null);
@Override public void clear(NamespaceId namespace) throws Exception { List<ArtifactSummary> artifacts = delegate.getArtifactSummaries(namespace, false); for (ArtifactSummary artifactSummary : artifacts) { authorizationEnforcer.enforce(namespace.artifact(artifactSummary.getName(), artifactSummary.getVersion()), authenticationContext.getPrincipal(), Action.ADMIN); } delegate.clear(namespace); }
/** * Adds a system artifact to CDAP instance that is used for testing. */ public void addSystemArtifact(String name, ArtifactVersion version, File artifactFile, @Nullable Set<ArtifactRange> parentArtifacts) throws Exception { ArtifactRepository artifactRepository = standaloneMain.getInjector().getInstance(DefaultArtifactRepository.class); ArtifactId artifactId = NamespaceId.SYSTEM.artifact(name, version.getVersion()); artifactRepository.addArtifact(Id.Artifact.fromEntityId(artifactId), artifactFile, parentArtifacts, null); }
@Override public void clear(NamespaceId namespace) throws Exception { List<ArtifactSummary> artifacts = delegate.getArtifactSummaries(namespace, false); for (ArtifactSummary artifactSummary : artifacts) { authorizationEnforcer.enforce(namespace.artifact(artifactSummary.getName(), artifactSummary.getVersion()), authenticationContext.getPrincipal(), Action.ADMIN); } delegate.clear(namespace); }
@BeforeClass public static void init() throws Exception { artifactJar = createArtifactJar(ServiceArtifactApp.class); addArtifact(NamespaceId.DEFAULT.artifact("dummybase", "1.0.0"), createSingleClassJar(DummyPluginBase.class)); addArtifact(NamespaceId.DEFAULT.artifact("dummy", "1.0.0"), createSingleClassJar(DummyPlugin.class)); }
@Test public void testAddBadApp() throws Exception { ArtifactId artifactId = NamespaceId.DEFAULT.artifact("wordcount", "1.0.0"); Assert.assertEquals(HttpResponseStatus.BAD_REQUEST.code(), addAppArtifact(Id.Artifact.fromEntityId(artifactId), ArtifactSummary.class).getResponseCode()); }
@Test public void testNotFound() throws IOException, URISyntaxException { Assert.assertTrue(getArtifacts(NamespaceId.DEFAULT).isEmpty()); Assert.assertNull(getArtifacts(NamespaceId.DEFAULT, "wordcount")); Assert.assertNull(getArtifact(NamespaceId.DEFAULT.artifact("wordcount", "1.0.0"))); }
private void addRuns(Store store, ProgramRunId... runs) { for (ProgramRunId run : runs) { ArtifactId artifactId = run.getNamespaceId().artifact("testArtifact", "1.0").toApiArtifactId(); setStartAndRunning(store, run.getParent(), run.getEntityName(), artifactId); } }
@Test public void testDoesNotExist() { assertDoesNotExist(new InstanceId(DOES_NOT_EXIST)); assertDoesNotExist(new NamespaceId(DOES_NOT_EXIST)); assertDoesNotExist(NamespaceId.DEFAULT.artifact(DOES_NOT_EXIST, "1.0")); ApplicationId app = NamespaceId.DEFAULT.app(AllProgramsApp.NAME); assertDoesNotExist(NamespaceId.DEFAULT.app(DOES_NOT_EXIST)); assertDoesNotExist(app.mr(DOES_NOT_EXIST)); assertDoesNotExist(NamespaceId.DEFAULT.dataset(DOES_NOT_EXIST)); }
@Test public void testAppFromArtifact() throws Exception { ArtifactId artifactId = NamespaceId.DEFAULT.artifact("cfg-app", "1.0.0-SNAPSHOT"); addAppArtifact(artifactId, ConfigTestApp.class); ApplicationId appId = NamespaceId.DEFAULT.app("AppFromArtifact"); AppRequest<ConfigTestApp.ConfigClass> createRequest = new AppRequest<>( new ArtifactSummary(artifactId.getArtifact(), artifactId.getVersion()), new ConfigTestApp.ConfigClass("testStream", "testDataset") ); ApplicationManager appManager = deployApplication(appId, createRequest); testAppConfig(appId.getApplication(), appManager, createRequest.getConfig()); }