/** * Figures out the artifact type (enum) from the given S-RAMP artifact type string. * @param artifactType */ public static ArtifactType valueOf(String artifactType) { return valueOf(artifactType, false); }
public static ArtifactType detect(String filename) { String type = HINTS.get(filename); if (type != null) { return ArtifactType.valueOf(filename, true); } return null; } }
@Override public ArtifactType detect(ArtifactContent content) { if (content.getFilename().equals("kmodule.xml")) { return ArtifactType.valueOf(KieJarModel.KieXmlDocument, true); } if (content.getFilename().endsWith(".bpmn") || content.getFilename().endsWith(".bpmn2")) { return ArtifactType.valueOf(KieJarModel.BpmnDocument, true); } if (content.getFilename().endsWith(".drl")) { return ArtifactType.valueOf(KieJarModel.DroolsDocument, true); } return null; }
/** * Resolves the proper artifact model given an artifact type. * @param artifactType the S-RAMP artifact type */ private String resolveArtifactModel(String artifactType) { return ArtifactType.valueOf(artifactType).getArtifactType().getModel(); } }
@Override public ArtifactType detect(ArtifactContent content, ArchiveContext archiveContext) { if (archiveContext.isExpandedFromArchive()) { return detect(content); } if (content.getFilename().endsWith(".zip")) { return ArtifactType.valueOf("ZipArchive", true); } return null; }
/** * Common visit method for all artifacts. * @param artifact */ protected void visitBase(BaseArtifactType artifact) { ArtifactType artifactType = ArtifactType.valueOf(artifact); BaseArtifactEnum apiType = artifactType.getArtifactType().getApiType(); artifact.setArtifactType(apiType); // Subclasses can do common visit logic here }
public static BaseArtifactType visit(ArtificerArtifact artificerArtifact, boolean includeAssociations) throws Exception { return visit(artificerArtifact, ArtifactType.valueOf(artificerArtifact.getType(), artificerArtifact.isDocument()), includeAssociations); }
@Override public ArtifactType detect(ArtifactContent content, ArchiveContext archiveContext) { if (archiveContext.isExpandedFromArchive()) { return detect(content); } else if (archiveContext.hasArchiveEntry("META-INF/kmodule.xml")) { return ArtifactType.valueOf(KieJarModel.TYPE_ARCHIVE, true); } return null; }
artifactContent = client(commandInvocation).getArtifactContent(ArtifactType.valueOf(artifact), artifact.getUuid());
@Override protected CommandResult doExecute(CommandInvocation commandInvocation) throws Exception { if (CollectionUtils.isEmpty(arguments)) { return doHelp(commandInvocation); } String pathToContent = optionalArgument(arguments, 0); InputStream contentStream = null; try { ArtifactType artifactType = ArtifactType.valueOf(type); String name = new File(type).getName(); if (pathToContent != null) { File contentFile = new File(pathToContent); contentStream = FileUtils.openInputStream(contentFile); } BaseArtifactType artifact = artifactType.newArtifactInstance(); artifact.setName(name); currentArchive(commandInvocation).addEntry(entryPath, artifact, contentStream); commandInvocation.getShell().out().println(Messages.i18n.format("AddEntry.Added", entryPath)); } catch (ArtificerArchiveException e) { commandInvocation.getShell().out().println(Messages.i18n.format("AddEntry.ArtificerArchiveException", e.getLocalizedMessage())); } finally { IOUtils.closeQuietly(contentStream); } return CommandResult.SUCCESS; }
@Override protected CommandResult doExecute(CommandInvocation commandInvocation) throws Exception { if (CollectionUtils.isEmpty(arguments) || arguments.size() < 1) { return doHelp(commandInvocation); } String text = arguments.get(0); ArtificerAtomApiClient client = client(commandInvocation); BaseArtifactType artifact = currentArtifact(commandInvocation); try { client.addComment(artifact.getUuid(), ArtifactType.valueOf(artifact), text); commandInvocation.getShell().out().println(Messages.i18n.format("AddComment.Success", artifact.getName())); } catch (Exception e) { commandInvocation.getShell().out().println(Messages.i18n.format("AddComment.Failure")); commandInvocation.getShell().out().println("\t" + e.getMessage()); return CommandResult.FAILURE; } return CommandResult.SUCCESS; }
/** * @see org.artificer.common.query.xpath.visitors.XPathVisitor#visit(org.artificer.common.query.xpath.ast.LocationPath) */ @Override public void visit(LocationPath node) { if (node.getArtifactType() != null) { // If an explicit type is given, we need to override the root 'from' in order to give the correct entity class. // This is so that certain fields can be restricted to their respective entities, rather than cramming // all possible fields into ArtificerArtifact itself. ArtificerArtifact artifact; try { artifact = HibernateEntityCreator.visit(ArtifactType.valueOf(node.getArtifactType())); } catch (Exception e) { throw new RuntimeException(e); } query = criteriaBuilder.createQuery(ArtifactSummary.class); from = query.from(artifact.getClass()); eq("type", node.getArtifactType()); artifactType = node.getArtifactType(); } if (node.getArtifactModel() != null) { eq("model", node.getArtifactModel()); artifactModel = node.getArtifactModel(); } }
if (StringUtils.isNotBlank(artifactUuid)) { BaseArtifactType artifact = artifact(commandInvocation, artifactUuid); artifactType = ArtifactType.valueOf(artifact); artifactName = artifact.getName(); } else if (StringUtils.isNotBlank(feedIndex)) { } else if (hasCurrentArtifact(commandInvocation)) { BaseArtifactType artifact = currentArtifact(commandInvocation); artifactType = ArtifactType.valueOf(artifact); artifactName = artifact.getName(); } else {
@Override protected CommandResult doExecute(CommandInvocation commandInvocation) throws Exception { ArtificerAtomApiClient client = client(commandInvocation); BaseArtifactType artifact = currentArtifact(commandInvocation); try { ArtifactType type = ArtifactType.valueOf(artifact); BaseArtifactType metaData = client.getArtifactMetaData(type, artifact.getUuid()); context(commandInvocation).setCurrentArtifact(metaData); commandInvocation.getShell().out().println(Messages.i18n.format("RefreshMetaData.Success", metaData.getName())); commandInvocation.getShell().out().println(Messages.i18n.format("RefreshMetaData.MetaDataFor", metaData.getUuid())); commandInvocation.getShell().out().println("--------------"); PrintArtifactMetaDataVisitor visitor = new PrintArtifactMetaDataVisitor(commandInvocation); ArtifactVisitorHelper.visitArtifact(visitor, metaData); } catch (Exception e) { commandInvocation.getShell().out().println(Messages.i18n.format("RefreshMetaData.Failure")); commandInvocation.getShell().out().println("\t" + e.getMessage()); return CommandResult.FAILURE; } return CommandResult.SUCCESS; }
@Override protected CommandResult doExecute(CommandInvocation commandInvocation) throws Exception { ArtificerAtomApiClient client = client(commandInvocation); BaseArtifactType artifact = context(commandInvocation).getCurrentArtifact(); QueryResultSet feed = context(commandInvocation).getCurrentArtifactFeed(); if (client == null) { commandInvocation.getShell().out().println(Messages.i18n.format("Status.Status1")); } else { commandInvocation.getShell().out().println(Messages.i18n.format("Status.Status2", client.getEndpoint())); } if (artifact == null) { commandInvocation.getShell().out().println(Messages.i18n.format("Status.Status3")); } else { ArtifactType type = ArtifactType.valueOf(artifact); commandInvocation.getShell().out().println(Messages.i18n.format("Status.Status4", artifact.getName(), type.getType())); } if (feed == null) { commandInvocation.getShell().out().println(Messages.i18n.format("Status.Status5")); } else { commandInvocation.getShell().out().println(Messages.i18n.format("Status.Status6", feed.size())); } return CommandResult.SUCCESS; }
@Override protected void visitDerived(DerivedArtifactType srampArtifact) { super.visitDerived(srampArtifact); try { if (includeAssociations) { ArtificerArtifact derivedFrom = artificerArtifact.getDerivedFrom(); if (derivedFrom != null) { DocumentArtifactTarget target = new DocumentArtifactTarget(); ArtifactType derivedFromType = ArtifactType.valueOf(derivedFrom.getType(), derivedFrom.isDocument()); DocumentArtifactEnum documentArtifactEnum = DocumentArtifactEnum.fromValue(derivedFromType.getArtifactType().getApiType()); target.setArtifactType(documentArtifactEnum); target.setValue(derivedFrom.getUuid()); srampArtifact.setRelatedDocument(target); } } } catch (Exception e) { throw new RuntimeException(e); } }
protected CommandResult doExecute(CommandInvocation commandInvocation) throws Exception { ArtificerAtomApiClient client = client(commandInvocation); ArtifactType artifactType = ArtifactType.valueOf(type); if (artifactType.isExtendedType()) { artifactType = ArtifactType.ExtendedArtifactType(artifactType.getExtendedType(), false); } if (artifactType.isDerived()) { commandInvocation.getShell().out().println(Messages.i18n.format("ArtifactModel.isDerived")); return CommandResult.FAILURE; } else if (artifactType.isDocument()) { commandInvocation.getShell().out().println(Messages.i18n.format("ArtifactModel.isDocument")); return CommandResult.FAILURE; } else { BaseArtifactType artifact = artifactType.newArtifactInstance(); artifact.setName(name); artifact.setDescription(description); artifact = client.createArtifact(artifact); // Put the artifact in the session as the active artifact context(commandInvocation).setCurrentArtifact(artifact); } commandInvocation.getShell().out().println(Messages.i18n.format("CreateArtifactCommand.Successful", name)); return CommandResult.SUCCESS; }
ArtifactType type = ArtifactType.valueOf(artifact); assertFeatureEnabled(type); ClientResponse<?> response = null;
/** * Creates a new artifact in the S-RAMP repository. Use this method when creating * logical artifacts in the repository (i.e. artifacts without document content). * @param artifact */ public BaseArtifactType createArtifact(BaseArtifactType artifact) throws ArtificerClientException, ArtificerServerException { ArtifactType artifactType = ArtifactType.valueOf(artifact); if (ArtificerModelUtils.isDocumentArtifact(artifact)) { throw new ArtificerClientException(Messages.i18n.format("MISSING_ARTIFACT_CONTEN")); } assertFeatureEnabled(artifactType); ClientResponse<Entry> response = null; try { String type = artifactType.getType(); String atomUrl = String.format("%1$s/%2$s/%3$s", srampEndpoint, artifactType.getModel(), type); ClientRequest request = createClientRequest(atomUrl); request.body(MediaType.APPLICATION_ATOM_XML_ENTRY, ArtificerAtomUtils.wrapSrampArtifact(artifact)); response = request.post(Entry.class); Entry entry = response.getEntity(); return ArtificerAtomUtils.unwrapSrampArtifact(artifactType, entry); } catch (ArtificerServerException e) { throw e; } catch (Throwable e) { throw new ArtificerClientException(e); } finally { closeQuietly(response); } }
ArtifactType artifactType = ArtifactType.valueOf(baseArtifactType); assertFeatureEnabled(artifactType); ClientResponse<Entry> response = null;