id
int64 1
60k
| buggy
stringlengths 34
37.5k
| fixed
stringlengths 6
37.4k
|
---|---|---|
1,401 |
protected void setToBeShown(boolean value, boolean onOk) {
getGeneralSettingsInstance().setConfirmExtractFiles(value);
}
protected boolean shouldSaveOptionsOnCancel() {
return true;
<BUG>}
protected Action[] createActions() {</BUG>
setOKButtonText(CommonBundle.getYesButtonText());
return new Action[]{getOKAction(), getCancelAction()};
}
|
protected void setToBeShown(boolean value, boolean onOk) {
getGeneralSettingsInstance().setConfirmExtractFiles(value);
}
protected boolean shouldSaveOptionsOnCancel() {
return true;
}
@NotNull
protected Action[] createActions() {
setOKButtonText(CommonBundle.getYesButtonText());
return new Action[]{getOKAction(), getCancelAction()};
}
|
1,402 |
public static int execAndGetResult(@NotNull final List<String> command) throws ExecutionException, InterruptedException {
assert command.size() > 0;
final GeneralCommandLine commandLine = new GeneralCommandLine(command);
final Process process = commandLine.createProcess();
return process.waitFor();
<BUG>}
public static String loadTemplate(@NotNull final ClassLoader loader,</BUG>
@NotNull final String templateName,
@Nullable final Map<String, String> variables) throws IOException {
@SuppressWarnings("IOResourceOpenedButNotSafelyClosed") final InputStream stream = loader.getResourceAsStream(templateName);
|
public static int execAndGetResult(@NotNull final List<String> command) throws ExecutionException, InterruptedException {
assert command.size() > 0;
final GeneralCommandLine commandLine = new GeneralCommandLine(command);
final Process process = commandLine.createProcess();
return process.waitFor();
}
@NotNull
public static String loadTemplate(@NotNull final ClassLoader loader,
@NotNull final String templateName,
@Nullable final Map<String, String> variables) throws IOException {
@SuppressWarnings("IOResourceOpenedButNotSafelyClosed") final InputStream stream = loader.getResourceAsStream(templateName);
|
1,403 |
if (pos >= 0) {
buffer.replace(pos, pos + name.length(), var.getValue());
}
}
return buffer.toString();
<BUG>}
public static File createTempExecutableScript(@NotNull final String prefix,</BUG>
@NotNull final String suffix,
@NotNull final String source) throws IOException, ExecutionException {
final File tempFile = FileUtil.createTempFile(prefix, suffix);
|
if (pos >= 0) {
buffer.replace(pos, pos + name.length(), var.getValue());
}
}
return buffer.toString();
}
@NotNull
public static File createTempExecutableScript(@NotNull final String prefix,
@NotNull final String suffix,
@NotNull final String source) throws IOException, ExecutionException {
final File tempFile = FileUtil.createTempFile(prefix, suffix);
|
1,404 |
FileUtil.writeToFile(tempFile, source);
if (!tempFile.setExecutable(true, true)) {
throw new ExecutionException("Failed to make temp file executable: " + tempFile);
}
return tempFile;
<BUG>}
public static String getOsascriptPath() {</BUG>
return "/usr/bin/osascript";
<BUG>}
public static String getOpenCommandPath() {</BUG>
return "/usr/bin/open";
|
FileUtil.writeToFile(tempFile, source);
if (!tempFile.setExecutable(true, true)) {
throw new ExecutionException("Failed to make temp file executable: " + tempFile);
}
return tempFile;
}
@NotNull
public static String getOsascriptPath() {
return "/usr/bin/osascript";
}
@NotNull
public static String getOpenCommandPath() {
|
1,405 |
reader.close();
}
}
catch (Exception ignored) { }
return null;
<BUG>}
public static ProcessOutput sudoAndGetOutput(@NotNull final String scriptPath,</BUG>
@NotNull final String prompt) throws IOException, ExecutionException {
return sudoAndGetOutput(scriptPath, prompt, null);
<BUG>}
public static ProcessOutput sudoAndGetOutput(@NotNull final String scriptPath,</BUG>
@NotNull final String prompt,
|
reader.close();
}
}
catch (Exception ignored) { }
return null;
}
@NotNull
public static ProcessOutput sudoAndGetOutput(@NotNull final String scriptPath,
@NotNull final String prompt) throws IOException, ExecutionException {
return sudoAndGetOutput(scriptPath, prompt, null);
}
@NotNull
public static ProcessOutput sudoAndGetOutput(@NotNull final String scriptPath,
@NotNull final String prompt,
|
1,406 |
});
playstop.addListener(new TextTooltip(txt("gui.tooltip.playstop"), skin));
TimeComponent timeComponent = new TimeComponent(skin, ui);
timeComponent.initialize();
CollapsiblePane time = new CollapsiblePane(ui, txt("gui.time"), timeComponent.getActor(), skin, true, playstop);
<BUG>time.align(Align.left);
mainActors.add(time);</BUG>
panes.put(timeComponent.getClass().getSimpleName(), time);
if (Constants.desktop) {
recCamera = new OwnImageButton(skin, "rec");
|
});
playstop.addListener(new TextTooltip(txt("gui.tooltip.playstop"), skin));
TimeComponent timeComponent = new TimeComponent(skin, ui);
timeComponent.initialize();
CollapsiblePane time = new CollapsiblePane(ui, txt("gui.time"), timeComponent.getActor(), skin, true, playstop);
time.align(Align.left).columnAlign(Align.left);
mainActors.add(time);
panes.put(timeComponent.getClass().getSimpleName(), time);
if (Constants.desktop) {
recCamera = new OwnImageButton(skin, "rec");
|
1,407 |
playCamera.addListener(new TextTooltip(txt("gui.tooltip.playcamera"), skin));
}
CameraComponent cameraComponent = new CameraComponent(skin, ui);
cameraComponent.initialize();
CollapsiblePane camera = new CollapsiblePane(ui, txt("gui.camera"), cameraComponent.getActor(), skin, false, recCamera, playCamera);
<BUG>camera.align(Align.left);
mainActors.add(camera);</BUG>
panes.put(cameraComponent.getClass().getSimpleName(), camera);
<BUG>VisibilityComponent visibilityComponent = new VisibilityComponent(skin, ui, this);
visibilityComponent.setVisibilityEntitites(visibilityEntities, visible);</BUG>
visibilityComponent.initialize();
|
playCamera.addListener(new TextTooltip(txt("gui.tooltip.playcamera"), skin));
}
CameraComponent cameraComponent = new CameraComponent(skin, ui);
cameraComponent.initialize();
CollapsiblePane camera = new CollapsiblePane(ui, txt("gui.camera"), cameraComponent.getActor(), skin, false, recCamera, playCamera);
camera.align(Align.left).columnAlign(Align.left);
mainActors.add(camera);
panes.put(cameraComponent.getClass().getSimpleName(), camera);
VisibilityComponent visibilityComponent = new VisibilityComponent(skin, ui);
visibilityComponent.setVisibilityEntitites(visibilityEntities, visible);
visibilityComponent.initialize();
|
1,408 |
panes.put(cameraComponent.getClass().getSimpleName(), camera);
<BUG>VisibilityComponent visibilityComponent = new VisibilityComponent(skin, ui, this);
visibilityComponent.setVisibilityEntitites(visibilityEntities, visible);</BUG>
visibilityComponent.initialize();
CollapsiblePane visibility = new CollapsiblePane(ui, txt("gui.visibility"), visibilityComponent.getActor(), skin, true);
<BUG>visibility.align(Align.left);
mainActors.add(visibility);</BUG>
panes.put(visibilityComponent.getClass().getSimpleName(), visibility);
VisualEffectsComponent visualEffectsComponent = new VisualEffectsComponent(skin, ui);
visualEffectsComponent.initialize();
|
panes.put(cameraComponent.getClass().getSimpleName(), camera);
VisibilityComponent visibilityComponent = new VisibilityComponent(skin, ui);
visibilityComponent.setVisibilityEntitites(visibilityEntities, visible);
visibilityComponent.initialize();
CollapsiblePane visibility = new CollapsiblePane(ui, txt("gui.visibility"), visibilityComponent.getActor(), skin, true);
visibility.align(Align.left).columnAlign(Align.left);
mainActors.add(visibility);
panes.put(visibilityComponent.getClass().getSimpleName(), visibility);
VisualEffectsComponent visualEffectsComponent = new VisualEffectsComponent(skin, ui);
visualEffectsComponent.initialize();
|
1,409 |
panes.put(visualEffectsComponent.getClass().getSimpleName(), visualEffects);
ObjectsComponent objectsComponent = new ObjectsComponent(skin, ui);
objectsComponent.setSceneGraph(sg);
objectsComponent.initialize();
CollapsiblePane objects = new CollapsiblePane(ui, txt("gui.objects"), objectsComponent.getActor(), skin, false);
<BUG>objects.align(Align.left);
mainActors.add(objects);</BUG>
panes.put(objectsComponent.getClass().getSimpleName(), objects);
GaiaComponent gaiaComponent = new GaiaComponent(skin, ui);
gaiaComponent.initialize();
|
panes.put(visualEffectsComponent.getClass().getSimpleName(), visualEffects);
ObjectsComponent objectsComponent = new ObjectsComponent(skin, ui);
objectsComponent.setSceneGraph(sg);
objectsComponent.initialize();
CollapsiblePane objects = new CollapsiblePane(ui, txt("gui.objects"), objectsComponent.getActor(), skin, false);
objects.align(Align.left).columnAlign(Align.left);
mainActors.add(objects);
panes.put(objectsComponent.getClass().getSimpleName(), objects);
GaiaComponent gaiaComponent = new GaiaComponent(skin, ui);
gaiaComponent.initialize();
|
1,410 |
if (Constants.desktop) {
MusicComponent musicComponent = new MusicComponent(skin, ui);
musicComponent.initialize();
Actor[] musicActors = MusicActorsManager.getMusicActors() != null ? MusicActorsManager.getMusicActors().getActors(skin) : null;
CollapsiblePane music = new CollapsiblePane(ui, txt("gui.music"), musicComponent.getActor(), skin, true, musicActors);
<BUG>music.align(Align.left);
mainActors.add(music);</BUG>
panes.put(musicComponent.getClass().getSimpleName(), music);
}
Button switchWebgl = new OwnTextButton(txt("gui.webgl.back"), skin, "link");
|
if (Constants.desktop) {
MusicComponent musicComponent = new MusicComponent(skin, ui);
musicComponent.initialize();
Actor[] musicActors = MusicActorsManager.getMusicActors() != null ? MusicActorsManager.getMusicActors().getActors(skin) : null;
CollapsiblePane music = new CollapsiblePane(ui, txt("gui.music"), musicComponent.getActor(), skin, true, musicActors);
music.align(Align.left).columnAlign(Align.left);
mainActors.add(music);
panes.put(musicComponent.getClass().getSimpleName(), music);
}
Button switchWebgl = new OwnTextButton(txt("gui.webgl.back"), skin, "link");
|
1,411 |
headerGroup.addActor(expandIcon);
headerGroup.addActor(detachIcon);
addActor(headerGroup);
expandIcon.setChecked(expanded);
}
<BUG>public void expand() {
</BUG>
if (!expandIcon.isChecked()) {
expandIcon.setChecked(true);
}
|
headerGroup.addActor(expandIcon);
headerGroup.addActor(detachIcon);
addActor(headerGroup);
expandIcon.setChecked(expanded);
}
public void expandPane() {
if (!expandIcon.isChecked()) {
expandIcon.setChecked(true);
|
1,412 |
</BUG>
if (!expandIcon.isChecked()) {
expandIcon.setChecked(true);
}
}
<BUG>public void collapse() {
</BUG>
if (expandIcon.isChecked()) {
expandIcon.setChecked(false);
}
|
headerGroup.addActor(expandIcon);
headerGroup.addActor(detachIcon);
addActor(headerGroup);
expandIcon.setChecked(expanded);
}
public void expandPane() {
if (!expandIcon.isChecked()) {
expandIcon.setChecked(true);
}
}
public void collapsePane() {
if (expandIcon.isChecked()) {
expandIcon.setChecked(false);
|
1,413 |
timeWarp = new OwnLabel(getFormattedTimeWrap(), skin, "warp");
timeWarp.setName("time warp");
Container wrapWrapper = new Container(timeWarp);
wrapWrapper.width(60f * GlobalConf.SCALE_FACTOR);
wrapWrapper.align(Align.center);
<BUG>VerticalGroup timeGroup = new VerticalGroup().align(Align.left).space(3 * GlobalConf.SCALE_FACTOR).padTop(3 * GlobalConf.SCALE_FACTOR);
</BUG>
HorizontalGroup dateGroup = new HorizontalGroup();
dateGroup.space(4 * GlobalConf.SCALE_FACTOR);
dateGroup.addActor(date);
|
timeWarp = new OwnLabel(getFormattedTimeWrap(), skin, "warp");
timeWarp.setName("time warp");
Container wrapWrapper = new Container(timeWarp);
wrapWrapper.width(60f * GlobalConf.SCALE_FACTOR);
wrapWrapper.align(Align.center);
VerticalGroup timeGroup = new VerticalGroup().align(Align.left).columnAlign(Align.left).space(3 * GlobalConf.SCALE_FACTOR).padTop(3 * GlobalConf.SCALE_FACTOR);
HorizontalGroup dateGroup = new HorizontalGroup();
dateGroup.space(4 * GlobalConf.SCALE_FACTOR);
dateGroup.addActor(date);
|
1,414 |
focusListScrollPane.setFadeScrollBars(false);
focusListScrollPane.setScrollingDisabled(true, false);
focusListScrollPane.setHeight(tree ? 200 * GlobalConf.SCALE_FACTOR : 100 * GlobalConf.SCALE_FACTOR);
focusListScrollPane.setWidth(160);
}
<BUG>VerticalGroup objectsGroup = new VerticalGroup().align(Align.left).space(3 * GlobalConf.SCALE_FACTOR);
</BUG>
objectsGroup.addActor(searchBox);
if (focusListScrollPane != null) {
objectsGroup.addActor(focusListScrollPane);
|
focusListScrollPane.setFadeScrollBars(false);
focusListScrollPane.setScrollingDisabled(true, false);
focusListScrollPane.setHeight(tree ? 200 * GlobalConf.SCALE_FACTOR : 100 * GlobalConf.SCALE_FACTOR);
focusListScrollPane.setWidth(160);
}
VerticalGroup objectsGroup = new VerticalGroup().align(Align.left).columnAlign(Align.left).space(3 * GlobalConf.SCALE_FACTOR);
objectsGroup.addActor(searchBox);
if (focusListScrollPane != null) {
objectsGroup.addActor(focusListScrollPane);
|
1,415 |
private static FGStorageManager instance;
private final Logger logger = FoxGuardMain.instance().getLogger();</BUG>
private final Set<LoadEntry> loaded = new HashSet<>();
private final Path directory = getDirectory();
private final Map<String, Path> worldDirectories;
<BUG>private FGStorageManager() {
defaultModifiedMap = new CacheMap<>((k, m) -> {</BUG>
if (k instanceof IFGObject) {
m.put((IFGObject) k, true);
return true;
|
private static FGStorageManager instance;
public final HashMap<IFGObject, Boolean> defaultModifiedMap;
private final UserStorageService userStorageService;
private final Logger logger = FoxGuardMain.instance().getLogger();
private final Set<LoadEntry> loaded = new HashSet<>();
private final Path directory = getDirectory();
private final Map<String, Path> worldDirectories;
private FGStorageManager() {
userStorageService = FoxGuardMain.instance().getUserStorage();
defaultModifiedMap = new CacheMap<>((k, m) -> {
if (k instanceof IFGObject) {
m.put((IFGObject) k, true);
return true;
|
1,416 |
constructDirectory(singleDir);
try {
fgObject.save(singleDir);
} catch (Exception e) {
<BUG>logger.error("There was an error while saving region \"" + name + "\"!", e);
</BUG>
}
<BUG>logger.info("Saving metadata for region \"" + name + "\"");
</BUG>
try (DB metaDB = DBMaker.fileDB(singleDir.resolve("metadata.foxdb").normalize().toString()).make()) {
|
constructDirectory(singleDir);
try {
fgObject.save(singleDir);
} catch (Exception e) {
logger.error("There was an error while saving region " + logName + "!", e);
}
logger.info("Saving metadata for region " + logName);
try (DB metaDB = DBMaker.fileDB(singleDir.resolve("metadata.foxdb").normalize().toString()).make()) {
|
1,417 |
metaCategory.set(FGUtil.getCategory(fgObject));
<BUG>metaType.set(fgObject.getUniqueTypeString());
metaEnabled.set(fgObject.isEnabled());</BUG>
}
} else {
<BUG>logger.info("Region \"" + name + "\" is already up to date. Skipping...");
</BUG>
}
mainMap.put(name, FGUtil.getCategory(fgObject));
<BUG>typeMap.put(name, fgObject.getUniqueTypeString());
enabledMap.put(name, fgObject.isEnabled());</BUG>
defaultModifiedMap.put(fgObject, false);
|
metaCategory.set(FGUtil.getCategory(fgObject));
metaType.set(fgObject.getUniqueTypeString());
metaOwner.set(owner);
metaEnabled.set(fgObject.isEnabled());
}
} else {
logger.info("Region " + logName + " is already up to date. Skipping...");
}
mainMap.put(name, FGUtil.getCategory(fgObject));
typeMap.put(name, fgObject.getUniqueTypeString());
ownerMap.put(name, owner);
enabledMap.put(name, fgObject.isEnabled());
defaultModifiedMap.put(fgObject, false);
|
1,418 |
mainMap.put(name, FGUtil.getCategory(fgObject));
<BUG>typeMap.put(name, fgObject.getUniqueTypeString());
enabledMap.put(name, fgObject.isEnabled());</BUG>
defaultModifiedMap.put(fgObject, false);
} else {
<BUG>logger.info("Region " + fgObject.getName() + " does not need saving. Skipping...");
</BUG>
}
if (fgObject.saveLinks()) {
linksMap.put(name, serializeHandlerList(fgObject.getHandlers()));
|
mainMap.put(name, FGUtil.getCategory(fgObject));
typeMap.put(name, fgObject.getUniqueTypeString());
ownerMap.put(name, owner);
enabledMap.put(name, fgObject.isEnabled());
defaultModifiedMap.put(fgObject, false);
} else {
logger.info("Region " + logName + " does not need saving. Skipping...");
}
if (fgObject.saveLinks()) {
linksMap.put(name, serializeHandlerList(fgObject.getHandlers()));
|
1,419 |
constructDirectory(singleDir);
try {
fgObject.save(singleDir);
} catch (Exception e) {
<BUG>logger.error("There was an error while saving world region \"" + name + "\" in world \"" + world.getName() + "\"!", e);
</BUG>
}
<BUG>logger.info("Saving metadata for world region \"" + name + "\"");
</BUG>
try (DB metaDB = DBMaker.fileDB(singleDir.resolve("metadata.foxdb").normalize().toString()).make()) {
|
constructDirectory(singleDir);
try {
fgObject.save(singleDir);
} catch (Exception e) {
logger.error("There was an error while saving world region " + logName + " in world " + world.getName() + "!", e);
}
logger.info("Saving metadata for world region " + logName);
try (DB metaDB = DBMaker.fileDB(singleDir.resolve("metadata.foxdb").normalize().toString()).make()) {
|
1,420 |
metaCategory.set(FGUtil.getCategory(fgObject));
<BUG>metaType.set(fgObject.getUniqueTypeString());
metaEnabled.set(fgObject.isEnabled());</BUG>
}
} else {
<BUG>logger.info("Region \"" + name + "\" is already up to date. Skipping...");
</BUG>
}
mainMap.put(name, FGUtil.getCategory(fgObject));
<BUG>typeMap.put(name, fgObject.getUniqueTypeString());
enabledMap.put(name, fgObject.isEnabled());</BUG>
defaultModifiedMap.put(fgObject, false);
|
metaCategory.set(FGUtil.getCategory(fgObject));
metaType.set(fgObject.getUniqueTypeString());
metaOwner.set(owner);
metaEnabled.set(fgObject.isEnabled());
}
} else {
logger.info("Region " + logName + " is already up to date. Skipping...");
}
mainMap.put(name, FGUtil.getCategory(fgObject));
typeMap.put(name, fgObject.getUniqueTypeString());
ownerMap.put(name, owner);
enabledMap.put(name, fgObject.isEnabled());
defaultModifiedMap.put(fgObject, false);
|
1,421 |
mainMap.put(name, FGUtil.getCategory(fgObject));
<BUG>typeMap.put(name, fgObject.getUniqueTypeString());
enabledMap.put(name, fgObject.isEnabled());</BUG>
defaultModifiedMap.put(fgObject, false);
} else {
<BUG>logger.info("World region " + fgObject.getName() + " does not need saving. Skipping...");
</BUG>
}
if (fgObject.saveLinks()) {
linksMap.put(name, serializeHandlerList(fgObject.getHandlers()));
|
mainMap.put(name, FGUtil.getCategory(fgObject));
typeMap.put(name, fgObject.getUniqueTypeString());
ownerMap.put(name, owner);
enabledMap.put(name, fgObject.isEnabled());
defaultModifiedMap.put(fgObject, false);
} else {
logger.info("World region " + logName + " does not need saving. Skipping...");
}
if (fgObject.saveLinks()) {
linksMap.put(name, serializeHandlerList(fgObject.getHandlers()));
|
1,422 |
String name = fgObject.getName();
Path singleDir = dir.resolve(name.toLowerCase());
</BUG>
boolean shouldSave = fgObject.shouldSave();
if (force || shouldSave) {
<BUG>logger.info((shouldSave ? "S" : "Force s") + "aving handler \"" + name + "\" in directory: " + singleDir);
</BUG>
constructDirectory(singleDir);
try {
fgObject.save(singleDir);
|
String name = fgObject.getName();
UUID owner = fgObject.getOwner();
boolean isOwned = !owner.equals(SERVER_UUID);
Optional<User> userOwner = userStorageService.get(owner);
String logName = (userOwner.isPresent() ? userOwner.get().getName() + ":" : "") + (isOwned ? owner + ":" : "") + name;
if (fgObject.autoSave()) {
Path singleDir = serverDir.resolve(name.toLowerCase());
boolean shouldSave = fgObject.shouldSave();
if (force || shouldSave) {
logger.info((shouldSave ? "S" : "Force s") + "aving handler " + logName + " in directory: " + singleDir);
constructDirectory(singleDir);
try {
fgObject.save(singleDir);
|
1,423 |
constructDirectory(singleDir);
try {
fgObject.save(singleDir);
} catch (Exception e) {
<BUG>logger.error("There was an error while saving region \"" + name + "\"!", e);
</BUG>
}
<BUG>logger.info("Saving metadata for region \"" + name + "\"");
</BUG>
try (DB metaDB = DBMaker.fileDB(singleDir.resolve("metadata.foxdb").normalize().toString()).make()) {
|
constructDirectory(singleDir);
try {
fgObject.save(singleDir);
} catch (Exception e) {
logger.error("There was an error while saving region " + logName + "!", e);
}
logger.info("Saving metadata for region " + logName);
try (DB metaDB = DBMaker.fileDB(singleDir.resolve("metadata.foxdb").normalize().toString()).make()) {
|
1,424 |
metaCategory.set(FGUtil.getCategory(fgObject));
<BUG>metaType.set(fgObject.getUniqueTypeString());
metaEnabled.set(fgObject.isEnabled());</BUG>
}
} else {
<BUG>logger.info("Region \"" + name + "\" is already up to date. Skipping...");
</BUG>
}
mainMap.put(name, FGUtil.getCategory(fgObject));
<BUG>typeMap.put(name, fgObject.getUniqueTypeString());
enabledMap.put(name, fgObject.isEnabled());</BUG>
defaultModifiedMap.put(fgObject, false);
|
metaCategory.set(FGUtil.getCategory(fgObject));
metaType.set(fgObject.getUniqueTypeString());
metaOwner.set(owner);
metaEnabled.set(fgObject.isEnabled());
}
} else {
logger.info("Region " + logName + " is already up to date. Skipping...");
}
mainMap.put(name, FGUtil.getCategory(fgObject));
typeMap.put(name, fgObject.getUniqueTypeString());
ownerMap.put(name, owner);
enabledMap.put(name, fgObject.isEnabled());
defaultModifiedMap.put(fgObject, false);
|
1,425 |
mainMap.put(name, FGUtil.getCategory(fgObject));
<BUG>typeMap.put(name, fgObject.getUniqueTypeString());
enabledMap.put(name, fgObject.isEnabled());</BUG>
defaultModifiedMap.put(fgObject, false);
} else {
<BUG>logger.info("Region " + fgObject.getName() + " does not need saving. Skipping...");
</BUG>
}
if (fgObject.saveLinks()) {
linksMap.put(name, serializeHandlerList(fgObject.getHandlers()));
|
mainMap.put(name, FGUtil.getCategory(fgObject));
typeMap.put(name, fgObject.getUniqueTypeString());
ownerMap.put(name, owner);
enabledMap.put(name, fgObject.isEnabled());
defaultModifiedMap.put(fgObject, false);
} else {
logger.info("Region " + logName + " does not need saving. Skipping...");
}
if (fgObject.saveLinks()) {
linksMap.put(name, serializeHandlerList(fgObject.getHandlers()));
|
1,426 |
if (fgObject.autoSave()) {
Path singleDir = dir.resolve(name.toLowerCase());
</BUG>
boolean shouldSave = fgObject.shouldSave();
if (force || shouldSave) {
<BUG>logger.info((shouldSave ? "S" : "Force s") + "aving world region \"" + name + "\" in directory: " + singleDir);
</BUG>
constructDirectory(singleDir);
try {
fgObject.save(singleDir);
|
if (fgObject.autoSave()) {
Path singleDir = serverDir.resolve(name.toLowerCase());
boolean shouldSave = fgObject.shouldSave();
if (force || shouldSave) {
logger.info((shouldSave ? "S" : "Force s") + "aving world region " + logName + " in directory: " + singleDir);
constructDirectory(singleDir);
try {
fgObject.save(singleDir);
|
1,427 |
</BUG>
constructDirectory(singleDir);
try {
fgObject.save(singleDir);
} catch (Exception e) {
<BUG>logger.error("There was an error while saving world region \"" + name + "\" in world \"" + world.getName() + "\"!", e);
</BUG>
}
<BUG>logger.info("Saving metadata for world region \"" + name + "\"");
</BUG>
try (DB metaDB = DBMaker.fileDB(singleDir.resolve("metadata.foxdb").normalize().toString()).make()) {
|
if (fgObject.autoSave()) {
Path singleDir = serverDir.resolve(name.toLowerCase());
boolean shouldSave = fgObject.shouldSave();
if (force || shouldSave) {
logger.info((shouldSave ? "S" : "Force s") + "aving world region " + logName + " in directory: " + singleDir);
constructDirectory(singleDir);
try {
fgObject.save(singleDir);
} catch (Exception e) {
logger.error("There was an error while saving world region " + logName + " in world " + world.getName() + "!", e);
}
logger.info("Saving metadata for world region " + logName);
try (DB metaDB = DBMaker.fileDB(singleDir.resolve("metadata.foxdb").normalize().toString()).make()) {
|
1,428 |
metaCategory.set(FGUtil.getCategory(fgObject));
<BUG>metaType.set(fgObject.getUniqueTypeString());
metaEnabled.set(fgObject.isEnabled());</BUG>
}
} else {
<BUG>logger.info("Region \"" + name + "\" is already up to date. Skipping...");
}</BUG>
mainMap.put(name, FGUtil.getCategory(fgObject));
<BUG>typeMap.put(name, fgObject.getUniqueTypeString());
enabledMap.put(name, fgObject.isEnabled());</BUG>
defaultModifiedMap.put(fgObject, false);
|
metaCategory.set(FGUtil.getCategory(fgObject));
metaType.set(fgObject.getUniqueTypeString());
metaOwner.set(owner);
metaEnabled.set(fgObject.isEnabled());
}
} else {
logger.info("Region " + name + " is already up to date. Skipping...");
}
mainMap.put(name, FGUtil.getCategory(fgObject));
typeMap.put(name, fgObject.getUniqueTypeString());
ownerMap.put(name, owner);
enabledMap.put(name, fgObject.isEnabled());
|
1,429 |
mainMap.put(name, FGUtil.getCategory(fgObject));
<BUG>typeMap.put(name, fgObject.getUniqueTypeString());
enabledMap.put(name, fgObject.isEnabled());</BUG>
defaultModifiedMap.put(fgObject, false);
} else {
<BUG>logger.info("World region " + fgObject.getName() + " does not need saving. Skipping...");
</BUG>
}
if (fgObject.saveLinks()) {
linksMap.put(name, serializeHandlerList(fgObject.getHandlers()));
|
mainMap.put(name, FGUtil.getCategory(fgObject));
typeMap.put(name, fgObject.getUniqueTypeString());
ownerMap.put(name, owner);
enabledMap.put(name, fgObject.isEnabled());
defaultModifiedMap.put(fgObject, false);
} else {
logger.info("World region " + logName + " does not need saving. Skipping...");
}
if (fgObject.saveLinks()) {
linksMap.put(name, serializeHandlerList(fgObject.getHandlers()));
|
1,430 |
public synchronized void loadRegionLinks() {
logger.info("Loading region links");
try (DB mainDB = DBMaker.fileDB(directory.resolve("regions.foxdb").normalize().toString()).make()) {
Map<String, String> linksMap = mainDB.hashMap("links", Serializer.STRING, Serializer.STRING).createOrOpen();
linksMap.entrySet().forEach(entry -> {
<BUG>IRegion region = FGManager.getInstance().getRegion(entry.getKey());
if (region != null) {
logger.info("Loading links for region \"" + region.getName() + "\"");</BUG>
String handlersString = entry.getValue();
|
public synchronized void loadRegionLinks() {
logger.info("Loading region links");
try (DB mainDB = DBMaker.fileDB(directory.resolve("regions.foxdb").normalize().toString()).make()) {
Map<String, String> linksMap = mainDB.hashMap("links", Serializer.STRING, Serializer.STRING).createOrOpen();
linksMap.entrySet().forEach(entry -> {
Optional<IRegion> regionOpt = FGManager.getInstance().getRegion(entry.getKey());
if (regionOpt.isPresent()) {
IRegion region = regionOpt.get();
logger.info("Loading links for region \"" + region.getName() + "\"");
String handlersString = entry.getValue();
|
1,431 |
public synchronized void loadWorldRegionLinks(World world) {
logger.info("Loading world region links for world \"" + world.getName() + "\"");
try (DB mainDB = DBMaker.fileDB(worldDirectories.get(world.getName()).resolve("wregions.foxdb").normalize().toString()).make()) {
Map<String, String> linksMap = mainDB.hashMap("links", Serializer.STRING, Serializer.STRING).createOrOpen();
linksMap.entrySet().forEach(entry -> {
<BUG>IRegion region = FGManager.getInstance().getWorldRegion(world, entry.getKey());
if (region != null) {
logger.info("Loading links for world region \"" + region.getName() + "\"");</BUG>
String handlersString = entry.getValue();
|
public synchronized void loadWorldRegionLinks(World world) {
logger.info("Loading world region links for world \"" + world.getName() + "\"");
try (DB mainDB = DBMaker.fileDB(worldDirectories.get(world.getName()).resolve("wregions.foxdb").normalize().toString()).make()) {
Map<String, String> linksMap = mainDB.hashMap("links", Serializer.STRING, Serializer.STRING).createOrOpen();
linksMap.entrySet().forEach(entry -> {
Optional<IWorldRegion> regionOpt = FGManager.getInstance().getWorldRegion(world, entry.getKey());
if (regionOpt.isPresent()) {
IWorldRegion region = regionOpt.get();
logger.info("Loading links for world region \"" + region.getName() + "\"");
String handlersString = entry.getValue();
|
1,432 |
StringBuilder builder = new StringBuilder();
for (Iterator<IHandler> it = handlers.iterator(); it.hasNext(); ) {
builder.append(it.next().getName());
if (it.hasNext()) builder.append(",");
}
<BUG>return builder.toString();
}</BUG>
private final class LoadEntry {
public final String name;
public final Type type;
|
StringBuilder builder = new StringBuilder();
for (Iterator<IHandler> it = handlers.iterator(); it.hasNext(); ) {
builder.append(it.next().getName());
if (it.hasNext()) builder.append(",");
}
return builder.toString();
}
public enum Type {
REGION, WREGION, HANDLER
}
private final class LoadEntry {
public final String name;
public final Type type;
|
1,433 |
import net.foxdenstudio.sponge.foxguard.plugin.handler.GlobalHandler;
import net.foxdenstudio.sponge.foxguard.plugin.handler.IHandler;
import net.foxdenstudio.sponge.foxguard.plugin.object.IFGObject;
import net.foxdenstudio.sponge.foxguard.plugin.object.IGlobal;
import net.foxdenstudio.sponge.foxguard.plugin.region.IRegion;
<BUG>import net.foxdenstudio.sponge.foxguard.plugin.region.world.GlobalWorldRegion;</BUG>
import org.spongepowered.api.Sponge;
import org.spongepowered.api.command.CommandException;
import org.spongepowered.api.command.CommandResult;
import org.spongepowered.api.command.CommandSource;
import org.spongepowered.api.command.args.ArgumentParseException;
<BUG>import org.spongepowered.api.entity.living.player.Player;</BUG>
import org.spongepowered.api.text.Text;
|
import net.foxdenstudio.sponge.foxguard.plugin.handler.GlobalHandler;
import net.foxdenstudio.sponge.foxguard.plugin.handler.IHandler;
import net.foxdenstudio.sponge.foxguard.plugin.object.IFGObject;
import net.foxdenstudio.sponge.foxguard.plugin.object.IGlobal;
import net.foxdenstudio.sponge.foxguard.plugin.region.IRegion;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.command.CommandException;
import org.spongepowered.api.command.CommandResult;
import org.spongepowered.api.command.CommandSource;
import org.spongepowered.api.command.args.ArgumentParseException;
import org.spongepowered.api.text.Text;
|
1,434 |
import org.spongepowered.api.world.Locatable;
import org.spongepowered.api.world.Location;
import org.spongepowered.api.world.World;
import javax.annotation.Nullable;
import java.util.List;
<BUG>import java.util.Optional;
import static net.foxdenstudio.sponge.foxcore.plugin.util.Aliases.*;</BUG>
public class CommandDelete extends FCCommandBase {
private static final FlagMapper MAPPER = map -> key -> value -> {
map.put(key, value);
|
import org.spongepowered.api.world.Locatable;
import org.spongepowered.api.world.Location;
import org.spongepowered.api.world.World;
import javax.annotation.Nullable;
import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;
import static net.foxdenstudio.sponge.foxcore.plugin.util.Aliases.*;
public class CommandDelete extends FCCommandBase {
private static final FlagMapper MAPPER = map -> key -> value -> {
map.put(key, value);
|
1,435 |
.append(Text.of(TextColors.GREEN, "Usage: "))
.append(getUsage(source))
.build());
return CommandResult.empty();
} else if (isIn(REGIONS_ALIASES, parse.args[0])) {
<BUG>if (parse.args.length < 2) throw new CommandException(Text.of("Must specify a name!"));
IRegion region = FGManager.getInstance().getRegion(parse.args[1]);
</BUG>
boolean isWorldRegion = false;
if (region == null) {
|
.append(Text.of(TextColors.GREEN, "Usage: "))
.append(getUsage(source))
.build());
return CommandResult.empty();
} else if (isIn(REGIONS_ALIASES, parse.args[0])) {
if (parse.args.length < 2) throw new CommandException(Text.of("Must specify a name!"));
String regionName = parse.args[1];
IRegion region = FGManager.getInstance().getRegion(regionName).orElse(null);
boolean isWorldRegion = false;
if (region == null) {
|
1,436 |
</BUG>
isWorldRegion = true;
}
if (region == null)
<BUG>throw new CommandException(Text.of("No region exists with the name \"" + parse.args[1] + "\"!"));
if (region instanceof GlobalWorldRegion) {
</BUG>
throw new CommandException(Text.of("You may not delete the global region!"));
}
|
if (world == null)
throw new CommandException(Text.of("No world exists with name \"" + worldName + "\"!"));
}
}
if (world == null) throw new CommandException(Text.of("Must specify a world!"));
region = FGManager.getInstance().getWorldRegion(world, regionName).orElse(null);
isWorldRegion = true;
}
if (region == null)
throw new CommandException(Text.of("No region exists with the name \"" + regionName + "\"!"));
if (region instanceof IGlobal) {
throw new CommandException(Text.of("You may not delete the global region!"));
}
|
1,437 |
source.getName() + " deleted " + (isWorldRegion ? "world" : "") + "region"
);
return CommandResult.success();
} else if (isIn(HANDLERS_ALIASES, parse.args[0])) {
if (parse.args.length < 2) throw new CommandException(Text.of("Must specify a name!"));
<BUG>IHandler handler = FGManager.getInstance().gethandler(parse.args[1]);
if (handler == null)
throw new ArgumentParseException(Text.of("No handler exists with that name!"), parse.args[1], 1);
if (handler instanceof GlobalHandler)</BUG>
throw new CommandException(Text.of("You may not delete the global handler!"));
|
source.getName() + " deleted " + (isWorldRegion ? "world" : "") + "region"
);
return CommandResult.success();
} else if (isIn(HANDLERS_ALIASES, parse.args[0])) {
if (parse.args.length < 2) throw new CommandException(Text.of("Must specify a name!"));
Optional<IHandler> handlerOpt = FGManager.getInstance().gethandler(parse.args[1]);
if (!handlerOpt.isPresent())
throw new ArgumentParseException(Text.of("No handler exists with that name!"), parse.args[1], 1);
IHandler handler = handlerOpt.get();
if (handler instanceof GlobalHandler)
throw new CommandException(Text.of("You may not delete the global handler!"));
|
1,438 |
.excludeCurrent(true)
.autoCloseQuotes(true)
.parse();
if (parse.current.type.equals(AdvCmdParser.CurrentElement.ElementType.ARGUMENT)) {
if (parse.current.index == 0)
<BUG>return ImmutableList.of("region", "handler").stream()
.filter(new StartsWithPredicate(parse.current.token))</BUG>
.map(args -> parse.current.prefix + args)
.collect(GuavaCollectors.toImmutableList());
else if (parse.current.index == 1) {
|
.excludeCurrent(true)
.autoCloseQuotes(true)
.parse();
if (parse.current.type.equals(AdvCmdParser.CurrentElement.ElementType.ARGUMENT)) {
if (parse.current.index == 0)
return Stream.of("region", "handler")
.filter(new StartsWithPredicate(parse.current.token))
.map(args -> parse.current.prefix + args)
.collect(GuavaCollectors.toImmutableList());
else if (parse.current.index == 1) {
|
1,439 |
.autoCloseQuotes(true)
.leaveFinalAsIs(true)
.parse();
if (parse.current.type.equals(AdvCmdParser.CurrentElement.ElementType.ARGUMENT)) {
if (parse.current.index == 0)
<BUG>return ImmutableList.of("region", "worldregion", "handler", "controller").stream()
</BUG>
.filter(new StartsWithPredicate(parse.current.token))
.collect(GuavaCollectors.toImmutableList());
else if (parse.current.index == 1) {
|
.autoCloseQuotes(true)
.leaveFinalAsIs(true)
.parse();
if (parse.current.type.equals(AdvCmdParser.CurrentElement.ElementType.ARGUMENT)) {
if (parse.current.index == 0)
return Stream.of("region", "worldregion", "handler", "controller")
.filter(new StartsWithPredicate(parse.current.token))
.collect(GuavaCollectors.toImmutableList());
else if (parse.current.index == 1) {
|
1,440 |
@Dependency(id = "foxcore")
},
description = "A world protection plugin built for SpongeAPI. Requires FoxCore.",
authors = {"gravityfox"},
url = "https://github.com/FoxDenStudio/FoxGuard")
<BUG>public final class FoxGuardMain {
public final Cause pluginCause = Cause.builder().named("plugin", this).build();
private static FoxGuardMain instanceField;</BUG>
@Inject
private Logger logger;
|
@Dependency(id = "foxcore")
},
description = "A world protection plugin built for SpongeAPI. Requires FoxCore.",
authors = {"gravityfox"},
url = "https://github.com/FoxDenStudio/FoxGuard")
public final class FoxGuardMain {
private static FoxGuardMain instanceField;
public final Cause pluginCause = Cause.builder().named("plugin", this).build();
@Inject
private Logger logger;
|
1,441 |
private UserStorageService userStorage;
private EconomyService economyService = null;
private boolean loaded = false;
private FCCommandDispatcher fgDispatcher;
public static FoxGuardMain instance() {
<BUG>return instanceField;
}</BUG>
@Listener
public void construct(GameConstructionEvent event) {
instanceField = this;
|
private UserStorageService userStorage;
private EconomyService economyService = null;
private boolean loaded = false;
private FCCommandDispatcher fgDispatcher;
public static FoxGuardMain instance() {
return instanceField;
}
public static Cause getCause() {
return instance().pluginCause;
}
@Listener
public void construct(GameConstructionEvent event) {
instanceField = this;
|
1,442 |
return configDirectory;
}
public boolean isLoaded() {
return loaded;
}
<BUG>public static Cause getCause() {
return instance().pluginCause;
}</BUG>
public EconomyService getEconomyService() {
return economyService;
|
return configDirectory;
}
public boolean isLoaded() {
return loaded;
}
public EconomyService getEconomyService() {
return economyService;
|
1,443 |
long t=t0;
long pnext=t+printInterval_ms;
boolean run = true;
while (!endEvent && run) {
SamplesEventsCount status = null;
<BUG>try {
System.out.println( TAG+" Waiting for " + (nSamples + trialLength_samp + 1) + " samples");</BUG>
status = C.waitForSamples(nSamples + trialLength_samp + 1, this.timeout_ms);
} catch (IOException e) {
e.printStackTrace();
|
long t=t0;
long pnext=t+printInterval_ms;
boolean run = true;
while (!endEvent && run) {
SamplesEventsCount status = null;
try {
if ( VERB>1 )
System.out.println( TAG+" Waiting for " + (nSamples + trialLength_samp + 1) + " samples");
status = C.waitForSamples(nSamples + trialLength_samp + 1, this.timeout_ms);
} catch (IOException e) {
e.printStackTrace();
|
1,444 |
dv = null;
continue;
}
t = System.currentTimeMillis();
if ( t > pnext ) {
<BUG>System.out.println(TAG+ String.format("%d %d %5.3f (samp,event,sec)\r",
status.nSamples,status.nEvents,(t-t0)/1000.0));</BUG>
pnext = t+printInterval_ms;
}
int onSamples = nSamples;
|
dv = null;
continue;
}
t = System.currentTimeMillis();
if ( t > pnext ) {
System.out.println(String.format("%d %d %5.3f (samp,event,sec)\r",
status.nSamples,status.nEvents,(t-t0)/1000.0));
pnext = t+printInterval_ms;
}
int onSamples = nSamples;
|
1,445 |
try {
data = new Matrix(new Matrix(C.getDoubleData(fromId, toId)).transpose());
} catch (IOException e) {
e.printStackTrace();
}
<BUG>if ( VERB>0 ) {
</BUG>
System.out.println(TAG+ String.format("Got data @ %d->%d samples", fromId, toId));
}
Matrix f = new Matrix(classifiers.get(0).getOutputSize(), 1);
|
try {
data = new Matrix(new Matrix(C.getDoubleData(fromId, toId)).transpose());
} catch (IOException e) {
e.printStackTrace();
}
if ( VERB>1 ) {
System.out.println(TAG+ String.format("Got data @ %d->%d samples", fromId, toId));
}
Matrix f = new Matrix(classifiers.get(0).getOutputSize(), 1);
|
1,446 |
ClassifierResult result = null;
for (PreprocClassifier c : classifiers) {
result = c.apply(data);
f = new Matrix(f.add(result.f));
fraw = new Matrix(fraw.add(result.fraw));
<BUG>}
double[] dvColumn = f.getColumn(0);</BUG>
f = new Matrix(dvColumn.length - 1, 1);
f.setColumn(0, Arrays.copyOfRange(dvColumn, 1, dvColumn.length));
if (normalizeLateralization){ // compute alphaLat score
|
ClassifierResult result = null;
for (PreprocClassifier c : classifiers) {
result = c.apply(data);
f = new Matrix(f.add(result.f));
fraw = new Matrix(fraw.add(result.fraw));
}
if ( f.getRowDimension() > 1 ) {
double[] dvColumn = f.getColumn(0);
f = new Matrix(dvColumn.length - 1, 1);
f.setColumn(0, Arrays.copyOfRange(dvColumn, 1, dvColumn.length));
if (normalizeLateralization){ // compute alphaLat score
|
1,447 |
f.setColumn(0, Arrays.copyOfRange(dvColumn, 1, dvColumn.length));
if (normalizeLateralization){ // compute alphaLat score
f.setEntry(0, 0, (dvColumn[0] - dvColumn[1]) / (dvColumn[0] + dvColumn[1]));
} else {
f.setEntry(0, 0, dvColumn[0] - dvColumn[1]);
<BUG>}
if (dv == null || predictionFilter < 0) {</BUG>
dv = f;
} else {
if (predictionFilter >= 0.) {// exponiential smoothing of predictions
|
f.setColumn(0, Arrays.copyOfRange(dvColumn, 1, dvColumn.length));
if (normalizeLateralization){ // compute alphaLat score
f.setEntry(0, 0, (dvColumn[0] - dvColumn[1]) / (dvColumn[0] + dvColumn[1]));
} else {
f.setEntry(0, 0, dvColumn[0] - dvColumn[1]);
}
}
if (dv == null || predictionFilter < 0) {
dv = f;
} else {
if (predictionFilter >= 0.) {// exponiential smoothing of predictions
|
1,448 |
if (baselinePhase) {
nBaseline++;
dvBaseline = new Matrix(dvBaseline.add(dv));
dv2Baseline = new Matrix(dv2Baseline.add(dv.multiplyElements(dv)));
if (nBaselineStep > 0 && nBaseline > nBaselineStep) {
<BUG>System.out.println( "Baseline timeout\n");
</BUG>
baselinePhase = false;
Tuple<Matrix, Matrix> ret = baselineValues(dvBaseline, dv2Baseline, nBaseline);
baseLineVal = ret.x;
|
if (baselinePhase) {
nBaseline++;
dvBaseline = new Matrix(dvBaseline.add(dv));
dv2Baseline = new Matrix(dv2Baseline.add(dv.multiplyElements(dv)));
if (nBaselineStep > 0 && nBaseline > nBaselineStep) {
if(VERB>1) System.out.println( "Baseline timeout\n");
baselinePhase = false;
Tuple<Matrix, Matrix> ret = baselineValues(dvBaseline, dv2Baseline, nBaseline);
baseLineVal = ret.x;
|
1,449 |
Tuple<Matrix, Matrix> ret=baselineValues(dvBaseline,dv2Baseline,nBaseline);
baseLineVal = ret.x;
baseLineVar = ret.y;
}
} else if ( value.equals(baselineStart) ) {
<BUG>System.out.println( "Baseline start event received");
</BUG>
baselinePhase = true;
nBaseline = 0;
dvBaseline = Matrix.zeros(classifiers.get(0).getOutputSize() - 1, 1);
|
Tuple<Matrix, Matrix> ret=baselineValues(dvBaseline,dv2Baseline,nBaseline);
baseLineVal = ret.x;
baseLineVar = ret.y;
}
} else if ( value.equals(baselineStart) ) {
if(VERB>1)System.out.println(TAG+ "Baseline start event received");
baselinePhase = true;
nBaseline = 0;
dvBaseline = Matrix.zeros(classifiers.get(0).getOutputSize() - 1, 1);
|
1,450 |
}
}
});
}
} else {
<BUG>if (n <= m) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {</BUG>
a[i][j] = operator.applyAsBoolean(a[i][j]);
}
|
}
public boolean[] row(final int rowIndex) {
N.checkArgument(rowIndex >= 0 && rowIndex < n, "Invalid row Index: %s", rowIndex);
return a[rowIndex];
}
|
1,451 |
}
}
});
}
} else {
<BUG>if (n <= m) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {</BUG>
result[i][j] = zipFunction.apply(a[i][j], b[i][j]);
}
|
}
public boolean get(final int i, final int j) {
return a[i][j];
}
|
1,452 |
}
}
});
}
} else {
<BUG>if (n <= m) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {</BUG>
result[i][j] = zipFunction.apply(a[i][j], b[i][j], c[i][j]);
}
|
}
}
return new BooleanMatrix(c);
}
|
1,453 |
}
public AsyncExecutor(int maxConcurrentThreadNumber, long keepAliveTime, TimeUnit unit) {
this.maxConcurrentThreadNumber = maxConcurrentThreadNumber;
this.keepAliveTime = keepAliveTime;
this.unit = unit;
<BUG>}
public AsyncExecutor(final ExecutorService executorService) {
this(8, 300, TimeUnit.SECONDS);
this.executorService = executorService;</BUG>
Runtime.getRuntime().addShutdownHook(new Thread() {
|
}
public AsyncExecutor(int maxConcurrentThreadNumber, long keepAliveTime, TimeUnit unit) {
this.maxConcurrentThreadNumber = maxConcurrentThreadNumber;
this.keepAliveTime = keepAliveTime;
this.unit = unit;
Runtime.getRuntime().addShutdownHook(new Thread() {
|
1,454 |
results.add(execute(cmd));
}
return results;
}
public <T> CompletableFuture<T> execute(final Callable<T> command) {
<BUG>final CompletableFuture<T> future = new CompletableFuture<T>(this, command);
getExecutorService().execute(future);</BUG>
return future;
}
public <T> List<CompletableFuture<T>> execute(final Callable<T>... commands) {
|
results.add(execute(cmd));
}
return results;
}
public <T> CompletableFuture<T> execute(final Callable<T> command) {
final CompletableFuture<T> future = new CompletableFuture<>(this, command);
getExecutorService().execute(future);
return future;
}
public <T> List<CompletableFuture<T>> execute(final Callable<T>... commands) {
|
1,455 |
package com.liferay.portlet.blogs.util;
import com.liferay.portal.kernel.search.Hits;
<BUG>import com.liferay.portal.kernel.search.SearchEngineUtil;</BUG>
import com.liferay.portal.search.HitsOpenSearchImpl;
import com.liferay.portlet.blogs.service.BlogsEntryLocalServiceUtil;
public class BlogsOpenSearchImpl extends HitsOpenSearchImpl {
public static final String SEARCH_PATH = "/c/blogs/open_search";
public static final String TITLE = "Liferay Blogs Search: ";
<BUG>public Hits getHits(long companyId, String keywords) throws Exception {
return BlogsEntryLocalServiceUtil.search(
companyId, 0, 0, keywords, SearchEngineUtil.ALL_POS,
SearchEngineUtil.ALL_POS);</BUG>
}
|
package com.liferay.portlet.blogs.util;
import com.liferay.portal.kernel.search.Hits;
import com.liferay.portal.search.HitsOpenSearchImpl;
import com.liferay.portlet.blogs.service.BlogsEntryLocalServiceUtil;
public class BlogsOpenSearchImpl extends HitsOpenSearchImpl {
public static final String SEARCH_PATH = "/c/blogs/open_search";
public static final String TITLE = "Liferay Blogs Search: ";
public Hits getHits(
long companyId, String keywords, int start, int end)
throws Exception {
return BlogsEntryLocalServiceUtil.search(
companyId, 0, 0, keywords, start, end);
}
|
1,456 |
package com.liferay.portlet.messageboards.util;
import com.liferay.portal.kernel.search.Hits;
<BUG>import com.liferay.portal.kernel.search.SearchEngineUtil;</BUG>
import com.liferay.portal.search.HitsOpenSearchImpl;
import com.liferay.portlet.messageboards.service.MBCategoryLocalServiceUtil;
public class MBOpenSearchImpl extends HitsOpenSearchImpl {
public static final String SEARCH_PATH = "/c/message_boards/open_search";
public static final String TITLE = "Liferay Message Boards Search: ";
<BUG>public Hits getHits(long companyId, String keywords) throws Exception {
return MBCategoryLocalServiceUtil.search(
companyId, 0, null, 0, keywords, SearchEngineUtil.ALL_POS,
SearchEngineUtil.ALL_POS);</BUG>
}
|
package com.liferay.portlet.messageboards.util;
import com.liferay.portal.kernel.search.Hits;
import com.liferay.portal.search.HitsOpenSearchImpl;
import com.liferay.portlet.messageboards.service.MBCategoryLocalServiceUtil;
public class MBOpenSearchImpl extends HitsOpenSearchImpl {
public static final String SEARCH_PATH = "/c/message_boards/open_search";
public static final String TITLE = "Liferay Message Boards Search: ";
public Hits getHits(
long companyId, String keywords, int start, int end)
throws Exception {
return MBCategoryLocalServiceUtil.search(
companyId, 0, null, 0, keywords, start, end);
}
|
1,457 |
package com.liferay.portlet.wiki.util;
import com.liferay.portal.kernel.search.Hits;
<BUG>import com.liferay.portal.kernel.search.SearchEngineUtil;</BUG>
import com.liferay.portal.search.HitsOpenSearchImpl;
import com.liferay.portlet.wiki.service.WikiNodeLocalServiceUtil;
public class WikiOpenSearchImpl extends HitsOpenSearchImpl {
public static final String SEARCH_PATH = "/c/wiki/open_search";
public static final String TITLE = "Liferay Wiki Search: ";
<BUG>public Hits getHits(long companyId, String keywords) throws Exception {
return WikiNodeLocalServiceUtil.search(
companyId, 0, null, keywords, SearchEngineUtil.ALL_POS,
SearchEngineUtil.ALL_POS);</BUG>
}
|
package com.liferay.portlet.wiki.util;
import com.liferay.portal.kernel.search.Hits;
import com.liferay.portal.search.HitsOpenSearchImpl;
import com.liferay.portlet.wiki.service.WikiNodeLocalServiceUtil;
public class WikiOpenSearchImpl extends HitsOpenSearchImpl {
public static final String SEARCH_PATH = "/c/wiki/open_search";
public static final String TITLE = "Liferay Wiki Search: ";
public Hits getHits(
long companyId, String keywords, int start, int end)
throws Exception {
return WikiNodeLocalServiceUtil.search(
companyId, 0, null, keywords, start, end);
}
|
1,458 |
package com.liferay.portlet.imagegallery.util;
import com.liferay.portal.kernel.search.Hits;
<BUG>import com.liferay.portal.kernel.search.SearchEngineUtil;</BUG>
import com.liferay.portal.search.HitsOpenSearchImpl;
import com.liferay.portlet.imagegallery.service.IGFolderLocalServiceUtil;
public class IGOpenSearchImpl extends HitsOpenSearchImpl {
public static final String SEARCH_PATH = "/c/image_gallery/open_search";
public static final String TITLE = "Liferay Image Gallery Search: ";
<BUG>public Hits getHits(long companyId, String keywords) throws Exception {
return IGFolderLocalServiceUtil.search(
companyId, 0, null, keywords, SearchEngineUtil.ALL_POS,
SearchEngineUtil.ALL_POS);</BUG>
}
|
package com.liferay.portlet.imagegallery.util;
import com.liferay.portal.kernel.search.Hits;
import com.liferay.portal.search.HitsOpenSearchImpl;
import com.liferay.portlet.imagegallery.service.IGFolderLocalServiceUtil;
public class IGOpenSearchImpl extends HitsOpenSearchImpl {
public static final String SEARCH_PATH = "/c/image_gallery/open_search";
public static final String TITLE = "Liferay Image Gallery Search: ";
public Hits getHits(
long companyId, String keywords, int start, int end)
throws Exception {
return IGFolderLocalServiceUtil.search(
companyId, 0, null, keywords, start, end);
}
|
1,459 |
int itemsPerPage)
throws SearchException {
<BUG>Hits hits = null;</BUG>
try {
ThemeDisplay themeDisplay =
<BUG>(ThemeDisplay)req.getAttribute(WebKeys.THEME_DISPLAY);
hits = CompanyLocalServiceUtil.search(
themeDisplay.getCompanyId(), keywords,
SearchEngineUtil.ALL_POS, SearchEngineUtil.ALL_POS);
Object[] values = addSearchResults(
keywords, startPage, itemsPerPage, hits,
</BUG>
"Liferay Portal Search: " + keywords, SEARCH_PATH,
|
int itemsPerPage)
throws SearchException {
try {
ThemeDisplay themeDisplay =
(ThemeDisplay)req.getAttribute(WebKeys.THEME_DISPLAY);
int start = (startPage * itemsPerPage) - itemsPerPage;
int end = startPage * itemsPerPage;
Hits results = CompanyLocalServiceUtil.search(
themeDisplay.getCompanyId(), keywords, start, end);
int total = results.getLength();
Object[] values = addSearchResults(
keywords, startPage, itemsPerPage, total, start,
"Liferay Portal Search: " + keywords, SEARCH_PATH,
|
1,460 |
Object[] values = addSearchResults(
keywords, startPage, itemsPerPage, hits,
</BUG>
"Liferay Portal Search: " + keywords, SEARCH_PATH,
themeDisplay);
<BUG>Hits results = (Hits)values[0];
org.dom4j.Document doc = (org.dom4j.Document)values[1];
Element root = (Element)values[2];
for (int i = 0; i < results.getLength(); i++) {
</BUG>
Document result = results.doc(i);
|
Object[] values = addSearchResults(
keywords, startPage, itemsPerPage, total, start,
"Liferay Portal Search: " + keywords, SEARCH_PATH,
themeDisplay);
org.dom4j.Document doc = (org.dom4j.Document)values[0];
Element root = (Element)values[1];
for (int i = 0; i < results.getDocs().length; i++) {
Document result = results.doc(i);
|
1,461 |
content = docSummary.getContent();
if (portlet.getPortletId().equals(PortletKeys.JOURNAL)) {
url = getJournalURL(themeDisplay, groupId, result);
}
}
<BUG>double score = hits.score(i);
</BUG>
addSearchResult(
root, portletTitle + " » " + title, url, modifedDate,
content, score);
|
content = docSummary.getContent();
if (portlet.getPortletId().equals(PortletKeys.JOURNAL)) {
url = getJournalURL(themeDisplay, groupId, result);
}
}
double score = results.score(i);
addSearchResult(
root, portletTitle + " » " + title, url, modifedDate,
content, score);
|
1,462 |
package com.liferay.portlet.bookmarks.util;
import com.liferay.portal.kernel.search.Hits;
<BUG>import com.liferay.portal.kernel.search.SearchEngineUtil;</BUG>
import com.liferay.portal.search.HitsOpenSearchImpl;
import com.liferay.portlet.bookmarks.service.BookmarksFolderLocalServiceUtil;
public class BookmarksOpenSearchImpl extends HitsOpenSearchImpl {
public static final String SEARCH_PATH = "/c/bookmarks/open_search";
public static final String TITLE = "Liferay Bookmarks Search: ";
<BUG>public Hits getHits(long companyId, String keywords) throws Exception {
return BookmarksFolderLocalServiceUtil.search(
companyId, 0, null, keywords, SearchEngineUtil.ALL_POS,
SearchEngineUtil.ALL_POS);</BUG>
}
|
package com.liferay.portlet.bookmarks.util;
import com.liferay.portal.kernel.search.Hits;
import com.liferay.portal.search.HitsOpenSearchImpl;
import com.liferay.portlet.bookmarks.service.BookmarksFolderLocalServiceUtil;
public class BookmarksOpenSearchImpl extends HitsOpenSearchImpl {
public static final String SEARCH_PATH = "/c/bookmarks/open_search";
public static final String TITLE = "Liferay Bookmarks Search: ";
public Hits getHits(
long companyId, String keywords, int start, int end)
throws Exception {
return BookmarksFolderLocalServiceUtil.search(
companyId, 0, null, keywords, start, end);
}
|
1,463 |
package com.liferay.portlet.documentlibrary.util;
import com.liferay.portal.kernel.search.Hits;
<BUG>import com.liferay.portal.kernel.search.SearchEngineUtil;</BUG>
import com.liferay.portal.search.HitsOpenSearchImpl;
import com.liferay.portlet.documentlibrary.service.DLFolderLocalServiceUtil;
public class DLOpenSearchImpl extends HitsOpenSearchImpl {
public static final String SEARCH_PATH = "/c/document_library/open_search";
public static final String TITLE = "Liferay Document Library Search: ";
<BUG>public Hits getHits(long companyId, String keywords) throws Exception {
return DLFolderLocalServiceUtil.search(
companyId, 0, null, keywords, SearchEngineUtil.ALL_POS,
SearchEngineUtil.ALL_POS);</BUG>
}
|
package com.liferay.portlet.documentlibrary.util;
import com.liferay.portal.kernel.search.Hits;
import com.liferay.portal.search.HitsOpenSearchImpl;
import com.liferay.portlet.documentlibrary.service.DLFolderLocalServiceUtil;
public class DLOpenSearchImpl extends HitsOpenSearchImpl {
public static final String SEARCH_PATH = "/c/document_library/open_search";
public static final String TITLE = "Liferay Document Library Search: ";
public Hits getHits(
long companyId, String keywords, int start, int end)
throws Exception {
return DLFolderLocalServiceUtil.search(
companyId, 0, null, keywords, start, end);
}
|
1,464 |
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.lucene.document.DateTools;
import org.dom4j.Element;
public abstract class HitsOpenSearchImpl extends BaseOpenSearchImpl {
<BUG>public abstract Hits getHits(long companyId, String keywords)
throws Exception;</BUG>
public abstract String getSearchPath();
public abstract String getTitle(String keywords);
public String search(
|
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.lucene.document.DateTools;
import org.dom4j.Element;
public abstract class HitsOpenSearchImpl extends BaseOpenSearchImpl {
public abstract Hits getHits(
long companyId, String keywords, int start, int end)
throws Exception;
public abstract String getSearchPath();
public abstract String getTitle(String keywords);
public String search(
|
1,465 |
String title = docSummary.getTitle();
String url = getURL(themeDisplay, groupId, result, portletURL);
Date modifedDate = DateTools.stringToDate(
result.get(Field.MODIFIED));
String content = docSummary.getContent();
<BUG>double score = hits.score(i);
</BUG>
addSearchResult(root, title, url, modifedDate, content, score);
}
if (_log.isDebugEnabled()) {
|
String title = docSummary.getTitle();
String url = getURL(themeDisplay, groupId, result, portletURL);
Date modifedDate = DateTools.stringToDate(
result.get(Field.MODIFIED));
String content = docSummary.getContent();
double score = results.score(i);
addSearchResult(root, title, url, modifedDate, content, score);
}
if (_log.isDebugEnabled()) {
|
1,466 |
return doc.asXML();
}
catch (Exception e) {
throw new SearchException(e);
}
<BUG>finally {
if (hits != null) {
hits.closeSearcher();
}
}</BUG>
}
|
return doc.asXML();
}
catch (Exception e) {
throw new SearchException(e);
}
}
|
1,467 |
Element link = OpenSearchUtil.addElement(
root, "link", OpenSearchUtil.DEFAULT_NAMESPACE);
link.addAttribute("rel", "search");
link.addAttribute("href", searchPath + "_description.xml");
link.addAttribute("type", "application/opensearchdescription+xml");
<BUG>return new Object[] {hits, doc, root};
}</BUG>
protected PortletURL getPortletURL(HttpServletRequest req, String portletId)
throws PortalException, PortletModeException, SystemException,
WindowStateException {
|
Element link = OpenSearchUtil.addElement(
root, "link", OpenSearchUtil.DEFAULT_NAMESPACE);
link.addAttribute("rel", "search");
link.addAttribute("href", searchPath + "_description.xml");
link.addAttribute("type", "application/opensearchdescription+xml");
return new Object[] {doc, root};
}
protected PortletURL getPortletURL(HttpServletRequest req, String portletId)
throws PortalException, PortletModeException, SystemException,
WindowStateException {
|
1,468 |
themeDisplay.getCompanyId(), keywords, Boolean.TRUE, null, start,
end, new ContactLastNameComparator(true));
int total = UserLocalServiceUtil.searchCount(
themeDisplay.getCompanyId(), keywords, Boolean.TRUE, null);
Object[] values = addSearchResults(
<BUG>keywords, startPage, itemsPerPage, total, null,
</BUG>
"Liferay Directory Search: " + keywords, SEARCH_PATH, themeDisplay);
<BUG>org.dom4j.Document doc = (org.dom4j.Document)values[1];
Element root = (Element)values[2];
</BUG>
for (User user : results) {
|
themeDisplay.getCompanyId(), keywords, Boolean.TRUE, null, start,
end, new ContactLastNameComparator(true));
int total = UserLocalServiceUtil.searchCount(
themeDisplay.getCompanyId(), keywords, Boolean.TRUE, null);
Object[] values = addSearchResults(
keywords, startPage, itemsPerPage, total, start,
"Liferay Directory Search: " + keywords, SEARCH_PATH, themeDisplay);
org.dom4j.Document doc = (org.dom4j.Document)values[0];
Element root = (Element)values[1];
for (User user : results) {
|
1,469 |
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.DigestOutputStream;
import java.security.MessageDigest;
<BUG>import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;</BUG>
public final class PatchUtils {
|
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.DigestOutputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
public final class PatchUtils {
|
1,470 |
package org.jboss.as.patching;
import org.jboss.as.controller.AttributeDefinition;
<BUG>import org.jboss.as.controller.SimpleAttributeDefinition;</BUG>
import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
import org.jboss.dmr.ModelType;
<BUG>class Constants {
</BUG>
static final AttributeDefinition PATCH_ID = SimpleAttributeDefinitionBuilder.create("patch-id", ModelType.STRING).build();
|
package org.jboss.as.patching;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
import org.jboss.dmr.ModelType;
public class Constants {
|
1,471 |
package org.jboss.as.patching;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.patching.runner.PatchingException;
import org.jboss.logging.Messages;
import org.jboss.logging.annotations.Message;
<BUG>import org.jboss.logging.annotations.MessageBundle;
import java.io.IOException;</BUG>
import java.util.List;
@MessageBundle(projectCode = "JBAS")
public interface PatchMessages {
|
package org.jboss.as.patching;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.patching.runner.PatchingException;
import org.jboss.logging.Messages;
import org.jboss.logging.annotations.Message;
import org.jboss.logging.annotations.MessageBundle;
import org.jboss.logging.annotations.Cause;
import java.io.IOException;
import java.util.List;
@MessageBundle(projectCode = "JBAS")
public interface PatchMessages {
|
1,472 |
package org.jboss.as.patching.runner;
<BUG>import org.jboss.as.boot.DirectoryStructure;
import org.jboss.as.patching.LocalPatchInfo;</BUG>
import org.jboss.as.patching.PatchInfo;
import org.jboss.as.patching.PatchLogger;
import org.jboss.as.patching.PatchMessages;
|
package org.jboss.as.patching.runner;
import static org.jboss.as.patching.runner.PatchUtils.generateTimestamp;
import org.jboss.as.boot.DirectoryStructure;
import org.jboss.as.patching.CommonAttributes;
import org.jboss.as.patching.LocalPatchInfo;
import org.jboss.as.patching.PatchInfo;
import org.jboss.as.patching.PatchLogger;
import org.jboss.as.patching.PatchMessages;
|
1,473 |
private static final String PATH_DELIMITER = "/";
public static final byte[] NO_CONTENT = PatchingTask.NO_CONTENT;
enum Element {
ADDED_BUNDLE("added-bundle"),
ADDED_MISC_CONTENT("added-misc-content"),
<BUG>ADDED_MODULE("added-module"),
BUNDLES("bundles"),</BUG>
CUMULATIVE("cumulative"),
DESCRIPTION("description"),
MISC_FILES("misc-files"),
|
private static final String PATH_DELIMITER = "/";
public static final byte[] NO_CONTENT = PatchingTask.NO_CONTENT;
enum Element {
ADDED_BUNDLE("added-bundle"),
ADDED_MISC_CONTENT("added-misc-content"),
ADDED_MODULE("added-module"),
APPLIES_TO_VERSION("applies-to-version"),
BUNDLES("bundles"),
CUMULATIVE("cumulative"),
DESCRIPTION("description"),
MISC_FILES("misc-files"),
|
1,474 |
writer.writeEndElement();
final Patch.PatchType type = patch.getPatchType();
<BUG>final List<String> appliesTo = patch.getAppliesTo();</BUG>
if(type == Patch.PatchType.ONE_OFF) {
<BUG>writer.writeEmptyElement(Element.ONE_OFF.name);
</BUG>
} else {
<BUG>writer.writeEmptyElement(Element.CUMULATIVE.name);
</BUG>
writer.writeAttribute(Attribute.RESULTING_VERSION.name, patch.getResultingVersion());
|
writer.writeEndElement();
writer.writeStartElement(Element.DESCRIPTION.name);
writer.writeCharacters(patch.getDescription());
writer.writeEndElement();
final Patch.PatchType type = patch.getPatchType();
if(type == Patch.PatchType.ONE_OFF) {
writer.writeStartElement(Element.ONE_OFF.name);
} else {
writer.writeStartElement(Element.CUMULATIVE.name);
writer.writeAttribute(Attribute.RESULTING_VERSION.name, patch.getResultingVersion());
|
1,475 |
} else {
<BUG>writer.writeEmptyElement(Element.CUMULATIVE.name);
</BUG>
writer.writeAttribute(Attribute.RESULTING_VERSION.name, patch.getResultingVersion());
}
<BUG>writer.writeAttribute(Attribute.APPLIES_TO_VERSION.name, appliesTo);
final List<ContentModification> bundlesAdd = new ArrayList<ContentModification>();</BUG>
final List<ContentModification> bundlesUpdate = new ArrayList<ContentModification>();
final List<ContentModification> bundlesRemove = new ArrayList<ContentModification>();
final List<ContentModification> miscAdd = new ArrayList<ContentModification>();
|
} else {
writer.writeStartElement(Element.CUMULATIVE.name);
writer.writeAttribute(Attribute.RESULTING_VERSION.name, patch.getResultingVersion());
}
writeAppliesToVersions(writer, patch.getAppliesTo());
writer.writeEndElement(); // </one-off> or </cumulative>
final List<ContentModification> bundlesAdd = new ArrayList<ContentModification>();
final List<ContentModification> bundlesUpdate = new ArrayList<ContentModification>();
final List<ContentModification> bundlesRemove = new ArrayList<ContentModification>();
final List<ContentModification> miscAdd = new ArrayList<ContentModification>();
|
1,476 |
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
final String value = reader.getAttributeValue(i);
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
switch (attribute) {
<BUG>case APPLIES_TO_VERSION:
builder.addAppliesTo(value);
break;</BUG>
case RESULTING_VERSION:
if(type == Patch.PatchType.CUMULATIVE) {
|
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
final String value = reader.getAttributeValue(i);
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
switch (attribute) {
case RESULTING_VERSION:
if(type == Patch.PatchType.CUMULATIVE) {
|
1,477 |
final StringBuilder path = new StringBuilder();
for(final String p : item.getPath()) {
path.append(p).append(PATH_DELIMITER);
}
path.append(item.getName());
<BUG>writer.writeAttribute(Attribute.PATH.name, path.toString());
if(type != ModificationType.REMOVE) {</BUG>
writer.writeAttribute(Attribute.HASH.name, bytesToHexString(item.getContentHash()));
}
if(type != ModificationType.ADD) {
|
final StringBuilder path = new StringBuilder();
for(final String p : item.getPath()) {
path.append(p).append(PATH_DELIMITER);
}
path.append(item.getName());
writer.writeAttribute(Attribute.PATH.name, path.toString());
if (item.isDirectory()) {
writer.writeAttribute(Attribute.DIRECTORY.name, "true");
}
if(type != ModificationType.REMOVE) {
writer.writeAttribute(Attribute.HASH.name, bytesToHexString(item.getContentHash()));
}
if(type != ModificationType.ADD) {
|
1,478 |
package com.opencms.file;
import java.util.*;
import java.sql.*;
<BUG>import com.opencms.core.*;
class CmsAccessFileMySql implements I_CmsAccessFile, I_CmsConstants {</BUG>
private Connection m_Con = null;
private CmsMountPoint m_mountpoint = null;
private static final String C_RESOURCE_WRITE = "INSERT INTO RESOURCES VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
package com.opencms.file;
import java.util.*;
import java.sql.*;
import com.opencms.core.*;
import com.opencms.util.*;
class CmsAccessFileMySql implements I_CmsAccessFile, I_CmsConstants {
private Connection m_Con = null;
private CmsMountPoint m_mountpoint = null;
private static final String C_RESOURCE_WRITE = "INSERT INTO RESOURCES VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
1,479 |
CmsFile file=null;
int projectId;
ResultSet res =null;
try {
if (project.equals(onlineProject)) {
<BUG>synchronized(m_statementFileReadOnline) {
m_statementFileReadOnline.setString(1,absoluteName(filename));
m_statementFileReadOnline.setInt(2,onlineProject.getId());
res = m_statementFileReadOnline.executeQuery();
if(res.next()) {</BUG>
file = new CmsFile(filename,
|
CmsFile file=null;
int projectId;
ResultSet res =null;
try {
if (project.equals(onlineProject)) {
PreparedStatement statementFileReadOnline=m_Con.prepareStatement(C_FILE_READ_ONLINE);
statementFileReadOnline.setString(1,absoluteName(filename));
statementFileReadOnline.setInt(2,onlineProject.getId());
res = statementFileReadOnline.executeQuery();
if(res.next()) {
file = new CmsFile(filename,
|
1,480 |
res.getInt(C_LOCKED_BY),
res.getInt(C_LAUNCHER_TYPE),
res.getString(C_LAUNCHER_CLASSNAME),
res.getLong(C_DATE_CREATED),
res.getLong(C_DATE_LASTMODIFIED),
<BUG>res.getBytes(C_FILE_CONTENT),
res.getInt(C_SIZE)</BUG>
);
} else {
<BUG>throw new CmsException(filename,CmsException.C_NOT_FOUND);
}</BUG>
}
|
res.getInt(C_LOCKED_BY),
res.getInt(C_LAUNCHER_TYPE),
res.getString(C_LAUNCHER_CLASSNAME),
res.getLong(C_DATE_CREATED),
res.getLong(C_DATE_LASTMODIFIED),
(res.getString(C_FILE_CONTENT)).getBytes(),
res.getInt(C_SIZE)
);
|
1,481 |
if (file.getState()==C_STATE_UNCHANGED) {
projectId=onlineProject.getId();
} else {
projectId=project.getId();
}
<BUG>synchronized (m_statementFileRead) {
m_statementFileRead.setString(1,absoluteName(filename));
m_statementFileRead.setInt(2,projectId);
res = m_statementFileRead.executeQuery();
if (res.next()) {</BUG>
file.setContents(res.getBytes(C_FILE_CONTENT));
|
if (file.getState()==C_STATE_UNCHANGED) {
projectId=onlineProject.getId();
} else {
projectId=project.getId();
}
PreparedStatement statementFileRead=m_Con.prepareStatement(C_FILE_READ);
statementFileRead.setString(1,absoluteName(filename));
statementFileRead.setInt(2,projectId);
res = statementFileRead.executeQuery();
if (res.next()) {
|
1,482 |
public CmsFile readFileHeader(A_CmsProject project, String filename)
throws CmsException {
CmsFile file=null;
ResultSet res =null;
try {
<BUG>synchronized ( m_statementResourceRead) {
m_statementResourceRead.setString(1,absoluteName(filename));
m_statementResourceRead.setInt(2,project.getId());
res = m_statementResourceRead.executeQuery();
}</BUG>
if(res.next()) {
|
public CmsFile readFileHeader(A_CmsProject project, String filename)
throws CmsException {
CmsFile file=null;
ResultSet res =null;
try {
PreparedStatement statementResourceRead=m_Con.prepareStatement(C_RESOURCE_READ);
statementResourceRead.setString(1,absoluteName(filename));
statementResourceRead.setInt(2,project.getId());
res = statementResourceRead.executeQuery();
if(res.next()) {
|
1,483 |
res.getLong(C_DATE_LASTMODIFIED),
new byte[0],
res.getInt(C_SIZE)
);
if (file.getState() == C_STATE_DELETED) {
<BUG>throw new CmsException(file.getAbsolutePath(),CmsException.C_NOT_FOUND);
</BUG>
}
} else {
<BUG>throw new CmsException(filename,CmsException.C_NOT_FOUND);
</BUG>
}
|
res.getLong(C_DATE_LASTMODIFIED),
new byte[0],
res.getInt(C_SIZE)
);
if (file.getState() == C_STATE_DELETED) {
throw new CmsException("["+this.getClass().getName()+"]"+file.getAbsolutePath(),CmsException.C_NOT_FOUND);
}
} else {
throw new CmsException("["+this.getClass().getName()+"]"+filename,CmsException.C_NOT_FOUND);
}
|
1,484 |
} else {
<BUG>throw new CmsException(filename,CmsException.C_NOT_FOUND);
</BUG>
}
} catch (SQLException e){
<BUG>throw new CmsException(e.getMessage(),CmsException.C_SQL_ERROR, e);
</BUG>
}
return file;
}
|
} else {
throw new CmsException("["+this.getClass().getName()+"]"+filename,CmsException.C_NOT_FOUND);
}
} catch (SQLException e){
throw new CmsException("["+this.getClass().getName()+"]"+e.getMessage(),CmsException.C_SQL_ERROR, e);
}
return file;
}
|
1,485 |
throws CmsException {
CmsFile file=null;
ResultSet res =null;
Vector allHeaders = new Vector();
try {
<BUG>synchronized ( m_statementResourceReadAll) {
m_statementResourceReadAll.setString(1,absoluteName(filename));
res = m_statementResourceReadAll.executeQuery();
}</BUG>
while(res.next()) {
|
throws CmsException {
CmsFile file=null;
ResultSet res =null;
Vector allHeaders = new Vector();
try {
PreparedStatement statementResourceReadAll=m_Con.prepareStatement(C_RESOURCE_READ_ALL);
statementResourceReadAll.setString(1,absoluteName(filename));
res = statementResourceReadAll.executeQuery();
while(res.next()) {
|
1,486 |
res.getInt(C_SIZE)
);
allHeaders.addElement(file);
}
} catch (SQLException e){
<BUG>throw new CmsException(e.getMessage(),CmsException.C_SQL_ERROR, e);
</BUG>
}
return allHeaders;
}
|
res.getInt(C_SIZE)
);
allHeaders.addElement(file);
}
} catch (SQLException e){
throw new CmsException("["+this.getClass().getName()+"]"+e.getMessage(),CmsException.C_SQL_ERROR, e);
}
return allHeaders;
}
|
1,487 |
public CmsFolder readFolder(A_CmsProject project, String foldername)
throws CmsException {
CmsFolder folder=null;
ResultSet res =null;
try {
<BUG>Statement s = m_Con.createStatement();
s.setEscapeProcessing(false);
res = s.executeQuery("SELECT * FROM RESOURCES WHERE RESOURCE_NAME = '"+foldername
+"' AND PROJECT_ID = "+project.getId());
if(res.next()) {</BUG>
folder = new CmsFolder(res.getString(C_RESOURCE_NAME),
|
public CmsFolder readFolder(A_CmsProject project, String foldername)
throws CmsException {
CmsFolder folder=null;
ResultSet res =null;
try {
PreparedStatement statementResourceRead=m_Con.prepareStatement(C_RESOURCE_READ);
statementResourceRead.setString(1,absoluteName(foldername));
statementResourceRead.setInt(2,project.getId());
res = statementResourceRead.executeQuery();
if(res.next()) {
folder = new CmsFolder(res.getString(C_RESOURCE_NAME),
|
1,488 |
res.getInt(C_LOCKED_BY),
res.getLong(C_DATE_CREATED),
res.getLong(C_DATE_LASTMODIFIED)
);
if (folder.getState() == C_STATE_DELETED) {
<BUG>throw new CmsException(folder.getAbsolutePath(),CmsException.C_NOT_FOUND);
</BUG>
}
}else {
<BUG>throw new CmsException(foldername,CmsException.C_NOT_FOUND);
</BUG>
}
|
res.getInt(C_LOCKED_BY),
res.getLong(C_DATE_CREATED),
res.getLong(C_DATE_LASTMODIFIED)
);
if (folder.getState() == C_STATE_DELETED) {
throw new CmsException("["+this.getClass().getName()+"]"+folder.getAbsolutePath(),CmsException.C_NOT_FOUND);
}
}else {
throw new CmsException("["+this.getClass().getName()+"]"+foldername,CmsException.C_NOT_FOUND);
}
|
1,489 |
}else {
<BUG>throw new CmsException(foldername,CmsException.C_NOT_FOUND);
</BUG>
}
} catch (SQLException e){
<BUG>throw new CmsException(e.getMessage(),CmsException.C_SQL_ERROR, e);
</BUG>
}
return folder;
}
|
}else {
throw new CmsException("["+this.getClass().getName()+"]"+foldername,CmsException.C_NOT_FOUND);
}
} catch (SQLException e){
throw new CmsException("["+this.getClass().getName()+"]"+e.getMessage(),CmsException.C_SQL_ERROR, e);
}
return folder;
}
|
1,490 |
} else {
<BUG>throw new CmsException(foldername,CmsException.C_NOT_EMPTY);
</BUG>
}
} else {
<BUG>throw new CmsException(foldername,CmsException.C_NOT_EMPTY);
</BUG>
}
}
public Vector getSubFolders(A_CmsProject project, String foldername)
|
} else {
throw new CmsException("["+this.getClass().getName()+"]"+foldername,CmsException.C_NOT_EMPTY);
}
} else {
throw new CmsException("["+this.getClass().getName()+"]"+foldername,CmsException.C_NOT_EMPTY);
}
}
public Vector getSubFolders(A_CmsProject project, String foldername)
|
1,491 |
res.getLong(C_DATE_CREATED),
res.getLong(C_DATE_LASTMODIFIED)
);
}
} catch (SQLException e){
<BUG>throw new CmsException(e.getMessage(),CmsException.C_SQL_ERROR, e);
</BUG>
}
return folders;
}
|
res.getLong(C_DATE_CREATED),
res.getLong(C_DATE_LASTMODIFIED)
);
}
} catch (SQLException e){
throw new CmsException("["+this.getClass().getName()+"]"+e.getMessage(),CmsException.C_SQL_ERROR, e);
}
return folders;
}
|
1,492 |
new byte[0],
res.getInt(C_SIZE)
);
}
} catch (SQLException e){
<BUG>throw new CmsException(e.getMessage(),CmsException.C_SQL_ERROR, e);
</BUG>
}
return files;
}
|
new byte[0],
res.getInt(C_SIZE)
);
}
} catch (SQLException e){
throw new CmsException("["+this.getClass().getName()+"]"+e.getMessage(),CmsException.C_SQL_ERROR, e);
}
return files;
}
|
1,493 |
Vector resources = new Vector();
CmsFile file;
CmsFolder folder;
ResultSet res;
try {
<BUG>synchronized (m_statementProjectReadFiles) {
m_statementProjectReadFiles.setInt(1,project.getId());
res=m_statementProjectReadFiles.executeQuery();
}</BUG>
while ( res.next() ) {
|
Vector resources = new Vector();
CmsFile file;
CmsFolder folder;
ResultSet res;
try {
PreparedStatement statementProjectReadFiles=m_Con.prepareStatement(C_PROJECT_READ_FILES);
statementProjectReadFiles.setInt(1,project.getId());
res=statementProjectReadFiles.executeQuery();
while ( res.next() ) {
|
1,494 |
} else if (file.getState() == C_STATE_DELETED) {
deleteFile(file);
resources.addElement(file.getAbsolutePath());
}
}
<BUG>synchronized (m_statementProjectReadFolders) {
m_statementProjectReadFolders.setInt(1,project.getId());
m_statementProjectReadFolders.setInt(2,C_TYPE_FOLDER);
res=m_statementProjectReadFolders.executeQuery();
}</BUG>
while ( res.next() ) {
|
} else if (file.getState() == C_STATE_DELETED) {
deleteFile(file);
resources.addElement(file.getAbsolutePath());
}
}
PreparedStatement statementProjectReadFolders=m_Con.prepareStatement(C_PROJECT_READ_FOLDER);
statementProjectReadFolders.setInt(1,project.getId());
statementProjectReadFolders.setInt(2,C_TYPE_FOLDER);
res=statementProjectReadFolders.executeQuery();
while ( res.next() ) {
|
1,495 |
deleteFolder(folder);
resources.addElement(folder.getAbsolutePath());
}
}
} catch (SQLException e){
<BUG>throw new CmsException(e.getMessage(),CmsException.C_SQL_ERROR, e);
</BUG>
}
return resources;
}
|
deleteFolder(folder);
createFolder(onlineProject,folder,folder.getAbsolutePath());
resources.addElement(folder.getAbsolutePath());
} else if (folder.getState() == C_STATE_DELETED) {
deleteFolder(folder);
resources.addElement(folder.getAbsolutePath());
}
}
} catch (SQLException e){
throw new CmsException("["+this.getClass().getName()+"]"+e.getMessage(),CmsException.C_SQL_ERROR, e);
}
return resources;
}
|
1,496 |
private A_CmsResource readResource(A_CmsProject project, String filename)
throws CmsException {
CmsResource file=null;
ResultSet res =null;
try {
<BUG>synchronized ( m_statementResourceRead) {
m_statementResourceRead.setString(1,absoluteName(filename));
m_statementResourceRead.setInt(2,project.getId());
res = m_statementResourceRead.executeQuery();
}</BUG>
if(res.next()) {
|
private A_CmsResource readResource(A_CmsProject project, String filename)
throws CmsException {
CmsResource file=null;
ResultSet res =null;
try {
PreparedStatement statementResourceRead=m_Con.prepareStatement(C_RESOURCE_READ);
statementResourceRead.setString(1,absoluteName(filename));
statementResourceRead.setInt(2,project.getId());
res = statementResourceRead.executeQuery();
if(res.next()) {
|
1,497 |
res.getLong(C_DATE_CREATED),
res.getLong(C_DATE_LASTMODIFIED),
res.getInt(C_SIZE)
);
} else {
<BUG>throw new CmsException(filename,CmsException.C_NOT_FOUND);
</BUG>
}
} catch (SQLException e){
<BUG>throw new CmsException(e.getMessage(),CmsException.C_SQL_ERROR, e);
</BUG>
}
|
res.getLong(C_DATE_CREATED),
res.getLong(C_DATE_LASTMODIFIED),
res.getInt(C_SIZE)
);
} else {
throw new CmsException("["+this.getClass().getName()+"]"+filename,CmsException.C_NOT_FOUND);
}
} catch (SQLException e){
throw new CmsException("["+this.getClass().getName()+"]"+e.getMessage(),CmsException.C_SQL_ERROR, e);
}
|
1,498 |
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
CmsRequestHttpServlet cmsReq= new CmsRequestHttpServlet(req);
CmsResponseHttpServlet cmsRes= new CmsResponseHttpServlet(req,res);
try {
<BUG>CmsObject cms=initUser(cmsReq,cmsRes);
CmsFile file=m_opencms.initResource(cms);
m_opencms.setResponse(cms,file);</BUG>
m_opencms.showResource(cms,file);
updateUser(cms,cmsReq,cmsRes);
|
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
CmsRequestHttpServlet cmsReq= new CmsRequestHttpServlet(req);
CmsResponseHttpServlet cmsRes= new CmsResponseHttpServlet(req,res);
try {
CmsObject cms=initUser(cmsReq,cmsRes);
System.err.println(cms.getRequestContext().currentUser().getName());
CmsFile file=m_opencms.initResource(cms);
System.err.println(file.toString());
m_opencms.setResponse(cms,file);
m_opencms.showResource(cms,file);
updateUser(cms,cmsReq,cmsRes);
|
1,499 |
public Vector getGroupsOfUser(int userid)
throws CmsException {
A_CmsGroup group;
Vector groups=new Vector();
ResultSet res = null;
<BUG>try {
PreparedStatement statementGetGroupsOfUser =
m_Con.prepareStatement(C_GETGROUPSOFUSER);</BUG>
statementGetGroupsOfUser.setInt(1,userid);
res = statementGetGroupsOfUser.executeQuery();
|
public Vector getGroupsOfUser(int userid)
throws CmsException {
A_CmsGroup group;
Vector groups=new Vector();
ResultSet res = null;
try {
PreparedStatement statementGetGroupsOfUser=m_Con.prepareStatement(C_GETGROUPSOFUSER);
statementGetGroupsOfUser.setInt(1,userid);
res = statementGetGroupsOfUser.executeQuery();
|
1,500 |
ResultSet res = null;
try{
PreparedStatement statementGroupReadId=m_Con.prepareStatement(C_GROUP_READID);
statementGroupReadId.setInt(1,id);
res = statementGroupReadId.executeQuery();
<BUG>Statement s = m_Con.createStatement();
s.setEscapeProcessing(false);
res = s.executeQuery("SELECT * FROM GROUPS WHERE GROUP_ID = "+id);</BUG>
if(res.next()) {
group=new CmsGroup(res.getInt(C_GROUP_ID),
|
ResultSet res = null;
try {
PreparedStatement statementGetGroupsOfUser=m_Con.prepareStatement(C_GETGROUPSOFUSER);
statementGetGroupsOfUser.setInt(1,userid);
res = statementGetGroupsOfUser.executeQuery();
while ( res.next() ) {
group=new CmsGroup(res.getInt(C_GROUP_ID),
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.