private static void finalize( Configuration conf, JobConf jobconf, final Path destPath, String presevedAttributes) throws IOException { if (presevedAttributes == null) { return; } EnumSet<FileAttribute> preseved = FileAttribute.parse(presevedAttributes); if (!preseved.contains(FileAttribute.USER) && !preseved.contains(FileAttribute.GROUP) && !preseved.contains(FileAttribute.PERMISSION)) { return; } FileSystem dstfs = destPath.getFileSystem(conf); Path dstdirlist = new Path(jobconf.get(DST_DIR_LIST_LABEL)); SequenceFile.Reader in = null; try { in = new SequenceFile.Reader(dstdirlist.getFileSystem(jobconf), dstdirlist, jobconf); Text dsttext = new Text(); FilePair pair = new FilePair(); for (; in.next(dsttext, pair); ) { Path absdst = new Path(destPath, pair.output); updatePermissions(pair.input, dstfs.getFileStatus(absdst), preseved, dstfs); } } finally { checkAndClose(in); } }
private void init() { this.transform_ = this.createJSTransform(); this.mouseWentDown() .addListener("function(o, e){var o=" + this.getSObjJsRef() + ";if(o){o.mouseDown(o, e);}}"); this.mouseWentUp() .addListener("function(o, e){var o=" + this.getSObjJsRef() + ";if(o){o.mouseUp(o, e);}}"); this.mouseDragged() .addListener("function(o, e){var o=" + this.getSObjJsRef() + ";if(o){o.mouseDrag(o, e);}}"); this.mouseMoved() .addListener( "function(o, e){var o=" + this.getSObjJsRef() + ";if(o){o.mouseMoved(o, e);}}"); this.touchStarted() .addListener( "function(o, e){var o=" + this.getSObjJsRef() + ";if(o){o.touchStarted(o, e);}}"); this.touchEnded() .addListener( "function(o, e){var o=" + this.getSObjJsRef() + ";if(o){o.touchEnded(o, e);}}"); this.touchMoved() .addListener( "function(o, e){var o=" + this.getSObjJsRef() + ";if(o){o.touchMoved(o, e);}}"); this.setSelectionAreaPadding(0, EnumSet.of(Side.Top)); this.setSelectionAreaPadding(20, EnumSet.of(Side.Left, Side.Right)); this.setSelectionAreaPadding(30, EnumSet.of(Side.Bottom)); if (this.chart_ != null) { this.chart_.addAxisSliderWidget(this); } }
private void internalScrollTo(long newX, long newY, boolean moveViewPort) { if (this.imageWidth_ != Infinite) { newX = Math.min(this.imageWidth_ - this.viewPortWidth_, Math.max((long) 0, newX)); } if (this.imageHeight_ != Infinite) { newY = Math.min(this.imageHeight_ - this.viewPortHeight_, Math.max((long) 0, newY)); } if (moveViewPort) { this.contents_.setOffsets(new WLength((double) -newX), EnumSet.of(Side.Left)); this.contents_.setOffsets(new WLength((double) -newY), EnumSet.of(Side.Top)); } this.generateGridItems(newX, newY); this.viewPortChanged_.trigger(this.currentX_, this.currentY_); }
/** * Parses a list of tags from the command line, assuming it comes from the GATK Engine tags, and * returns the corresponding EnumSet. * * @param arg the actual engine arg, used for the UserException if there's an error * @param tags a list of string tags that should be converted to the MissingPedField value * @return */ public static final EnumSet<MissingPedField> parseMissingFieldTags( final Object arg, final List<String> tags) { final EnumSet<MissingPedField> missingFields = EnumSet.noneOf(MissingPedField.class); for (final String tag : tags) { try { missingFields.add(MissingPedField.valueOf(tag)); } catch (IllegalArgumentException e) { throw new UserException.BadArgumentValue( arg.toString(), "Unknown tag " + tag + " allowed values are " + MissingPedField.values()); } } return missingFields; }
void expand(int row, int column, int rowSpan, int columnSpan) { int newNumRows = row + rowSpan; int curNumColumns = this.getColumnCount(); int newNumColumns = Math.max(curNumColumns, column + columnSpan); if (newNumRows > this.getRowCount() || newNumColumns > curNumColumns) { if (newNumColumns == curNumColumns && this.getRowCount() >= this.headerRowCount_) { this.rowsAdded_ += newNumRows - this.getRowCount(); } else { this.flags_.set(BIT_GRID_CHANGED); } this.repaint(EnumSet.of(RepaintFlag.RepaintInnerHtml)); for (int r = this.getRowCount(); r < newNumRows; ++r) { this.rows_.add(new WTableRow(this, newNumColumns)); } if (newNumColumns > curNumColumns) { for (int r = 0; r < this.getRowCount(); ++r) { WTableRow tr = this.rows_.get(r); tr.expand(newNumColumns); } for (int c = curNumColumns; c <= column; ++c) { this.columns_.add(new WTableColumn(this)); } } } }
/** * Consctructor for a media widget. * * <p>A freshly constructed media widget has no options set, no media sources, and has preload * mode set to PreloadAuto. */ public WAbstractMedia(WContainerWidget parent) { super(parent); this.sources_ = new ArrayList<WAbstractMedia.Source>(); this.sourcesRendered_ = 0; this.mediaId_ = ""; this.flags_ = EnumSet.noneOf(WAbstractMedia.Options.class); this.preloadMode_ = WAbstractMedia.PreloadMode.PreloadAuto; this.alternative_ = null; this.flagsChanged_ = false; this.preloadChanged_ = false; this.sourcesChanged_ = false; this.playing_ = false; this.volume_ = -1; this.current_ = -1; this.duration_ = -1; this.ended_ = false; this.readyState_ = WAbstractMedia.ReadyState.HaveNothing; this.setInline(false); this.setFormObject(true); WApplication app = WApplication.getInstance(); app.loadJavaScript("js/WAbstractMedia.js", wtjs1()); this.setJavaScriptMember( " WAbstractMedia", "new Wt3_2_3.WAbstractMedia(" + app.getJavaScriptClass() + "," + this.getJsRef() + ");"); }
/** * Get the active cipher suites. * * <p>In TLS 1.1, many weak or vulnerable cipher suites were obsoleted, such as * TLS_RSA_EXPORT_WITH_RC4_40_MD5. The implementation MUST NOT negotiate these cipher suites in * TLS 1.1 or later mode. * * <p>Therefore, when the active protocols only include TLS 1.1 or later, the client cannot * request to negotiate those obsoleted cipher suites. That is, the obsoleted suites should not be * included in the client hello. So we need to create a subset of the enabled cipher suites, the * active cipher suites, which does not contain obsoleted cipher suites of the minimum active * protocol. * * <p>Return empty list instead of null if no active cipher suites. */ CipherSuiteList getActiveCipherSuites() { if (activeCipherSuites == null) { if (activeProtocols == null) { activeProtocols = getActiveProtocols(); } ArrayList<CipherSuite> suites = new ArrayList<>(); if (!(activeProtocols.collection().isEmpty()) && activeProtocols.min.v != ProtocolVersion.NONE.v) { for (CipherSuite suite : enabledCipherSuites.collection()) { if (suite.obsoleted > activeProtocols.min.v && suite.supported <= activeProtocols.max.v) { if (algorithmConstraints.permits( EnumSet.of(CryptoPrimitive.KEY_AGREEMENT), suite.name, null)) { suites.add(suite); } } else if (debug != null && Debug.isOn("verbose")) { if (suite.obsoleted <= activeProtocols.min.v) { System.out.println("Ignoring obsoleted cipher suite: " + suite); } else { System.out.println("Ignoring unsupported cipher suite: " + suite); } } } } activeCipherSuites = new CipherSuiteList(suites); } return activeCipherSuites; }
/* * Get the active protocol versions. * * In TLS 1.1, many weak or vulnerable cipher suites were obsoleted, * such as TLS_RSA_EXPORT_WITH_RC4_40_MD5. The implementation MUST NOT * negotiate these cipher suites in TLS 1.1 or later mode. * * For example, if "TLS_RSA_EXPORT_WITH_RC4_40_MD5" is the * only enabled cipher suite, the client cannot request TLS 1.1 or * later, even though TLS 1.1 or later is enabled. We need to create a * subset of the enabled protocols, called the active protocols, which * contains protocols appropriate to the list of enabled Ciphersuites. * * Return empty list instead of null if no active protocol versions. */ ProtocolList getActiveProtocols() { if (activeProtocols == null) { ArrayList<ProtocolVersion> protocols = new ArrayList<>(4); for (ProtocolVersion protocol : enabledProtocols.collection()) { boolean found = false; for (CipherSuite suite : enabledCipherSuites.collection()) { if (suite.isAvailable() && suite.obsoleted > protocol.v && suite.supported <= protocol.v) { if (algorithmConstraints.permits( EnumSet.of(CryptoPrimitive.KEY_AGREEMENT), suite.name, null)) { protocols.add(protocol); found = true; break; } else if (debug != null && Debug.isOn("verbose")) { System.out.println("Ignoring disabled cipher suite: " + suite + " for " + protocol); } } else if (debug != null && Debug.isOn("verbose")) { System.out.println("Ignoring unsupported cipher suite: " + suite + " for " + protocol); } } if (!found && (debug != null) && Debug.isOn("handshake")) { System.out.println("No available cipher suite for " + protocol); } } activeProtocols = new ProtocolList(protocols); } return activeProtocols; }
/** * Adds a widget to the grid. * * <p>Calls {@link #addWidget(WWidget widget, int row, int column, int rowSpan, int columnSpan, * EnumSet alignment) addWidget(widget, row, column, rowSpan, columnSpan, EnumSet.of(alignmen, * alignment))} */ public final void addWidget( WWidget widget, int row, int column, int rowSpan, int columnSpan, AlignmentFlag alignmen, AlignmentFlag... alignment) { addWidget(widget, row, column, rowSpan, columnSpan, EnumSet.of(alignmen, alignment)); }
/** * Adds a nested layout item to the grid. * * <p>Calls {@link #addLayout(WLayout layout, int row, int column, int rowSpan, int columnSpan, * EnumSet alignment) addLayout(layout, row, column, rowSpan, columnSpan, EnumSet.of(alignmen, * alignment))} */ public final void addLayout( WLayout layout, int row, int column, int rowSpan, int columnSpan, AlignmentFlag alignmen, AlignmentFlag... alignment) { addLayout(layout, row, column, rowSpan, columnSpan, EnumSet.of(alignmen, alignment)); }
/** * Adds a layout item to the grid. * * <p>Calls {@link #addItem(WLayoutItem item, int row, int column, int rowSpan, int columnSpan, * EnumSet alignment) addItem(item, row, column, rowSpan, columnSpan, EnumSet.of(alignmen, * alignment))} */ public final void addItem( WLayoutItem item, int row, int column, int rowSpan, int columnSpan, AlignmentFlag alignmen, AlignmentFlag... alignment) { addItem(item, row, column, rowSpan, columnSpan, EnumSet.of(alignmen, alignment)); }
void repaintRow(WTableRow row) { if (row.getRowNum() >= (int) (this.getRowCount() - this.rowsAdded_)) { return; } if (!(this.rowsChanged_ != null)) { this.rowsChanged_ = new HashSet<WTableRow>(); } this.rowsChanged_.add(row); this.repaint(EnumSet.of(RepaintFlag.RepaintInnerHtml)); }
/** Delete a column and all its contents. */ public void deleteColumn(int column) { for (int i = 0; i < this.getRowCount(); ++i) { this.rows_.get(i).deleteColumn(column); } if ((int) column <= this.columns_.size()) {; this.columns_.remove(0 + column); } this.flags_.set(BIT_GRID_CHANGED); this.repaint(EnumSet.of(RepaintFlag.RepaintInnerHtml)); }
private static void updatePermissions( FileStatus src, FileStatus dst, EnumSet<FileAttribute> preseved, FileSystem destFileSys) throws IOException { String owner = null; String group = null; if (preseved.contains(FileAttribute.USER) && !src.getOwner().equals(dst.getOwner())) { owner = src.getOwner(); } if (preseved.contains(FileAttribute.GROUP) && !src.getGroup().equals(dst.getGroup())) { group = src.getGroup(); } if (owner != null || group != null) { destFileSys.setOwner(dst.getPath(), owner, group); } if (preseved.contains(FileAttribute.PERMISSION) && !src.getPermission().equals(dst.getPermission())) { destFileSys.setPermission(dst.getPath(), src.getPermission()); } }
/** Inserts an empty row. */ public WTableRow insertRow(int row) { if (row >= this.getRowCount()) { return this.getRowAt(row); } else { WTableRow tableRow = new WTableRow(this, this.getColumnCount()); this.rows_.add(0 + row, tableRow); this.flags_.set(BIT_GRID_CHANGED); this.repaint(EnumSet.of(RepaintFlag.RepaintInnerHtml)); return tableRow; } }
private FSDataOutputStream create(Path f, Reporter reporter, FileStatus srcstat) throws IOException { if (destFileSys.exists(f)) { destFileSys.delete(f, false); } if (!preserve_status) { return destFileSys.create(f, true, sizeBuf, reporter); } FsPermission permission = preseved.contains(FileAttribute.PERMISSION) ? srcstat.getPermission() : null; short replication = preseved.contains(FileAttribute.REPLICATION) ? srcstat.getReplication() : destFileSys.getDefaultReplication(); long blockSize = preseved.contains(FileAttribute.BLOCK_SIZE) ? srcstat.getBlockSize() : destFileSys.getDefaultBlockSize(); return destFileSys.create(f, permission, true, sizeBuf, replication, blockSize, reporter); }
private void generateGridItems(long newX, long newY) { WVirtualImage.Rect newNb = this.neighbourhood(newX, newY, this.viewPortWidth_, this.viewPortHeight_); long i1 = newNb.x1 / this.gridImageSize_; long j1 = newNb.y1 / this.gridImageSize_; long i2 = newNb.x2 / this.gridImageSize_ + 1; long j2 = newNb.y2 / this.gridImageSize_ + 1; for (int invisible = 0; invisible < 2; ++invisible) { for (long i = i1; i < i2; ++i) { for (long j = j1; j < j2; ++j) { long key = this.gridKey(i, j); WImage it = this.grid_.get(key); if (it == null) { boolean v = this.visible(i, j); if (v && !(invisible != 0) || !v && invisible != 0) { long brx = i * this.gridImageSize_ + this.gridImageSize_; long bry = j * this.gridImageSize_ + this.gridImageSize_; brx = Math.min(brx, this.imageWidth_); bry = Math.min(bry, this.imageHeight_); WImage img = this.createImage( i * this.gridImageSize_, j * this.gridImageSize_, (int) (brx - i * this.gridImageSize_), (int) (bry - j * this.gridImageSize_)); img.setAttributeValue("onmousedown", "return false;"); this.contents_.addWidget(img); img.setPositionScheme(PositionScheme.Absolute); img.setOffsets(new WLength((double) i * this.gridImageSize_), EnumSet.of(Side.Left)); img.setOffsets(new WLength((double) j * this.gridImageSize_), EnumSet.of(Side.Top)); this.grid_.put(key, img); } } } } } this.currentX_ = newX; this.currentY_ = newY; this.cleanGrid(); }
/** Inserts an empty column. */ public WTableColumn insertColumn(int column) { for (int i = 0; i < this.rows_.size(); ++i) { this.rows_.get(i).insertColumn(column); } WTableColumn tableColumn = null; if ((int) column <= this.columns_.size()) { tableColumn = new WTableColumn(this); this.columns_.add(0 + column, tableColumn); } this.flags_.set(BIT_GRID_CHANGED); this.repaint(EnumSet.of(RepaintFlag.RepaintInnerHtml)); return tableColumn; }
static EnumSet<FileAttribute> parse(String s) { if (s == null || s.length() == 0) { return EnumSet.allOf(FileAttribute.class); } EnumSet<FileAttribute> set = EnumSet.noneOf(FileAttribute.class); FileAttribute[] attributes = values(); for (char c : s.toCharArray()) { int i = 0; for (; i < attributes.length && c != attributes[i].symbol; i++) ; if (i < attributes.length) { if (!set.contains(attributes[i])) { set.add(attributes[i]); } else { throw new IllegalArgumentException( "There are more than one '" + attributes[i].symbol + "' in " + s); } } else { throw new IllegalArgumentException("'" + c + "' in " + s + " is undefined."); } } return set; }
@Deprecated public static void copy( Configuration conf, String srcPath, String destPath, Path logPath, boolean srcAsList, boolean ignoreReadFailures) throws IOException { final Path src = new Path(srcPath); List<Path> tmp = new ArrayList<Path>(); if (srcAsList) { tmp.addAll(fetchFileList(conf, src)); } else { tmp.add(src); } EnumSet<Options> flags = ignoreReadFailures ? EnumSet.of(Options.IGNORE_READ_FAILURES) : EnumSet.noneOf(Options.class); final Path dst = new Path(destPath); copy(conf, new Arguments(tmp, dst, logPath, flags, null, Long.MAX_VALUE, Long.MAX_VALUE, null)); }
/** * Move a table row from its original position to a new position. * * <p>The table expands automatically when the <code>to</code> row is beyond the current table * dimensions. * * <p> * * @see WTable#moveColumn(int from, int to) */ public void moveRow(int from, int to) { if (from < 0 || from >= (int) this.rows_.size()) { logger.error( new StringWriter() .append("moveRow: the from index is not a valid row index.") .toString()); return; } WTableRow from_tr = this.getRowAt(from); this.rows_.remove(from_tr); if (to > (int) this.rows_.size()) { this.getRowAt(to); } this.rows_.add(0 + to, from_tr); this.flags_.set(BIT_GRID_CHANGED); this.repaint(EnumSet.of(RepaintFlag.RepaintInnerHtml)); }
/** * Deletes a row and all its contents. * * <p>Rows below the given row are shifted up. */ public void deleteRow(int row) { if (this.rowsChanged_ != null) { this.rowsChanged_.remove(this.rows_.get(row)); if (this.rowsChanged_.isEmpty()) {; this.rowsChanged_ = null; } } for (int i = 0; i < this.getColumnCount(); ++i) { WTableCell cell = this.rows_.get(row).cells_.get(i).cell; if (cell != null) cell.remove(); } if (row >= (int) (this.getRowCount() - this.rowsAdded_)) { --this.rowsAdded_; } else { this.flags_.set(BIT_GRID_CHANGED); this.repaint(EnumSet.of(RepaintFlag.RepaintInnerHtml)); } ; this.rows_.remove(0 + row); }
/** * Adds a layout item to the grid. * * <p>Adds the <i>item</i> at (<i>row</i>, <code>column</code>). If an item was already added to * that location, it is replaced (but not deleted). * * <p>An item may span several more rows or columns, which is controlled by <i>rowSpan</i> and * <code>columnSpan</code>. * * <p>The <code>alignment</code> specifies the vertical and horizontal alignment of the item. The * default value 0 indicates that the item is stretched to fill the entire grid cell. The * alignment can be specified as a logical combination of a horizontal alignment ( {@link * AlignmentFlag#AlignLeft}, {@link AlignmentFlag#AlignCenter}, or {@link * AlignmentFlag#AlignRight}) and a vertical alignment ( {@link AlignmentFlag#AlignTop}, {@link * AlignmentFlag#AlignMiddle}, or {@link AlignmentFlag#AlignBottom}). * * <p> * * @see WGridLayout#addLayout(WLayout layout, int row, int column, EnumSet alignment) * @see WGridLayout#addWidget(WWidget widget, int row, int column, EnumSet alignment) */ public void addItem( WLayoutItem item, int row, int column, int rowSpan, int columnSpan, EnumSet<AlignmentFlag> alignment) { columnSpan = Math.max(1, columnSpan); rowSpan = Math.max(1, rowSpan); this.expand(row, column, rowSpan, columnSpan); final Grid.Item gridItem = this.grid_.items_.get(row).get(column); if (gridItem.item_ != null) { WLayoutItem oldItem = gridItem.item_; gridItem.item_ = null; this.updateRemoveItem(oldItem); } gridItem.item_ = item; gridItem.rowSpan_ = rowSpan; gridItem.colSpan_ = columnSpan; gridItem.alignment_ = EnumSet.copyOf(alignment); this.updateAddItem(item); }
/** * Move a table column from its original position to a new position. * * <p>The table expands automatically when the <code>to</code> column is beyond the current table * dimensions. * * <p> * * @see WTable#moveRow(int from, int to) */ public void moveColumn(int from, int to) { if (from < 0 || from >= (int) this.columns_.size()) { logger.error( new StringWriter() .append("moveColumn: the from index is not a valid column index.") .toString()); return; } WTableColumn from_tc = this.getColumnAt(from); this.columns_.remove(from_tc); if (to > (int) this.columns_.size()) { this.getColumnAt(to); } this.columns_.add(0 + to, from_tc); for (int i = 0; i < this.rows_.size(); i++) { List<WTableRow.TableData> cells = this.rows_.get(i).cells_; WTableRow.TableData cell = cells.get(from); cells.remove(0 + from); cells.add(0 + to, cell); } this.flags_.set(BIT_GRID_CHANGED); this.repaint(EnumSet.of(RepaintFlag.RepaintInnerHtml)); }
public void resourceChanged() { this.parent.sourcesChanged_ = true; this.parent.repaint(EnumSet.of(RepaintFlag.RepaintPropertyAttribute)); }
/** * Add a media source. * * <p>This method specifies a media source (which may be a URL or dynamic resource). You may add * as many media sources as you want. The browser will select the appropriate media stream to * display to the user. * * <p>This method specifies a media source using the URL, the mime type, and the media attribute. * HTML allows for empty type and media attributes. */ public void addSource(WLink link, String type, String media) { this.sources_.add(new WAbstractMedia.Source(this, link, type, media)); this.sourcesChanged_ = true; this.repaint(EnumSet.of(RepaintFlag.RepaintPropertyAttribute)); }
/** * Removes all source elements. * * <p>This method can be used to remove all media sources. Afterward, you may add new media * sources with calls to {@link WAbstractMedia#addSource(WLink link, String type, String media) * addSource()}. * * <p>Use this to reuse a {@link WAbstractMedia} instantiation to play something else. */ public void clearSources() { for (int i = 0; i < this.sources_.size(); ++i) {; } this.sources_.clear(); this.repaint(EnumSet.of(RepaintFlag.RepaintPropertyAttribute)); }
/** Set the preload mode. */ public void setPreloadMode(WAbstractMedia.PreloadMode mode) { this.preloadMode_ = mode; this.preloadChanged_ = true; this.repaint(EnumSet.of(RepaintFlag.RepaintPropertyAttribute)); }
/** * Set the media element options. * * <p>Calls {@link #setOptions(EnumSet flags) setOptions(EnumSet.of(flag, flags))} */ public final void setOptions(WAbstractMedia.Options flag, WAbstractMedia.Options... flags) { setOptions(EnumSet.of(flag, flags)); }
/** * Set the media element options. * * <p> * * @see WAbstractMedia.Options */ public void setOptions(EnumSet<WAbstractMedia.Options> flags) { this.flags_ = EnumSet.copyOf(flags); this.flagsChanged_ = true; this.repaint(EnumSet.of(RepaintFlag.RepaintPropertyAttribute)); }