@Override public void run() { while (threadRunFlag) { if (queue.isEmpty()) { System.out.println("wait add new Data to upload thread!"); synchronized (this) { try { wait(); } catch (InterruptedException e) { e.printStackTrace(); } } } else { Entity entity = (Entity) queue.remove(); System.out.println("current upload is:" + entity.toString()); System.out.println("list size i s :" + queue.size()); try { Thread.sleep(300); } catch (InterruptedException e) { e.printStackTrace(); } } } }
private void verifyCurrentUserIsAuthorized(Process process, Task task) throws ForbiddenError, BadRequestError { if (process == null) throw new BadRequestError(Constants.ExceptionCodes.process_does_not_exist); String taskId = task != null ? task.getTaskInstanceId() : null; Entity principal = identityHelper.getPrincipal(); if (principal == null || StringUtils.isEmpty(principal.getEntityId())) { LOG.error( "Forbidden: Unauthorized user or user with no userId (e.g. system user) attempting to create a request for task: " + taskId); throw new ForbiddenError(); } if (!principal.hasRole(process, AuthorizationRole.OVERSEER)) { if (task != null && !task.isCandidateOrAssignee(principal)) { LOG.warn( "Forbidden: Unauthorized principal " + principal.toString() + " attempting to access task " + taskId); throw new ForbiddenError(); } } }
// public static void createSystemTables(Model model) // { // Field field; // Entity entity; // // try // { // FileMetaInfo fileinfo = model.getFileInfo(); // UserMetaInfo userinfo = model.getUserInfo(); // RoleMetaInfo roleinfo = model.getRoleInfo(); // EntityMetaInfo entityinfo = model.getEntityInfo(); // ScreenMetaInfo screeninfo = model.getScreenInfo(); // // // files // entity = new Entity(fileinfo.getEntity(), "", model.getDatabase(), true); // // field = new Field(entity, Field.Type.INT, fileinfo.getColumnNameID(), "", // true, false, false, ""); // entity.addField(field); // entity.addKey(field,null); // // // Vector<Field> constraint_name = new Vector<Field>(); // // field = new Field(entity, Field.Type.STRING, // fileinfo.getColumnNameFilename(), "", false, true, false, ""); // field.setVarCharLength(1024); // entity.addField(field); // // constraint_name.add(field); // // field = new Field(entity, Field.Type.STRING, // fileinfo.getColumnNameEntityOwner(), "", false, true, false, // ""); // field.setVarCharLength(1024); // entity.addField(field); // // constraint_name.add(field); // // // entity.addKey(constraint_name); // // field = new Field(entity, Field.Type.STRING, // fileinfo.getColumnNameLocalFileName(), "", false, true, false, // ""); // field.setVarCharLength(1024); // entity.addField(field); // // field = new Field(entity, Field.Type.STRING, // fileinfo.getColumnNameMime(), "", false, true, false, ""); // field.setVarCharLength(255); // entity.addField(field); // // // users // entity = new Entity(userinfo.getEntity(), "", model.getDatabase(), true); // // field = new Field(entity, Field.Type.INT, userinfo.getColumnNameID(), "", // true, false, false, ""); // entity.addField(field); // entity.addKey(field); // // field = new Field(entity, Field.Type.STRING, // userinfo.getColumnNameInitials(), "", false, true, false, ""); // field.setVarCharLength(32); // entity.addField(field); // // field = new Field(entity, Field.Type.STRING, // userinfo.getColumnNameLastName(), "", false, true, false, ""); // field.setVarCharLength(32); // entity.addField(field); // // // name can only be unique if not null! // field = new Field(entity, Field.Type.STRING, // userinfo.getColumnNameUsername(), "", false, false, false, ""); // field.setVarCharLength(32); // entity.addField(field); // entity.addKey(field); // make the username unique // // field = new Field(entity, Field.Type.STRING, // userinfo.getColumnNamePassword(), "", false, true, false, ""); // field.setVarCharLength(32); // entity.addField(field); // // field = new Field(entity, Field.Type.XREF_MULTIPLE, // userinfo.getColumnNameRoles(), "", false, true, false, // ""); // field.setXRefVariables(roleinfo.getEntity(), roleinfo.getColumnNameID(), // roleinfo.getColumnNameRoleName()); // // field.setXRefLinkTable(""); // entity.addField(field); // // // roles // entity = new Entity(roleinfo.getEntity(), "", model.getDatabase(), true); // // field = new Field(entity, Field.Type.INT, roleinfo.getColumnNameID(), "", // true, false, false, ""); // entity.addField(field); // entity.addKey(field); // // // name can only be unique if not null! // field = new Field(entity, Field.Type.STRING, // roleinfo.getColumnNameRoleName(), "", false, false, false, ""); // field.setVarCharLength(255); // entity.addField(field); // entity.addKey(field); // // // entities // entity = new Entity(entityinfo.getEntity(), "", model.getDatabase(), // true); // // field = new Field(entity, Field.Type.INT, entityinfo.getColumnNameID(), // "", true, false, false, ""); // entity.addField(field); // entity.addKey(field); // // // name can only be unique if not null! // field = new Field(entity, Field.Type.STRING, // entityinfo.getColumnNameName(), "", false, false, false, ""); // field.setVarCharLength(255); // entity.addField(field); // entity.addKey(field); // // field = new Field(entity, Field.Type.XREF_MULTIPLE, // entityinfo.getColumnNameRoles(), "", false, true, // false, ""); // field.setXRefVariables(roleinfo.getEntity(), roleinfo.getColumnNameID(), // roleinfo.getColumnNameRoleName()); // // field.setXRefLinkTable(""); // entity.addField(field); // // // screens // entity = new Entity(screeninfo.getEntity(), "", model.getDatabase(), // true); // // field = new Field(entity, Field.Type.INT, screeninfo.getColumnNameID(), // "", true, false, false, ""); // entity.addField(field); // entity.addKey(field); // // field = new Field(entity, Field.Type.STRING, // screeninfo.getColumnNameName(), "", false, true, false, ""); // field.setVarCharLength(255); // entity.addField(field); // // entity.addKey(field); // // field = new Field(entity, Field.Type.XREF_MULTIPLE, // screeninfo.getColumnNameRoles(), "", false, true, // false, ""); // field.setXRefVariables(roleinfo.getEntity(), roleinfo.getColumnNameID(), // roleinfo.getColumnNameRoleName()); // // field.setXRefLinkTable(""); // entity.addField(field); // } // catch (Exception e) // { // } // } @Override public String toString() { StringBuffer result = new StringBuffer(); for (Entity e : getEntities()) { result.append("ENTITY: " + e.toString() + "\n"); // result.append("ENTITY:"+e.getName()+"\n"); } for (Matrix m : getMatrices()) { result.append("MATRIX: " + m.toString() + "\n"); // result.append("ENTITY:"+e.getName()+"\n"); } for (UISchema u : getUserinterface().getAllChildren()) { result.append(u.toString() + "\n"); } return result.toString(); }
public DeathDetail(EntityDeathEvent event) { player = (Player) event.getEntity(); entityDeathEvent = event; // Support for setHealth(0) which is used by essentials to do a suicide try { EntityDamageEvent damageEvent = event.getEntity().getLastDamageCause(); if (damageEvent instanceof EntityDamageByEntityEvent) { Entity damager = ((EntityDamageByEntityEvent) damageEvent).getDamager(); log.debug("damager", damager.toString()); if (damager instanceof Player) { log.debug("Killed by an other player"); if (((Player) damager).getItemInHand().getType().equals(Material.AIR)) { causeOfDeath = DeathEventType.PVP_FISTS; } else { causeOfDeath = DeathEventType.PVP; } murderWeapon = ((Player) damager).getItemInHand().getType().toString(); killer = (Player) damager; } else if (damager instanceof Creature || damager instanceof Slime) { log.debug("We have a creature or slime"); if (damager instanceof Tameable && ((Tameable) damager).isTamed()) { causeOfDeath = DeathEventType.PVP_TAMED; murderWeapon = damager.getType().toString(); killer = (Player) ((Tameable) damager).getOwner(); } else { try { causeOfDeath = DeathEventType.valueOf(damager.getType().toString()); if (damager instanceof Skeleton) { Skeleton skeleton = (Skeleton) damager; causeOfDeath = skeleton.getSkeletonType() == SkeletonType.WITHER ? DeathEventType.WITHER_SKELETON : DeathEventType.SKELETON; } else if (damager instanceof Zombie) { Zombie zombie = (Zombie) damager; causeOfDeath = zombie.isVillager() ? DeathEventType.ZOMBIE_VILLAGER : DeathEventType.ZOMBIE; } } catch (IllegalArgumentException iae) { log.severe("Please notify the developer of the following Error:"); log.severe( "The following damager is not correctly implemented: " + damager.getType().toString()); causeOfDeath = DeathEventType.UNKNOWN; } log.debug("and it is: " + causeOfDeath); } } else if (damager instanceof Projectile) { log.debug("this is a projectile"); log.debug("shooter", ((Projectile) damager).getShooter()); if (((Projectile) damager).getShooter() instanceof Player) { causeOfDeath = DeathEventType.PVP; murderWeapon = ((Projectile) damager).toString().replace("Craft", ""); killer = (Player) ((Projectile) damager).getShooter(); } if (((Projectile) damager).getShooter() == null) { // let's assume that null will only be caused by a dispenser! causeOfDeath = DeathEventType.DISPENSER; murderWeapon = ((Projectile) damager).toString().replace("Craft", ""); } if (((Projectile) damager).getShooter().toString().equalsIgnoreCase("CraftSkeleton")) { causeOfDeath = DeathEventType.SKELETON; murderWeapon = ((Projectile) damager).toString().replace("Craft", ""); } } else if (damager instanceof TNTPrimed) { causeOfDeath = DeathEventType.BLOCK_EXPLOSION; } else { log.info("unknown enitity damager" + damager); } } else if (damageEvent != null) { log.debug("DamageEvent is not by Entity"); try { causeOfDeath = DeathEventType.valueOf(damageEvent.getCause().toString()); } catch (IllegalArgumentException e) { causeOfDeath = DeathEventType.UNKNOWN; } } } catch (NullPointerException npe) { log.debug("normal detection of damageevent failed", npe); log.debug("assuming you did use essentials or similar"); log.debug("which uses setHealth(0) to kill people"); log.info("Deathcause is being set to SUICIDE!"); causeOfDeath = DeathEventType.SUICIDE; murderWeapon = "Essentials"; } if (causeOfDeath == null) { causeOfDeath = DeathEventType.UNKNOWN; murderWeapon = "unknown"; } log.debug("causeOfDeath", causeOfDeath); log.debug("murderWeapon", murderWeapon); log.debug("killer", killer); }