/** * Inserts the provided {@code statement} after the the node this inserter was created for. Tries * to put the {@code statement} as close to the {@code marker} as possible. * * @param statement The statement to insert after the insertion node. */ void insertAfter(final Statement statement) { Validate.notNull(statement); Validate.validState( this.insertionList != null, "Insertion is only possible after the inserter has been set up."); Validate.validState( this.insertionList.isPresent(), "Insertion is only possible if setting up the inserter succeeded."); if (this.differentAfterList) { this.afterList.add(0, statement); } else if (this.breakDetector.containsControlFlowBreakingStatement(this.markedStatement)) { // we are trying to insert after a control flow breaking statement. That’s // dangerous, better surround with try…finally final AST factory = this.markedStatement.getAST(); final TryStatement tryStatement = factory.newTryStatement(); tryStatement.setFinally(factory.newBlock()); @SuppressWarnings("unchecked") final List<Statement> tryBodyStatements = tryStatement.getBody().statements(); @SuppressWarnings("unchecked") final List<Statement> finallyStatements = tryStatement.getFinally().statements(); final Statement copy = (Statement) ASTNode.copySubtree(factory, this.markedStatement); tryBodyStatements.add(copy); finallyStatements.add(statement); this.insertionList.get().set(this.markerIndex, tryStatement); this.markedStatement = tryStatement; this.differentAfterList = true; this.afterList = finallyStatements; } else { this.insertionList.get().add(this.markerIndex, statement); } }
/** * Inserts the provided {@code statement} before the node this inserter was created for. Tries to * put the {@code statement} as close to the node as possible. * * @param statement The statement to insert before the insertion node. */ void insertBefore(final Statement statement) { Validate.notNull(statement); Validate.validState( this.insertionList != null, "Insertion is only possible after the inserter has been set up."); Validate.validState( this.insertionList.isPresent(), "Insertion is only possible if setting up the inserter succeeded."); this.insertionList.get().add(this.markerIndex, statement); this.markerIndex++; }
private void addFaviconToStatusResponse(ServerStatusResponse response) { File var2 = this.getFile("server-icon.png"); if (var2.isFile()) { ByteBuf var3 = Unpooled.buffer(); try { BufferedImage var4 = ImageIO.read(var2); Validate.validState(var4.getWidth() == 64, "Must be 64 pixels wide", new Object[0]); Validate.validState(var4.getHeight() == 64, "Must be 64 pixels high", new Object[0]); ImageIO.write(var4, "PNG", new ByteBufOutputStream(var3)); ByteBuf var5 = Base64.encode(var3); response.setFavicon("data:image/png;base64," + var5.toString(Charsets.UTF_8)); } catch (Exception var9) { logger.error("Couldn\'t load server icon", var9); } finally { var3.release(); } } }
private void a(ServerPing serverping) { File file = this.d("server-icon.png"); if (file.isFile()) { ByteBuf bytebuf = Unpooled.buffer(); try { BufferedImage bufferedimage = ImageIO.read(file); Validate.validState( bufferedimage.getWidth() == 64, "Must be 64 pixels wide", new Object[0]); Validate.validState( bufferedimage.getHeight() == 64, "Must be 64 pixels high", new Object[0]); ImageIO.write(bufferedimage, "PNG", new ByteBufOutputStream(bytebuf)); ByteBuf bytebuf1 = Base64.encode(bytebuf); serverping.setFavicon("data:image/png;base64," + bytebuf1.toString(Charsets.UTF_8)); } catch (Exception exception) { MinecraftServer.LOGGER.error("Couldn\'t load server icon", exception); } finally { bytebuf.release(); } } }
@Override public GenericValue transformOne( final String entityName, final EntityCondition entityCondition, final String lockField, final Transformation transformation) { final List<GenericValue> transformedValues = transform(entityName, entityCondition, null, lockField, transformation); Validate.validState( transformedValues.size() == 1, "Expected one match for %s but found %d: %s", entityCondition, transformedValues.size(), transformedValues); return transformedValues.get(0); }
public void processLoginStart(C00PacketLoginStart packetIn) { Validate.validState( this.currentLoginState == NetHandlerLoginServer.LoginState.HELLO, "Unexpected hello packet", new Object[0]); this.loginGameProfile = packetIn.getProfile(); if (this.server.isServerInOnlineMode() && !this.networkManager.isLocalChannel()) { this.currentLoginState = NetHandlerLoginServer.LoginState.KEY; this.networkManager.sendPacket( new S01PacketEncryptionRequest( this.serverId, this.server.getKeyPair().getPublic(), this.field_147330_e)); } else { this.currentLoginState = NetHandlerLoginServer.LoginState.READY_TO_ACCEPT; } }
/** 检查ApplicationContext不为空. */ private static void assertContextInjected() { Validate.validState( applicationContext != null, "applicaitonContext属性未注入, 请在applicationContext.xml中定义SpringContextHolder."); }
public void processEncryptionResponse(C01PacketEncryptionResponse packetIn) { Validate.validState( this.currentLoginState == NetHandlerLoginServer.LoginState.KEY, "Unexpected key packet", new Object[0]); PrivateKey var2 = this.server.getKeyPair().getPrivate(); if (!Arrays.equals(this.field_147330_e, packetIn.func_149299_b(var2))) { throw new IllegalStateException("Invalid nonce!"); } else { this.secretKey = packetIn.func_149300_a(var2); this.currentLoginState = NetHandlerLoginServer.LoginState.AUTHENTICATING; this.networkManager.enableEncryption(this.secretKey); (new Thread("User Authenticator #" + AUTHENTICATOR_THREAD_ID.incrementAndGet()) { private static final String __OBFID = "CL_00002268"; public void run() { GameProfile var1 = NetHandlerLoginServer.this.loginGameProfile; try { String var2 = (new BigInteger( CryptManager.getServerIdHash( NetHandlerLoginServer.this.serverId, NetHandlerLoginServer.this.server.getKeyPair().getPublic(), NetHandlerLoginServer.this.secretKey))) .toString(16); NetHandlerLoginServer.this.loginGameProfile = NetHandlerLoginServer.this .server .getMinecraftSessionService() .hasJoinedServer(new GameProfile((UUID) null, var1.getName()), var2); if (NetHandlerLoginServer.this.loginGameProfile != null) { NetHandlerLoginServer.logger.info( "UUID of player " + NetHandlerLoginServer.this.loginGameProfile.getName() + " is " + NetHandlerLoginServer.this.loginGameProfile.getId()); NetHandlerLoginServer.this.currentLoginState = NetHandlerLoginServer.LoginState.READY_TO_ACCEPT; } else if (NetHandlerLoginServer.this.server.isSinglePlayer()) { NetHandlerLoginServer.logger.warn( "Failed to verify username but will let them in anyway!"); NetHandlerLoginServer.this.loginGameProfile = NetHandlerLoginServer.this.getOfflineProfile(var1); NetHandlerLoginServer.this.currentLoginState = NetHandlerLoginServer.LoginState.READY_TO_ACCEPT; } else { NetHandlerLoginServer.this.closeConnection("Failed to verify username!"); NetHandlerLoginServer.logger.error( "Username \'" + NetHandlerLoginServer.this.loginGameProfile.getName() + "\' tried to join with an invalid session"); } } catch (AuthenticationUnavailableException var3) { if (NetHandlerLoginServer.this.server.isSinglePlayer()) { NetHandlerLoginServer.logger.warn( "Authentication servers are down but will let them in anyway!"); NetHandlerLoginServer.this.loginGameProfile = NetHandlerLoginServer.this.getOfflineProfile(var1); NetHandlerLoginServer.this.currentLoginState = NetHandlerLoginServer.LoginState.READY_TO_ACCEPT; } else { NetHandlerLoginServer.this.closeConnection( "Authentication servers are down. Please try again later, sorry!"); NetHandlerLoginServer.logger.error( "Couldn\'t verify username because servers are unavailable"); } } } }) .start(); } }
private Table updateOrDeleteManagedEntity( final ClassOrInterfaceTypeDetails managedEntity, final Database database) { // Update the attributes of the existing JPA-related annotation final AnnotationMetadata jpaAnnotation = getJpaAnnotation(managedEntity); Validate.validState( jpaAnnotation != null, "Neither @%s nor @%s found on existing DBRE-managed entity %s", ROO_JPA_ACTIVE_RECORD.getSimpleTypeName(), ROO_JPA_ENTITY.getSimpleTypeName(), managedEntity.getName().getFullyQualifiedTypeName()); // Find table in database using 'table' and 'schema' attributes from the // JPA annotation final AnnotationAttributeValue<?> tableAttribute = jpaAnnotation.getAttribute(new JavaSymbolName("table")); final String errMsg = "Unable to maintain database-managed entity " + managedEntity.getName().getFullyQualifiedTypeName() + " because its associated table could not be found"; Validate.notNull(tableAttribute, errMsg); final String tableName = (String) tableAttribute.getValue(); Validate.notBlank(tableName, errMsg); final AnnotationAttributeValue<?> schemaAttribute = jpaAnnotation.getAttribute(new JavaSymbolName("schema")); final String schemaName = schemaAttribute != null ? (String) schemaAttribute.getValue() : null; final Table table = database.getTable(tableName, schemaName); if (table == null) { // Table is missing and probably has been dropped so delete managed // type and its identifier if applicable deleteManagedType(managedEntity, "no database table called '" + tableName + "'"); return null; } table.setIncludeNonPortableAttributes(database.isIncludeNonPortableAttributes()); table.setDisableVersionFields(database.isDisableVersionFields()); table.setDisableGeneratedIdentifiers(database.isDisableGeneratedIdentifiers()); // Update the @RooJpaEntity/@RooJpaActiveRecord attributes final AnnotationMetadataBuilder jpaAnnotationBuilder = new AnnotationMetadataBuilder(jpaAnnotation); final Set<JavaSymbolName> attributesToDeleteIfPresent = new LinkedHashSet<JavaSymbolName>(); manageIdentifier( managedEntity.getName(), jpaAnnotationBuilder, attributesToDeleteIfPresent, table); // Manage versionField attribute final AnnotationAttributeValue<?> versionFieldAttribute = jpaAnnotation.getAttribute(new JavaSymbolName(VERSION_FIELD)); if (versionFieldAttribute == null) { if (hasVersionField(table)) { attributesToDeleteIfPresent.add(new JavaSymbolName(VERSION_FIELD)); } else { jpaAnnotationBuilder.addStringAttribute(VERSION_FIELD, ""); } } else { final String versionFieldValue = (String) versionFieldAttribute.getValue(); if (hasVersionField(table) && (StringUtils.isBlank(versionFieldValue) || VERSION.equals(versionFieldValue))) { attributesToDeleteIfPresent.add(new JavaSymbolName(VERSION_FIELD)); } } final AnnotationAttributeValue<?> sequenceNameFieldAttribute = jpaAnnotation.getAttribute(new JavaSymbolName(SEQUENCE_NAME_FIELD)); if (sequenceNameFieldAttribute == null) { if (!table.isDisableGeneratedIdentifiers()) { attributesToDeleteIfPresent.add(new JavaSymbolName(SEQUENCE_NAME_FIELD)); } else { jpaAnnotationBuilder.addStringAttribute(SEQUENCE_NAME_FIELD, ""); } } else { final String sequenceNameFieldValue = (String) sequenceNameFieldAttribute.getValue(); if (!table.isDisableGeneratedIdentifiers() && ("".equals(sequenceNameFieldValue))) { attributesToDeleteIfPresent.add(new JavaSymbolName(SEQUENCE_NAME_FIELD)); } } // Update the annotation on disk final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(managedEntity); cidBuilder.updateTypeAnnotation(jpaAnnotationBuilder.build(), attributesToDeleteIfPresent); typeManagementService.createOrUpdateTypeOnDisk(cidBuilder.build()); return table; }