public static ConversationId fromString(String conversationIdString) { try { String conversationId = URLDecoder.decode(conversationIdString, "UTF-8"); String[] conversationIdElements = conversationId.split(SPLIT_PATTERN); if (conversationIdElements.length != 4) { throw new IllegalArgumentException("Non-parsable conversationId '" + conversationIdString + "'"); } String kieServerId = conversationIdElements[0].replaceAll("'", ""); String containerId = conversationIdElements[1]; String[] releaseIdElements = conversationIdElements[2].split(":"); ReleaseId releaseId = new ReleaseId(releaseIdElements[0], releaseIdElements[1], releaseIdElements[2]); String uniqueString = conversationIdElements[3].replaceAll("'", "");; return new ConversationId(kieServerId, containerId, releaseId, uniqueString); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } }
public void upgrade(final String version) { view.disableActions(); ruleCapabilitiesService.call(new RemoteCallback<Void>() { @Override public void callback(final Void response) { if (version != null && !version.isEmpty() && version.compareTo(containerSpec.getReleasedId().getVersion()) == 0) { notification.fire(new NotificationEvent(view.getUpgradeSuccessMessage(), NotificationEvent.NotificationType.SUCCESS)); } updateViewState(); } }, new ErrorCallback<Object>() { @Override public boolean error(final Object o, final Throwable throwable) { notification.fire(new NotificationEvent(view.getUpgradeErrorMessage(), NotificationEvent.NotificationType.ERROR)); updateViewState(); return false; } }).upgradeContainer(containerSpec, new ReleaseId(containerSpec.getReleasedId().getGroupId(), containerSpec.getReleasedId().getArtifactId(), version)); }
/** * Checks whether the releaseId was updated (i.e. the old one is different from the new one). * * @param oldReleaseId old ReleaseId * @param newReleaseId new releaseId * @return true if the second (new) releaseId is different and thus was updated; otherwise false */ private boolean releaseIdUpdated(ReleaseId oldReleaseId, ReleaseId newReleaseId) { if (oldReleaseId == null && newReleaseId == null) { return false; } if (oldReleaseId == null && newReleaseId != null) { return true; } // now both releaseIds are non-null, so it is safe to call equals() return !oldReleaseId.equals(newReleaseId); }
public Builder releaseId(ReleaseId releaseId) { this.groupId = releaseId.getGroupId(); this.artifactId = releaseId.getArtifactId(); this.version = releaseId.getVersion(); return this; }
public void setup(final ReleaseId gav) { checkNotNull("gav", gav); view.setup(gav.getGroupId(), gav.getArtifactId()); } }
@Override public Object answer(InvocationOnMock invocation) throws Throwable { releaseId.setVersion(invocation.getArgumentAt(1, ReleaseId.class).getVersion()); return null; } }).when(ruleCapabilitiesService).upgradeContainer(any(ContainerSpecKey.class),
final ReleaseId resolvedReleasedId = new ReleaseId( "org.kie", "container", "1.0.0" ); final Container container = new Container( "containerSpecId", "containerName", serverInstanceKey, Collections.singletonList( message ), resolvedReleasedId, null ); verify( footerPresenter ).setup( container.getUrl(), resolvedReleasedId.getVersion() ); verify( cardPresenter ).addTitle( linkTitlePresenter ); verify( cardPresenter ).addBody( bodyPresenter );
ReleaseId releaseId = new ReleaseId(gavElements[0], gavElements[1], gavElements[2]); KieContainerResource container = new KieContainerResource(releaseId.getArtifactId(), releaseId, KieContainerStatus.STARTED); containers.add(container);
@Before public void init() { releaseId = new ReleaseId(); releaseId.setVersion("0.1"); doNothing().when(notification).fire(any(NotificationEvent.class)); ruleCapabilitiesServiceCaller = new CallerMock<RuleCapabilitiesService>(ruleCapabilitiesService); when(containerSpec.getReleasedId()).thenReturn(releaseId); when(view.getUpgradeSuccessMessage()).thenReturn(SUCCESS_UPGRADE); presenter = new ContainerRulesConfigPresenter(logger, view, ruleCapabilitiesServiceCaller, notification); doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { releaseId.setVersion(invocation.getArgumentAt(1, ReleaseId.class).getVersion()); return null; } }).when(ruleCapabilitiesService).upgradeContainer(any(ContainerSpecKey.class), any(ReleaseId.class)); }
@Override public void upgradeContainer(final ContainerSpecKey containerSpecKey, ReleaseId releaseId) { ServerTemplate serverTemplate = templateStorage.load(containerSpecKey.getServerTemplateKey().getId()); if (serverTemplate == null) { throw new KieServerControllerIllegalArgumentException("No server template found for id " + containerSpecKey.getServerTemplateKey().getId()); } ContainerSpec containerSpec = serverTemplate.getContainerSpec(containerSpecKey.getId()); if (containerSpec == null) { throw new KieServerControllerIllegalArgumentException("No container spec found for id " + containerSpecKey.getId()); } if (releaseId.getGroupId() == null) { releaseId.setGroupId(containerSpec.getReleasedId().getGroupId()); } if (releaseId.getArtifactId() == null) { releaseId.setArtifactId(containerSpec.getReleasedId().getArtifactId()); } final List<Container> containers; containerSpec.setReleasedId(releaseId); if (containerSpec.getStatus() == KieContainerStatus.STARTED) { containers = kieServerInstanceManager.upgradeContainer(serverTemplate, containerSpec); } else { containers = kieServerInstanceManager.startContainer(serverTemplate, containerSpec); } containerSpec.setStatus(KieContainerStatus.STARTED); templateStorage.update(serverTemplate); notificationService.notify(serverTemplate, containerSpec, containers); }
protected String getContainerAlias(KieContainerResource containerResource) { String alias = containerResource.getContainerAlias(); if (alias == null || alias.isEmpty()) { alias = containerResource.getReleaseId().getArtifactId(); } return alias; }
@Override public void callback(final Void response) { if (version != null && !version.isEmpty() && version.compareTo(containerSpec.getReleasedId().getVersion()) == 0) { notification.fire(new NotificationEvent(view.getUpgradeSuccessMessage(), NotificationEvent.NotificationType.SUCCESS)); } updateViewState(); } },
final ReleaseId resolvedReleasedId = new ReleaseId( "org.kie", "container", "1.0.0" ); final Container container = new Container( "containerSpecId", "containerName", serverInstanceKey, Collections.singletonList( message ), resolvedReleasedId, null ); verify( infoTitlePresenter ).setup( container.getResolvedReleasedId() ); verify( bodyPresenter ).setup( Arrays.asList( message ) ); verify( footerPresenter ).setup( container.getUrl(), resolvedReleasedId.getVersion() ); verify( cardPresenter ).addTitle( linkTitlePresenter ); verify( cardPresenter ).addTitle( infoTitlePresenter );
public ReleaseIdFilter(ReleaseId releaseId) { this(releaseId.getGroupId(), releaseId.getArtifactId(),releaseId.getVersion()); }
public void setup(final ContainerSpec containerSpec, final RuleConfig ruleConfig) { this.containerSpec = checkNotNull("containerSpec", containerSpec); setRuleConfig(ruleConfig, containerSpec.getReleasedId().getVersion()); }
@Test public void testSetup() { final ReleaseId releaseId = new ReleaseId( "com.company", "artifact-id", "1.0.0" ); presenter.setup( releaseId ); verify( view ).setup( releaseId.getGroupId(), releaseId.getArtifactId() ); }
/** * Checks whether the specified releaseId matches (is accepted by) this filter. * * @param releaseId releaseId to match against * @return true if this filter accepts the specified releaseId, otherwise false */ public boolean accept(ReleaseId releaseId) { if (releaseId == null) { throw new IllegalArgumentException("ReleaseId can not be null!"); } return matches(groupId, releaseId.getGroupId()) && matches(artifactId, releaseId.getArtifactId()) && matches(version, releaseId.getVersion()); }
@Override public boolean equals(Object o) { if ( this == o ) return true; if ( !(o instanceof UpdateReleaseIdCommand) ) return false; UpdateReleaseIdCommand that = (UpdateReleaseIdCommand) o; if ( containerId != null ? !containerId.equals( that.containerId ) : that.containerId != null ) return false; if ( releaseId != null ? !releaseId.equals( that.releaseId ) : that.releaseId != null ) return false; return true; }
public void onRuleConfigUpdate(@Observes final RuleConfigUpdated configUpdate) { if (configUpdate != null && configUpdate.getRuleConfig() != null && configUpdate.getReleasedId() != null) { setRuleConfig(configUpdate.getRuleConfig(), configUpdate.getReleasedId().getVersion()); } else { logger.warn("Illegal event argument."); } }