auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public void should_parse_virtual_metadata() { KeyspaceMetadata km = session().getCluster().getMetadata().getKeyspace("system_views"); assertThat(km.getTables().size() >= 2); assertThat(km.isVirtual()).isTrue(); assertThat(km.isDurableWrites()).isFalse(); assertThat(km.getName()).isEqualTo("system_views"); assertThat(km.getUserTypes().size()).isEqualTo(0); assertThat(km.getFunctions().size()).isEqualTo(0); assertThat(km.getMaterializedViews().size()).isEqualTo(0); assertThat(km.getAggregates().size()).isEqualTo(0); assertThat(km.asCQLQuery()).isEqualTo(" "); TableMetadata tm = km.getTable("clients"); assertThat(tm).isNotNull(); assertThat(tm.getName()).isEqualTo("clients"); assertThat(tm.isVirtual()).isTrue(); assertThat(tm.getColumns().size()).isEqualTo(12); assertThat(tm.getIndexes().size()).isEqualTo(0); assertThat(tm.getViews().size()).isEqualTo(0); assertThat(tm.getClusteringColumns().size()).isEqualTo(1); assertThat(tm.getClusteringOrder().size()).isEqualTo(1); assertThat(tm.getId()).isEqualTo(new UUID(0L, 0L)); assertThat(tm.getOptions()).isNull(); assertThat(tm.getKeyspace()).isEqualTo(km); assertThat(tm.asCQLQuery()).isEqualTo(" "); ColumnMetadata cm = tm.getColumn("driver_name"); assertThat(cm).isNotNull(); assertThat(cm.getParent()).isEqualTo(tm); assertThat(cm.getType()).isEqualTo(DataType.text()); assertThat(cm.getName()).isEqualTo("driver_name"); }

Target:
public void should_parse_virtual_metadata() { KeyspaceMetadata km = session().getCluster().getMetadata().getKeyspace("system_views"); assertThat(km.getTables().size() >= 2); assertThat(km.isVirtual()).isTrue(); assertThat(km.isDurableWrites()).isFalse(); assertThat(km.getName()).isEqualTo("system_views"); assertThat(km.getUserTypes().size()).isEqualTo(0); assertThat(km.getFunctions().size()).isEqualTo(0); assertThat(km.getMaterializedViews().size()).isEqualTo(0); assertThat(km.getAggregates().size()).isEqualTo(0); assertThat(km.asCQLQuery()).isEqualTo(" "); TableMetadata tm = km.getTable("clients"); assertThat(tm).isNotNull(); assertThat(tm.getName()).isEqualTo("clients"); assertThat(tm.isVirtual()).isTrue(); assertThat(tm.getColumns().size()).isEqualTo(12); assertThat(tm.getPartitionKey().size()).isEqualTo(1); assertThat(tm.getPartitionKey().get(0).getName()).isEqualTo("address"); assertThat(tm.getClusteringColumns().size()).isEqualTo(1); assertThat(tm.getClusteringColumns().get(0).getName()).isEqualTo("port"); assertThat(tm.getIndexes().size()).isEqualTo(0); assertThat(tm.getViews().size()).isEqualTo(0); assertThat(tm.getClusteringColumns().size()).isEqualTo(1); assertThat(tm.getClusteringOrder().size()).isEqualTo(1); assertThat(tm.getId()).isEqualTo(new UUID(0L, 0L)); assertThat(tm.getOptions()).isNull(); assertThat(tm.getKeyspace()).isEqualTo(km); assertThat(tm.asCQLQuery()).isEqualTo(" "); ColumnMetadata cm = tm.getColumn("driver_name"); assertThat(cm).isNotNull(); assertThat(cm.getParent()).isEqualTo(tm); assertThat(cm.getType()).isEqualTo(DataType.text()); assertThat(cm.getName()).isEqualTo("driver_name"); }
Source:
public void onClick(View v) { if (v.getId() == R.id.sign_in_button) { onSignInClicked(); } }

Target:
public void onClick(View v) { onSignInClicked(); }
Source:
public static Block createMap(MapType mapType, MethodHandle keyEqual, MethodHandle keyHashCode, State state, Block keyBlock, Block valueBlock) { checkCondition(keyBlock.getPositionCount() == valueBlock.getPositionCount(), INVALID_FUNCTION_ARGUMENT, "Key and value arrays must be the same length"); PageBuilder pageBuilder = state.getPageBuilder(); if (pageBuilder.isFull()) { pageBuilder.reset(); } BlockBuilder mapBlockBuilder = pageBuilder.getBlockBuilder(0); BlockBuilder blockBuilder = mapBlockBuilder.beginBlockEntry(); for (int i = 0; i < keyBlock.getPositionCount(); i++) { if (keyBlock.isNull(i)) { pageBuilder.resetBlockBuilder(0); throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "map key cannot be null"); } mapType.getKeyType().appendTo(keyBlock, i, blockBuilder); mapType.getValueType().appendTo(valueBlock, i, blockBuilder); } mapBlockBuilder.closeEntry(); pageBuilder.declarePosition(); return mapType.getObject(mapBlockBuilder, mapBlockBuilder.getPositionCount() - 1); }

Target:
public static Block createMap(MapType mapType, MethodHandle keyEqual, MethodHandle keyHashCode, State state, Block keyBlock, Block valueBlock) { checkCondition(keyBlock.getPositionCount() == valueBlock.getPositionCount(), INVALID_FUNCTION_ARGUMENT, "Key and value arrays must be the same length"); PageBuilder pageBuilder = state.getPageBuilder(); if (pageBuilder.isFull()) { pageBuilder.reset(); } BlockBuilder mapBlockBuilder = pageBuilder.getBlockBuilder(0); BlockBuilder blockBuilder = mapBlockBuilder.beginBlockEntry(); for (int i = 0; i < keyBlock.getPositionCount(); i++) { if (keyBlock.isNull(i)) { mapBlockBuilder.closeEntry(); throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "map key cannot be null"); } mapType.getKeyType().appendTo(keyBlock, i, blockBuilder); mapType.getValueType().appendTo(valueBlock, i, blockBuilder); } mapBlockBuilder.closeEntry(); pageBuilder.declarePosition(); return mapType.getObject(mapBlockBuilder, mapBlockBuilder.getPositionCount() - 1); }
Source:
public String getEventDescription() { List<User> users = _accountService.getAccountUsers(_accountService.getAccount(getId())); User user = users.isEmpty() ? null : users.get(0); return (user != null ? ("deleting User " + user.getUsername() + " (id: " + user.getId() + ") and accountId = " + user.getAccountId()) : "user delete, but this user does not exist in the system"); }

Target:
public String getEventDescription() { Account account = _accountService.getAccount(getId()); return (account != null ? "Deleting user account " + account.getAccountName() + " (ID: " + account.getUuid() + ") and all corresponding users" : "Account delete, but this account does not exist in the system"); }
Source:
public void scanFile(JavaFileScannerContext context) { this.context = context; scan(context.getTree()); shifts.clear(); byteSecuring.clear(); }

Target:
public void scanFile(JavaFileScannerContext context) { this.context = context; scan(context.getTree()); shifts.clear(); byteContainments.clear(); }
Source:
private void waitIfRequired(ReplicaMetadataResponseInfo replicaMetadataResponseInfo, DataNodeId remoteNode, RemoteReplicaInfo remoteReplicaInfo) throws InterruptedException { long remoteReplicaLag = replicaMetadataResponseInfo.getRemoteReplicaLagInBytes(); long startTime = SystemTime.getInstance().milliseconds(); if (!replicatingFromRemoteColo) { needToWaitForReplicaLag = false; } if (remoteReplicaLag < replicationConfig.replicationMaxLagForWaitTimeInBytes && needToWaitForReplicaLag) { logger.trace("Remote node: Thread name: Remote replica: Remote replica lag: " + "ReplicationMaxLagForWaitTimeInBytes: Waiting for ms", remoteNode, threadName, remoteReplicaInfo.getReplicaId(), replicaMetadataResponseInfo.getRemoteReplicaLagInBytes(), replicationConfig.replicationMaxLagForWaitTimeInBytes, replicationConfig.replicaWaitTimeBetweenReplicasMs); Thread.sleep(replicationConfig.replicaWaitTimeBetweenReplicasMs); needToWaitForReplicaLag = false; } if (replicatingFromRemoteColo) { replicationMetrics.interColoReplicationWaitTime.get(datacenterName) .update(SystemTime.getInstance().milliseconds() - startTime); } else { replicationMetrics.intraColoReplicationWaitTime.update(SystemTime.getInstance().milliseconds() - startTime); } }

Target:
private void waitIfRequired(ReplicaMetadataResponseInfo replicaMetadataResponseInfo, DataNodeId remoteNode, RemoteReplicaInfo remoteReplicaInfo) throws InterruptedException { long remoteReplicaLag = replicaMetadataResponseInfo.getRemoteReplicaLagInBytes(); long startTime = SystemTime.getInstance().milliseconds(); if (remoteReplicaLag < replicationConfig.replicationMaxLagForWaitTimeInBytes) { logger.trace("Remote node: Thread name: Remote replica: Remote replica lag: " + "ReplicationMaxLagForWaitTimeInBytes: Waiting for ms", remoteNode, threadName, remoteReplicaInfo.getReplicaId(), replicaMetadataResponseInfo.getRemoteReplicaLagInBytes(), replicationConfig.replicationMaxLagForWaitTimeInBytes, replicationConfig.replicaWaitTimeBetweenReplicasMs); Thread.sleep(replicationConfig.replicaWaitTimeBetweenReplicasMs); waitEnabled = false; } replicationMetrics.intraColoReplicationWaitTime.update(SystemTime.getInstance().milliseconds() - startTime); }
Source:
public Optional<FieldSortExpectations<ZonedDateTime>> getFieldSortExpectations() { return Optional.of( new FieldSortExpectations<>( LocalDateTime.of( 2018, 2, 1, 0, 0 ).atZone( ZoneId.of( "America/Chicago" ) ), LocalDateTime.of( 2018, 3, 1, 0, 0 ).atZone( ZoneId.of( "America/Chicago" ) ), LocalDateTime.of( 2018, 4, 1, 0, 0 ).atZone( ZoneId.of( "America/Chicago" ) ), LocalDateTime.of( 2018, 1, 1, 0, 0 ).atZone( ZoneId.of( "America/Chicago" ) ), LocalDateTime.of( 2018, 2, 15, 0, 0 ).atZone( ZoneId.of( "America/Chicago" ) ), LocalDateTime.of( 2018, 3, 15, 0, 0 ).atZone( ZoneId.of( "America/Chicago" ) ), LocalDateTime.of( 2018, 5, 1, 0, 0 ).atZone( ZoneId.of( "America/Chicago" ) ) ) ); }

Target:
public Optional<FieldSortExpectations<ZonedDateTime>> getFieldSortExpectations() { return Optional.of( new FieldSortExpectations<>( LocalDateTime.of( 2018, 2, 1, 0, 0 ).atZone( ZoneId.of( "America/Chicago" ) ), LocalDateTime.of( 2018, 3, 1, 0, 0 ).atZone( ZoneId.of( "America/Chicago" ) ), LocalDateTime.of( 2018, 4, 1, 0, 0 ).atZone( ZoneId.of( "America/Chicago" ) ), LocalDateTime.of( 2018, 1, 1, 0, 0 ).atZone( ZoneId.of( "America/Chicago" ) ), LocalDateTime.of( 2018, 2, 15, 0, 0 ).atZone( ZoneId.of( "America/Chicago" ) ), LocalDateTime.of( 2018, 3, 1, 0, 0 ).atZone( ZoneId.of( "US/Alaska" ) ), LocalDateTime.of( 2018, 5, 1, 0, 0 ).atZone( ZoneId.of( "America/Chicago" ) ) ) ); }
Source:
public DruidCoordinatorRuntimeParams run(DruidCoordinatorRuntimeParams params) { log.info("Starting coordination. Getting available segments."); final TreeSet<DataSegment> availableSegments = DruidCoordinatorRuntimeParams.createAvailableSegmentsSet(); for (DataSegment segment : coordinator.iterateAvailableDataSegments()) { if (segment.getSize() < 0) { log.makeAlert("No size on a segment") .addData("segment", segment) .emit(); } availableSegments.add(segment); } if (log.isDebugEnabled()) { log.debug("Available DataSegments"); for (DataSegment dataSegment : availableSegments) { log.debug(" %s", dataSegment); } } log.info("Found [%,d] available segments.", availableSegments.size()); return params.buildFromExisting() .setAvailableSegments(availableSegments) .build(); }

Target:
public DruidCoordinatorRuntimeParams run(DruidCoordinatorRuntimeParams params) { log.info("Starting coordination. Getting available segments."); Iterable<DataSegment> availableSegmentsWithSizeChecking = Iterables.transform( coordinator.iterateAvailableDataSegments(), segment -> { if (segment.getSize() < 0) { log.makeAlert("No size on a segment") .addData("segment", segment) .emit(); } return segment; } ); final TreeSet<DataSegment> availableSegments = DruidCoordinatorRuntimeParams.createAvailableSegmentsSet(availableSegmentsWithSizeChecking); if (log.isDebugEnabled()) { log.debug("Available DataSegments"); for (DataSegment dataSegment : availableSegments) { log.debug(" %s", dataSegment); } } log.info("Found [%,d] available segments.", availableSegments.size()); return params.buildFromExisting() .setAvailableSegments(availableSegments) .build(); }
Source:
public boolean isInputElementValid(WebElement inputElement) { Preconditions.checkArgument(inputElement.getAttribute("nodeName").equals("INPUT")); return (boolean) executeScript("return arguments[0].checkValidity();", inputElement); }

Target:
public boolean isInputElementValid(WebElement inputElement) { checkArgument(inputElement.getAttribute("nodeName").equals("INPUT")); return (boolean) executeScript("return arguments[0].willValidate && arguments[0].checkValidity();", inputElement); }
Source:
protected Constraint roomPenalty(ConstraintFactory constraintFactory) { return constraintFactory.from(Exam.class) .ifExists(Room.class, equal(Exam::getRoom, Function.identity()), filtering((exam, room) -> room.getPenalty() != 0)) .penalize("Room penalty", HardSoftScore.ONE_SOFT, exam -> exam.getRoom().getPenalty()); }

Target:
protected Constraint roomPenalty(ConstraintFactory constraintFactory) { return constraintFactory.from(Exam.class) .filter(exam -> exam.getRoom().getPenalty() != 0) .penalizeConfigurable("roomPenalty", exam -> exam.getRoom().getPenalty()); }
Source:
public IosRSAKey() { }

Target:
private IosRSAKey() { }
Source:
public void shouldThrowExceptionWhenNoKeysInUsersPreferences() throws Exception { sshKeyStore = spy(new UserProfileSshKeyStore(API_ENDPOINT)); doReturn(null).when(sshKeyStore).getSshKeys(); thrown.expect(SshKeyStoreException.class); thrown.expectMessage(new StringContains("Impossible get keys")); sshKeyStore.getAll(); }

Target:
public void shouldThrowExceptionWhenNoKeysInUsersPreferences() throws Exception { sshKeyStore = spy(new UserProfileSshKeyStore(API_ENDPOINT)); doThrow(IOException.class).when(sshKeyStore).getSshKeys(); thrown.expect(SshKeyStoreException.class); thrown.expectMessage(new StringContains("Failed to get keys ")); sshKeyStore.getAll(); }
Source:
public HueBridgeNupnpDiscovery() { super(SUPPORTED_THING_TYPES, DISCOVERY_TIMEOUT); }

Target:
public HueBridgeNupnpDiscovery() { super(SUPPORTED_THING_TYPES, DISCOVERY_TIMEOUT, false); }
Source:
public void executesUploadCmd() throws Exception { final File dir = Files.createTempDir(); FileUtils.write(new File(dir, "s3cmd"), "echo $@"); final S3CmdPut cmd = new S3CmdPut( "a1", "./*", "bkt1", "", "AAAAAAAAAAAAAAAAAAAA", "30KFuodpOPX07QIaO4+QoLdTR5/MW/FN5qUDqxs=" ); cmd.exec( new Provisioned.ProvisionedShell( "PATH=.:$PATH && chmod +x s3cmd", new ShellMocker.Bash(dir) ) ); }

Target:
public void executesUploadCmd() throws Exception { final File dir = Files.createTempDir(); FileUtils.write(new File(dir, "s3cmd"), "echo $@"); final S3CmdPut cmd = new S3CmdPut( "a1", "./*", "bkt1", "", "AAAAAAAAAAAAAAAAAAAA", "30KFuodpOPX07QIaO4+QoLdTR5/MW/FN5qUDqxs=" ); final Shells shells = Mockito.mock(Shells.class); Mockito.when(shells.acquire()).thenReturn(new ShellMocker.Bash(dir)); cmd.exec( new Provisioned("PATH=.:$PATH && chmod +x s3cmd", shells).acquire() ); }
Source:
private boolean isNotNull(int index) { if (idForNull == UNKNOWN) { String value = selector.lookupName(index); if (value == null) { idForNull = index; return false; } } return index != idForNull; }

Target:
private boolean isNotNull(int index) { if (idForNull == UNKNOWN) { String value = selector.lookupName(index); if (value == null) { idForNull = index; return false; } else { return true; } } return index != idForNull; }
Source:
public boolean matches(final Object o) { if (!super.matches(o)) { return false; } final InvoiceItemCatalogBase that = (InvoiceItemCatalogBase) o; if (catalogEffectiveDate != null && that.catalogEffectiveDate != null ? catalogEffectiveDate.compareTo(that.catalogEffectiveDate) != 0 : that.catalogEffectiveDate != null) { return false; } if (phaseName != null ? !phaseName.equals(that.phaseName) : that.phaseName != null) { return false; } if (planName != null ? !planName.equals(that.planName) : that.planName != null) { return false; } return true; }

Target:
public boolean matches(final Object o) { if (!super.matches(o)) { return false; } final InvoiceItemCatalogBase that = (InvoiceItemCatalogBase) o; if (catalogEffectiveDate != null && that.catalogEffectiveDate != null && catalogEffectiveDate.compareTo(that.catalogEffectiveDate) != 0) { return false; } else if ((catalogEffectiveDate != null && that.catalogEffectiveDate == null) || (catalogEffectiveDate == null && that.catalogEffectiveDate != null)) { return false; } if (phaseName != null ? !phaseName.equals(that.phaseName) : that.phaseName != null) { return false; } if (planName != null ? !planName.equals(that.planName) : that.planName != null) { return false; } return true; }
Source:
private void processTagsToResource( final Map<String, String> tags, final Map<String, String> resource ) { if (tagsToResource.isEmpty()) { return; } tagsToResource.forEach((fromTag, asResource) -> { if (tags.containsKey(fromTag) && !resource.containsKey(asResource)) { resource.put(asResource, tags.get(fromTag)); } tags.remove(fromTag); }); }

Target:
private void processTagsToResource( final Map<String, String> tags, final Map<String, String> resource ) { if (tagsToResource.isEmpty()) { return; } tagsToResource.forEach((fromTag, toResource) -> { final String tag = tags.remove(fromTag); if (tag != null) { resource.putIfAbsent(toResource, tag); } }); }
Source:
public synchronized void saveTags(Long sessionData_id, List<TagDto> tags) { Set<TagEntity> tagEntities = new HashSet<TagEntity>(); SessionData sessionData; for (TagDto tagDto : tags) { tagEntities.add(new TagEntity(tagDto.getName(), tagDto.getDescription())); } try { entityManager.getTransaction().begin(); sessionData = (SessionData) entityManager.createQuery("select sd from SessionData as sd where sd.id = (:sessionData_id)") .setParameter("sessionData_id", sessionData_id) .getSingleResult(); if (sessionData != null) { sessionData.setTags(tagEntities); entityManager.merge(sessionData); entityManager.flush(); } } finally { entityManager.getTransaction().commit(); } }

Target:
public synchronized void saveTags(Long sessionData_id, List<TagDto> tags) { Set<TagEntity> tagEntities = new HashSet<TagEntity>(); SessionData sessionData; for (TagDto tagDto : tags) { tagEntities.add(new TagEntity(tagDto.getName(), tagDto.getDescription())); } try { entityManager.getTransaction().begin(); sessionData = entityManager.find(SessionData.class,sessionData_id); if (sessionData != null) { sessionData.setTags(tagEntities); entityManager.merge(sessionData); entityManager.flush(); } } finally { entityManager.getTransaction().commit(); } }
Source:
private void parseResources(String resourceUri, Predicate<String> predicate) throws Exception { final List<URL> list = new ArrayList<>(); final Iterable it = ObjectHelper.createIterable(resourceUri); StreamSupport.stream(it.spliterator(), false) .filter(predicate) .forEach(path -> { try { final URL url = ResourceHelper.resolveMandatoryResourceAsUrl(getCamelContext().getClassResolver(), path.toString()); list.add(url); } catch (Exception e) { } }); if (list.size() > 0) { final URL[] urls = list.toArray(new URL[list.size()]); elSql = ElSql.parse(elSqlConfig, urls); } }

Target:
private void parseResources(String resourceUri, Predicate<String> predicate) throws Exception { final List<URL> list = new ArrayList<>(); final Iterable<String> it = ObjectHelper.createIterable(resourceUri); for (final String path : it) { if (predicate.test(path)) { final URL url = ResourceHelper.resolveMandatoryResourceAsUrl(getCamelContext().getClassResolver(), path); list.add(url); } } if (list.size() > 0) { final URL[] urls = list.toArray(new URL[list.size()]); elSql = ElSql.parse(elSqlConfig, urls); } }
Source:
public String editResolver(Principal principal, @Validated @ModelAttribute("resolver") ProjectHandleResolver resolver, BindingResult results, Model model) { if (results.hasErrors()) { model.addAttribute("resolver", resolver); return "auth/resolvers/edit"; } resolver.setUsername(principal.getName()); resolverManager.saveProjectHandleResolver(resolver, principal.getName()); return "redirect:/auth/resolvers"; }

Target:
public String editResolver(Principal principal, @Validated @ModelAttribute("resolver") ProjectHandleResolver resolver, BindingResult results, Model model) { if (results.hasErrors()) { model.addAttribute("resolver", resolver); return "auth/resolvers/edit"; } resolverManager.saveProjectHandleResolver(resolver, principal.getName()); return "redirect:/auth/resolvers"; }
Source:
private static boolean hasUnicodeChar(String literal) { final Pattern escapedBackslashPattern = Pattern.compile("\\\\\\\\"); final String literalWithoutEscapedBackslashes = escapedBackslashPattern.matcher(literal).replaceAll(""); return UNICODE_REGEXP.matcher(literalWithoutEscapedBackslashes).find(); }

Target:
private static boolean hasUnicodeChar(String literal) { final String literalWithoutEscapedBackslashes = ESCAPED_BACKSLASH.matcher(literal).replaceAll(""); return UNICODE_REGEXP.matcher(literalWithoutEscapedBackslashes).find(); }
Source:
static <R> Function0<Option<R>> lift(CheckedFunction0<? extends R> partialFunction) { return () -> Try.of(of(partialFunction)::apply).getOption(); }

Target:
static <R> Function0<Option<R>> lift(CheckedFunction0<? extends R> partialFunction) { return () -> Try.<R>of(partialFunction::apply).getOption(); }
Source:
public static UnlockWalletDialogFragment show(final FragmentManager fm) { UnlockWalletDialogFragment unlockWalletDialogFragment = new UnlockWalletDialogFragment(); unlockWalletDialogFragment.show(fm, FRAGMENT_TAG); return unlockWalletDialogFragment; }

Target:
public static void show(final FragmentManager fm) { new UnlockWalletDialogFragment().show(fm, FRAGMENT_TAG); }
Source:
public static String convertToEqualShareFormat(int i) { if (i > 100) { return "Equal share + " + (i - 100) + "%"; } else if (i == 100) { return "Equal share"; } else if (i > 0) { return "Equal share - " + (100 - i) + "%"; } else if (i == 0) { return "0%"; } else if (i == Const.POINTS_NOT_SURE) { return "Not Sure"; } else if (i == Const.POINTS_NOT_SUBMITTED) { return ""; } else { return ""; } }

Target:
public static String convertToEqualShareFormat(int i) { if (i > 100) { return "Equal share + " + (i - 100) + "%"; } else if (i == 100) { return "Equal share"; } else if (i > 0) { return "Equal share - " + (100 - i) + "%"; } else if (i == 0) { return "0%"; } else if (i == Const.POINTS_NOT_SURE) { return "Not Sure"; } else { return ""; } }
Source:
protected synchronized void closeLedgerManagerFactory() { LedgerManagerFactory lmToClose; synchronized (this) { lmToClose = lmFactory; lmFactory = null; } if (null != lmToClose) { try { lmToClose.close(); } catch (IOException e) { log.warn("Failed to close zookeeper based ledger manager", e); } } }

Target:
protected void closeLedgerManagerFactory() { LedgerManagerFactory lmToClose; synchronized (this) { lmToClose = lmFactory; lmFactory = null; } if (null != lmToClose) { try { lmToClose.close(); } catch (IOException e) { log.warn("Failed to close zookeeper based ledger manager", e); } } }
Source:
public ByteSource readImage( final ReadImageParams readImageParams ) throws IOException { final String format = doGetFormatByMimeType( readImageParams.getMimeType() ); if ( renderAsASource( format ) ) { return contentService.getBinary( readImageParams.getContentId(), readImageParams.getBinaryReference() ); } final Path cachedImagePath = getCachedImagePath( readImageParams, format ); return ImmutableFilesHelper.computeIfAbsent( cachedImagePath, () -> createImage( readImageParams, format ) ); }

Target:
public ByteSource readImage( final ReadImageParams readImageParams ) throws IOException { if ( renderAsSource( readImageParams ) ) { return contentService.getBinary( readImageParams.getContentId(), readImageParams.getBinaryReference() ); } final Path cachedImagePath = getCachedImagePath( readImageParams ); return ImmutableFilesHelper.computeIfAbsent( cachedImagePath, () -> createImage( readImageParams ) ); }
Source:
public synchronized void setBrightnessInUserInterfaceDimensionUnit(float percent) { if (percent < 0f) { percent = 0f; } else if (percent > 200f) { percent = 200f; } brightness = percent / 100f; changeShader = true; refreshTextures(); }

Target:
public synchronized void setBrightnessInUserInterfaceDimensionUnit(float percent) { if (percent < 0f) { percent = 0f; } else if (percent > 200f) { percent = 200f; } brightness = percent / 100f; refreshTextures(true); }
Source:
private static long countDistinctDescriptors(Stream<IDataChartDescriptor<?, ?>> descriptors) { return descriptors.map(desc -> desc.hashCode()).distinct().count(); }

Target:
private static long countDistinctDescriptors(Stream<IDataChartDescriptor<?, ?>> descriptors) { return descriptors.distinct().count(); }
Source:
private boolean allNodesAreAvailable(Map<String, Node> nodes, ResourceManager rm) { if (rm == null) { throw new NotConnectedException("No connection to RM"); } Set<String> unknownNodeUrls = PAFuture.getFutureValue( rm.setNodeAvailable(ImmutableSet.copyOf(nodes.keySet())), NODE_AVAILABILITY_REPORT_TIMEOUT_DELAY); for (String unknownNodeUrl : unknownNodeUrls) { Node node = nodes.get(unknownNodeUrl); if (node == null) { logger.warn("The RM has sent back an URL that was not published by the Node: " + unknownNodeUrl); } else { String nodeName = node.getNodeInformation().getName(); try { node.getProActiveRuntime().killNode(nodeName); } catch (Exception e) { logger.warn("Killing the local node has failed: " + nodeName, e); } finally { nodes.remove(unknownNodeUrl); logger.info("Node " + unknownNodeUrl + " has been removed "); } } } int nodeCount = nodes.size(); if (logger.isDebugEnabled()) { logger.debug("Node count is equal to " + nodeCount); } return true; }

Target:
private boolean allNodesAreAvailable(Map<String, Node> nodes, ResourceManager rm) { if (rm == null) { throw new NotConnectedException("No connection to RM"); } Set<String> unknownNodeUrls = PAFuture.getFutureValue( rm.setNodesAvailable(ImmutableSet.copyOf(nodes.keySet())), nodeAvailabilityReportTimeoutDelay); for (String unknownNodeUrl : unknownNodeUrls) { killWorkerNodeIfRemovedByUser(nodes, unknownNodeUrl); } int nodeCount = nodes.size(); if (logger.isDebugEnabled()) { logger.debug("Node count is equal to " + nodeCount); } return true; }
Source:
public void stop(String workspaceId, Map<String, String> options) throws NotFoundException, InfrastructureException, ConflictException { RuntimeState state = runtimes.get(workspaceId); if (state == null) { throw new NotFoundException("Workspace with id '" + workspaceId + "' is not running."); } if (!state.status.equals(RUNNING) && !state.status.equals(STARTING)) { throw new ConflictException( format("Could not stop workspace '%s' because its state is '%s'", workspaceId, state.status)); } if (!runtimes.replace(workspaceId, state, new RuntimeState(state.runtime, STOPPING))) { RuntimeState newState = runtimes.get(workspaceId); WorkspaceStatus status = newState != null ? newState.status : STOPPED; throw new ConflictException( format("Could not stop workspace '%s' because its state is '%s'", workspaceId, status)); } eventService.publish(DtoFactory.newDto(WorkspaceStatusEvent.class) .withWorkspaceId(workspaceId) .withPrevStatus(state.status) .withStatus(STOPPING)); try { state.runtime.stop(options); runtimes.remove(workspaceId); publishWorkspaceStoppedEvent(workspaceId, STOPPING, null); } catch (InfrastructureException e) { runtimes.remove(workspaceId); if (!(e instanceof RuntimeStartInterruptedException)) { publishWorkspaceStoppedEvent(workspaceId, STOPPING, "Error occurs on workspace runtime stop. Error: " + e.getMessage()); } else { publishWorkspaceStoppedEvent(workspaceId, STOPPING, null); } } }

Target:
public void stop(String workspaceId, Map<String, String> options) throws NotFoundException, ConflictException { RuntimeState state = runtimes.get(workspaceId); if (state == null) { throw new NotFoundException("Workspace with id '" + workspaceId + "' is not running."); } if (state.status != RUNNING && state.status != STARTING) { throw new ConflictException( format("Could not stop workspace '%s' because its state is '%s'", workspaceId, state.status)); } if (!runtimes.replace(workspaceId, state, new RuntimeState(state.runtime, STOPPING))) { RuntimeState newState = runtimes.get(workspaceId); WorkspaceStatus status = newState != null ? newState.status : STOPPED; throw new ConflictException( format("Could not stop workspace '%s' because its state is '%s'", workspaceId, status)); } eventService.publish(DtoFactory.newDto(WorkspaceStatusEvent.class) .withWorkspaceId(workspaceId) .withPrevStatus(state.status) .withStatus(STOPPING)); try { state.runtime.stop(options); runtimes.remove(workspaceId); publishWorkspaceStoppedEvent(workspaceId, STOPPING, null); } catch (InfrastructureException e) { runtimes.remove(workspaceId); publishWorkspaceStoppedEvent(workspaceId, STOPPING, "Error occurs on workspace runtime stop. Error: " + e.getMessage()); } }
Source:
ResourceInformationReflector(String resourceClassName, String resourceInfoClassName) { Method resourceSetResourceInformationMethod = null; Method resourceGetResourcesMethod = null; Method resourceInformationGetNameMethod = null; Method resourceInformationGetValueMethod = null; Method resourceInformationNewInstanceMethod = null; boolean isYarnResourceTypesAvailable = false; try { final Class<?> resourceClass = Class.forName(resourceClassName); final Class<?> resourceInfoClass = Class.forName(resourceInfoClassName); resourceSetResourceInformationMethod = resourceClass.getMethod("setResourceInformation", String.class, resourceInfoClass); resourceGetResourcesMethod = resourceClass.getMethod("getResources"); resourceInformationGetNameMethod = resourceInfoClass.getMethod("getName"); resourceInformationGetValueMethod = resourceInfoClass.getMethod("getValue"); resourceInformationNewInstanceMethod = resourceInfoClass.getMethod("newInstance", String.class, long.class); isYarnResourceTypesAvailable = true; } catch (Exception e) { LOG.debug("The underlying Yarn does not support external resource.", e); } finally { this.resourceSetResourceInformationMethod = resourceSetResourceInformationMethod; this.resourceGetResourcesMethod = resourceGetResourcesMethod; this.resourceInformationGetNameMethod = resourceInformationGetNameMethod; this.resourceInformationGetValueMethod = resourceInformationGetValueMethod; this.resourceInformationNewInstanceMethod = resourceInformationNewInstanceMethod; this.isYarnResourceTypesAvailable = isYarnResourceTypesAvailable; } }

Target:
ResourceInformationReflector(String resourceClassName, String resourceInfoClassName) { Method resourceSetResourceInformationMethod = null; Method resourceGetResourcesMethod = null; Method resourceInformationGetNameMethod = null; Method resourceInformationGetValueMethod = null; Method resourceInformationNewInstanceMethod = null; boolean isYarnResourceTypesAvailable = false; try { final Class<?> resourceClass = Class.forName(resourceClassName); final Class<?> resourceInfoClass = Class.forName(resourceInfoClassName); resourceSetResourceInformationMethod = resourceClass.getMethod("setResourceInformation", String.class, resourceInfoClass); resourceGetResourcesMethod = resourceClass.getMethod("getResources"); resourceInformationGetNameMethod = resourceInfoClass.getMethod("getName"); resourceInformationGetValueMethod = resourceInfoClass.getMethod("getValue"); resourceInformationNewInstanceMethod = resourceInfoClass.getMethod("newInstance", String.class, long.class); isYarnResourceTypesAvailable = true; } catch (Exception e) { LOG.debug("The underlying Yarn version does not support external resources.", e); } finally { this.resourceSetResourceInformationMethod = resourceSetResourceInformationMethod; this.resourceGetResourcesMethod = resourceGetResourcesMethod; this.resourceInformationGetNameMethod = resourceInformationGetNameMethod; this.resourceInformationGetValueMethod = resourceInformationGetValueMethod; this.resourceInformationNewInstanceMethod = resourceInformationNewInstanceMethod; this.isYarnResourceTypesAvailable = isYarnResourceTypesAvailable; } }
Source:
public AtomicInteger getNumberOfConnections() { return this.numberOfConnections; }

Target:
public int getNumberOfConnections() { return this.numberOfConnections.intValue(); }
Source:
private static boolean isPortFreeToUse(int port) { if (port < MIN_PORT_NUMBER || port > MAX_PORT_NUMBER) { throw new IllegalArgumentException("Invalid start port: " + port); } try (ServerSocket ss = new ServerSocket(port); DatagramSocket ds = new DatagramSocket(port)) { ss.setReuseAddress(true); ds.setReuseAddress(true); return true; } catch (IOException e) { } return false; }

Target:
private static boolean isPortFreeToUse(int port) { return isUDPPortFreeToUse(port) && isTCPPortFreeToUse(port); }
Source:
private void initialize() { Thread.currentThread().setPriority(Thread.MAX_PRIORITY); Stopwatch totalInitTime = Stopwatch.createStarted(); try { logger.info("Initializing Terasology..."); logEnvironmentInfo(); GameThread.setToCurrentThread(); preInitSubsystems(); initManagers(); initSubsystems(); changeStatus(TerasologyEngineStatus.INITIALIZING_ASSET_MANAGEMENT); initAssets(); EnvironmentSwitchHandler environmentSwitcher = new EnvironmentSwitchHandler(); rootContext.put(EnvironmentSwitchHandler.class, environmentSwitcher); environmentSwitcher.handleSwitchToGameEnvironment(rootContext); rootContext.put(TranslationSystem.class, new TranslationSystemImpl(rootContext)); postInitSubsystems(); verifyInitialisation(); CoreRegistry.setContext(null); } catch (RuntimeException e) { logger.error("Failed to initialise Terasology", e); cleanup(); throw e; } double seconds = 0.001 * totalInitTime.elapsed(TimeUnit.MILLISECONDS); logger.info("Initialization completed in {}sec.", String.format("%.2f", seconds)); }

Target:
private void initialize() { Thread.currentThread().setPriority(Thread.MAX_PRIORITY); Stopwatch totalInitTime = Stopwatch.createStarted(); try { logger.info("Initializing Terasology..."); logEnvironmentInfo(); GameThread.setToCurrentThread(); preInitSubsystems(); initManagers(); initSubsystems(); changeStatus(TerasologyEngineStatus.INITIALIZING_ASSET_MANAGEMENT); initAssets(); EnvironmentSwitchHandler environmentSwitcher = new EnvironmentSwitchHandler(); rootContext.put(EnvironmentSwitchHandler.class, environmentSwitcher); environmentSwitcher.handleSwitchToGameEnvironment(rootContext); postInitSubsystems(); verifyInitialisation(); CoreRegistry.setContext(null); } catch (RuntimeException e) { logger.error("Failed to initialise Terasology", e); cleanup(); throw e; } double seconds = 0.001 * totalInitTime.elapsed(TimeUnit.MILLISECONDS); logger.info("Initialization completed in {}sec.", String.format("%.2f", seconds)); }
Source:
private boolean tryLockVmForUpdate(Pair<VM, VmInternalData> pair) { Guid vmId = getVmId(pair); if (vmId != null) { VmManager vmManager = getResourceManager().getVmManager(vmId); if (vmManager.trylock()) { if (fetchTime - vmManager.getVmDataChangedTime() < 0) { log.warn("skipping VM '{}' from this monitoring cycle" + " - the VM data has changed since fetching the data", vmId); vmManager.unlock(); } else { vmManagers.put(vmId, vmManager); return true; } } else { log.debug("skipping VM '{}' from this monitoring cycle" + " - the VM is locked by its VmManager ", getVmId(pair)); } } return false; }

Target:
private boolean tryLockVmForUpdate(Pair<VM, VmInternalData> pair) { Guid vmId = getVmId(pair); if (vmId != null) { VmManager vmManager = getResourceManager().getVmManager(vmId); if (vmManager.trylock()) { if (fetchTime - vmManager.getVmDataChangedTime() <= 0) { log.warn("skipping VM '{}' from this monitoring cycle" + " - the VM data has changed since fetching the data", vmId); vmManager.unlock(); } else { vmManagers.put(vmId, vmManager); return true; } } else { log.debug("skipping VM '{}' from this monitoring cycle" + " - the VM is locked by its VmManager ", getVmId(pair)); } } return false; }
Source:
public String getDeathDateAsString(Campaign campaign) { if(getDateOfDeath() == null) { return ""; } else { return getDateOfDeath().format(DateTimeFormatter.ofPattern( campaign.getCampaignOptions().getDisplayDateFormat())); } }

Target:
public String getDeathDateAsString(Campaign campaign) { if (getDateOfDeath() == null) { return ""; } else { return campaign.getCampaignOptions().getDisplayFormattedDate(getDateOfDeath()); } }
Source:
public long getEstimatedSizeBytes(PipelineOptions options) { if (isRemoteFileFromLaunchSite) { return 0; } long size = 0; try { Job job = Job.getInstance(getDeserializerConfiguration()); for (FileStatus st : listStatus(createFormat(job), job)) { size += st.getLen(); } return size; } catch (IOException | NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException e) { SOURCE_LOG.warn("Got exception", e); return 0; } }

Target:
public long getEstimatedSizeBytes(PipelineOptions options) { if (isRemoteFileFromLaunchSite) { return 0; } long size = 0; try { Job job = Job.getInstance(getDeserializerConfiguration()); for (FileStatus st : listStatus(createFormat(job), job)) { size += st.getLen(); } return size; } catch (IOException | NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException e) { SOURCE_LOG.error("Got exception while trying to getEstimatedSizeBytes().", e); return 0; } }
Source:
protected AuditMessageType.ActiveParticipant getActiveParticipantDestination(NhinTargetSystemType target, boolean isRequesting, Properties webContextProprties, String serviceName) { String strUrl = null; String strHost = null; boolean setDefaultValue = true; AuditMessageType.ActiveParticipant participant = new AuditMessageType.ActiveParticipant(); strUrl = isRequesting ? getWebServiceUrlFromRemoteObject(target, serviceName) : getWebServiceRequestURL(webContextProprties); if (strUrl != null) { try { URL url = new URL(strUrl); participant.setUserID(strUrl); strHost = url.getHost(); participant.setNetworkAccessPointID(strHost); participant.setNetworkAccessPointTypeCode(getNetworkAccessPointTypeCode(strHost)); setDefaultValue = false; } catch (MalformedURLException ex) { LOG.error(ex); setDefaultValue = true; } } if (setDefaultValue) { participant.setUserID(AuditTransformConstants.ACTIVE_PARTICPANT_USER_ID_SOURCE); participant.setNetworkAccessPointTypeCode(AuditTransformConstants.NETWORK_ACCESSOR_PT_TYPE_CODE_NAME); participant.setNetworkAccessPointID(AuditTransformConstants.ACTIVE_PARTICPANT_UNKNOWN_IP_ADDRESS); } participant.setUserIsRequestor(Boolean.FALSE); participant.getRoleIDCode().add(AuditDataTransformHelper.createCodeValueType(AuditTransformConstants.ACTIVE_PARTICIPANT_ROLE_CODE_DEST, null, AuditTransformConstants.ACTIVE_PARTICIPANT_CODE_SYSTEM_NAME, AuditTransformConstants.ACTIVE_PARTICPANT_ROLE_CODE_DESTINATION_DISPLAY_NAME)); return participant; }

Target:
protected AuditMessageType.ActiveParticipant getActiveParticipantDestination(NhinTargetSystemType target, boolean isRequesting, Properties webContextProprties, String serviceName) { String strUrl = null; String strHost = null; boolean setDefaultValue = true; AuditMessageType.ActiveParticipant participant = new AuditMessageType.ActiveParticipant(); strUrl = isRequesting ? getWebServiceUrlFromRemoteObject(target, serviceName) : getWebServiceRequestURL(webContextProprties); if (strUrl != null) { try { URL url = new URL(strUrl); participant.setUserID(strUrl); strHost = url.getHost(); participant.setNetworkAccessPointID(strHost); participant.setNetworkAccessPointTypeCode(getNetworkAccessPointTypeCode(strHost)); setDefaultValue = false; } catch (MalformedURLException ex) { LOG.error(ex); participant.setUserID(AuditTransformConstants.ACTIVE_PARTICIPANT_USER_ID_SOURCE); participant.setNetworkAccessPointTypeCode(AuditTransformConstants.NETWORK_ACCESSOR_PT_TYPE_CODE_NAME); participant.setNetworkAccessPointID(AuditTransformConstants.ACTIVE_PARTICIPANT_UNKNOWN_IP_ADDRESS); } } participant.setUserIsRequestor(Boolean.FALSE); participant.getRoleIDCode().add(AuditDataTransformHelper.createCodeValueType(AuditTransformConstants.ACTIVE_PARTICIPANT_ROLE_CODE_DEST, null, AuditTransformConstants.ACTIVE_PARTICIPANT_CODE_SYSTEM_NAME, AuditTransformConstants.ACTIVE_PARTICIPANT_ROLE_CODE_DESTINATION_DISPLAY_NAME)); return participant; }
Source:
private final void fireCommandChanged(final CommandEvent commandEvent) { if (commandEvent == null) { throw new NullPointerException("Cannot fire a null event"); } final Object[] listeners = getListeners(); for (Object listener2 : listeners) { final ICommandListener listener = (ICommandListener) listener2; SafeRunner.run(new ISafeRunnable() { @Override public void handleException(Throwable exception) { } @Override public void run() throws Exception { listener.commandChanged(commandEvent); } }); } }

Target:
private final void fireCommandChanged(final CommandEvent commandEvent) { if (commandEvent == null) { throw new NullPointerException("Cannot fire a null event"); } final Object[] listeners = getListeners(); for (Object listener : listeners) { final ICommandListener commandListener = (ICommandListener) listener; SafeRunner.run(new ISafeRunnable() { @Override public void handleException(Throwable exception) { } @Override public void run() throws Exception { commandListener.commandChanged(commandEvent); } }); } }
Source:
private static void addExtensionLink(LinkMenuBar m, TopMenuItem item) { String url = item.getUrl(); if (myConfig.getContextPath() != null && !myConfig.getContextPath().isEmpty()) { url = myConfig.getContextPath(); if (item.getUrl().indexOf('/') != 0) { url += '/'; } url += item.getUrl(); } Anchor atag = anchor(item.getName(), url); atag.setTarget(item.getTarget()); if (item.getId() != null) { atag.getElement().setAttribute("id", item.getId()); } m.add(atag); }

Target:
private static void addExtensionLink(LinkMenuBar m, TopMenuItem item) { Anchor atag = anchor(item.getName(), selfRedirect(item.getUrl())); atag.setTarget(item.getTarget()); if (item.getId() != null) { atag.getElement().setAttribute("id", item.getId()); } m.add(atag); }
Source:
public Collection<Address> getLinkedAddresses() { return linkedAddresses == null ? Collections.emptySet() : linkedAddresses; }

Target:
public Collection<Address> getLinkedAddresses() { final Collection<Address> linkedAddresses = this.linkedAddresses; if (linkedAddresses == null) { return Collections.emptySet(); } return linkedAddresses; }
Source:
private void validateCursors(final ZkSubscriptionClient subscriptionClient, final List<SubscriptionCursor> cursors, final String streamId) throws NakadiException { final ZkSubscriptionNode subscription = subscriptionClient.getZkSubscriptionNodeLocked(); if (!Arrays.stream(subscription.getSessions()).anyMatch(session -> session.getId().equals(streamId))) { throw new InvalidStreamIdException("Session with stream id " + streamId + " not found"); } final Map<Partition.PartitionKey, Partition> partitions = Arrays.stream(subscription.getPartitions()) .collect(Collectors.toMap(Partition::getKey, Function.identity())); final List<SubscriptionCursor> invalidCursors = cursors.stream().filter(cursor -> Try.cons(() -> eventTypeRepository.findByName(cursor.getEventType())).getO().map(eventType -> { final Partition.PartitionKey key = new Partition.PartitionKey(eventType.getTopic(), cursor.getPartition()); final Partition partition = partitions.get(key); return partition == null || !streamId.equals(partition.getSession()); }).orElseGet(() -> false)).collect(Collectors.toList()); if (!invalidCursors.isEmpty()) { throw new InvalidStreamIdException("Cursors " + invalidCursors + " cannot be commited with stream id " + streamId); } }

Target:
private void validateCursors(final ZkSubscriptionClient subscriptionClient, final List<SubscriptionCursor> cursors, final String streamId) throws NakadiException { final ZkSubscriptionNode subscription = subscriptionClient.getZkSubscriptionNodeLocked(); if (!Arrays.stream(subscription.getSessions()).anyMatch(session -> session.getId().equals(streamId))) { throw new InvalidStreamIdException("Session with stream id " + streamId + " not found"); } final Map<Partition.PartitionKey, Partition> partitions = Arrays.stream(subscription.getPartitions()) .collect(Collectors.toMap(Partition::getKey, Function.identity())); final List<SubscriptionCursor> invalidCursors = cursors.stream().filter(cursor -> Try.cons(() -> eventTypeRepository.findByName(cursor.getEventType())).getO().map(eventType -> { final Partition.PartitionKey key = new Partition.PartitionKey(eventType.getTopic(), cursor.getPartition()); final Partition partition = partitions.get(key); return partition == null || !streamId.equals(partition.getSession()); }).orElseGet(() -> false)).collect(Collectors.toList()); if (!invalidCursors.isEmpty()) { throw new InvalidStreamIdException("Cursors " + invalidCursors + " cannot be committed with stream id " + streamId); } }
Source:
protected void loopOfflinePlayers(final Server server, final CommandSource sender, final boolean multipleStringMatches, boolean matchWildcards, final String searchTerm, final String[] commandArgs) throws Exception { loopOfflinePlayersConsumer(server, sender, multipleStringMatches, matchWildcards, searchTerm, user -> updatePlayer(server, sender, user, commandArgs)); }

Target:
protected void loopOfflinePlayers(final Server server, final CommandSource sender, final boolean multipleStringMatches, boolean matchWildcards, final String searchTerm, final String[] commandArgs) throws PlayerNotFoundException, NotEnoughArgumentsException, PlayerExemptException, ChargeException, MaxMoneyException { loopOfflinePlayersConsumer(server, sender, multipleStringMatches, matchWildcards, searchTerm, user -> updatePlayer(server, sender, user, commandArgs)); }
Source:
public Response register(Action action) { BackendVnicProfileHelper.validateVnicMappings(action, this); ImportVmTemplateFromConfParameters params = new ImportVmTemplateFromConfParameters(); ExternalRegistrationConfigurationMapper.mapFromModel(action.getRegistrationConfiguration(), params); params.setContainerId(guid); params.setStorageDomainId(parent.getStorageDomainId()); if (action.isSetCluster()) { params.setClusterId(getClusterId(action)); } params.setImagesExistOnTargetStorageDomain(true); params.setExternalVnicProfileMappings(ExternalVnicProfileMappingMapper.mapFromModel(action.getVnicProfileMappings())); if (action.isSetClone()) { params.setImportAsNewEntity(action.isClone()); if (action.isSetVm() && action.getTemplate().isSetName()) { params.getVmTemplate().setName(action.getTemplate().getName()); } } if (action.isSetAllowPartialImport()) { params.setAllowPartialImport(action.isAllowPartialImport()); } return doAction(ActionType.ImportVmTemplateFromConfiguration, params, action); }

Target:
public Response register(Action action) { BackendVnicProfileHelper.validateVnicMappings(this, action); ImportVmTemplateFromConfParameters params = new ImportVmTemplateFromConfParameters(); ExternalRegistrationConfigurationMapper.mapFromModel(action.getRegistrationConfiguration(), params); params.setContainerId(guid); params.setStorageDomainId(parent.getStorageDomainId()); if (action.isSetCluster()) { params.setClusterId(getClusterId(action)); } params.setImagesExistOnTargetStorageDomain(true); params.setExternalVnicProfileMappings(ExternalVnicProfileMappingMapper.mapFromModel(action.getVnicProfileMappings())); if (action.isSetClone()) { params.setImportAsNewEntity(action.isClone()); if (action.isSetVm() && action.getTemplate().isSetName()) { params.getVmTemplate().setName(action.getTemplate().getName()); } } if (action.isSetAllowPartialImport()) { params.setAllowPartialImport(action.isAllowPartialImport()); } return doAction(ActionType.ImportVmTemplateFromConfiguration, params, action); }