List of usage examples for java.util EnumSet of
@SafeVarargs public static <E extends Enum<E>> EnumSet<E> of(E first, E... rest)
From source file:ch.cyberduck.core.b2.B2ReadFeatureTest.java
@Test public void testReadChunkedTransfer() throws Exception { final B2Session session = new B2Session(new Host(new B2Protocol(), new B2Protocol().getDefaultHostname(), new Credentials(System.getProperties().getProperty("b2.user"), System.getProperties().getProperty("b2.key")))); final LoginConnectionService service = new LoginConnectionService(new DisabledLoginCallback(), new DisabledHostKeyCallback(), new DisabledPasswordStore(), new DisabledProgressListener()); service.connect(session, PathCache.empty(), new DisabledCancelCallback()); final Path bucket = new Path("test-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume)); final Path file = new Path(bucket, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); final byte[] content = RandomUtils.nextBytes(923); final TransferStatus status = new TransferStatus(); status.setLength(content.length);/*from www . j a v a 2 s .com*/ status.setChecksum(new SHA1ChecksumCompute().compute(new ByteArrayInputStream(content), status)); final HttpResponseOutputStream<BaseB2Response> out = new B2WriteFeature(session).write(file, status, new DisabledConnectionCallback()); IOUtils.write(content, out); out.close(); final Local local = new Local(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString()); assertEquals(-1L, local.attributes().getSize()); new DefaultDownloadFeature(new B2ReadFeature(session)).download(file, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledStreamListener(), new TransferStatus() { @Override public void setLength(long length) { assertEquals(923L, length); // Ignore update. As with unknown length for chunked transfer } }, new DisabledLoginCallback(), new DisabledPasswordCallback()); assertEquals(923L, local.attributes().getSize()); new B2DeleteFeature(session).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback()); session.close(); }
From source file:com.facebook.presto.geospatial.GeoFunctions.java
@Description("Returns the area of a polygon using Euclidean measurement on a 2D plane (based on spatial ref) in projected units") @ScalarFunction("ST_Area") @SqlType(StandardTypes.DOUBLE)/*from ww w .j ava 2s .c o m*/ public static double stArea(@SqlType(GEOMETRY_TYPE_NAME) Slice input) { OGCGeometry geometry = deserialize(input); validateType("ST_Area", geometry, EnumSet.of(POLYGON, MULTI_POLYGON)); return geometry.getEsriGeometry().calculateArea2D(); }
From source file:com.twosigma.beaker.r.rest.RShellRest.java
private String makeTemp(String base, String suffix) throws IOException { File dir = new File(System.getenv("beaker_tmp_dir")); File tmp = File.createTempFile(base, suffix, dir); if (!windows()) { Set<PosixFilePermission> perms = EnumSet.of(PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE); Files.setPosixFilePermissions(tmp.toPath(), perms); }// www.j a va2 s.c om return tmp.getAbsolutePath(); }
From source file:com.slytechs.utils.number.Version.java
/** * Initialized with major, minor version. * /*from ww w . j a va 2 s . co m*/ * @param major * major version * * @param minor * minor version */ public Version(int major, int minor) { this.major = major; this.minor = minor; this.detail = EnumSet.of(VersionDetail.Major, VersionDetail.Minor); map.put(VersionDetail.Major, major); map.put(VersionDetail.Minor, minor); }
From source file:ch.cyberduck.core.s3.S3AccessControlListFeatureTest.java
@Test public void testReadKey() throws Exception { final S3Session session = new S3Session(new Host(new S3Protocol(), new S3Protocol().getDefaultHostname(), new Credentials(System.getProperties().getProperty("s3.key"), System.getProperties().getProperty("s3.secret")))); session.open(new DisabledHostKeyCallback(), new DisabledTranscriptListener()); session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback()); final Path container = new Path("test-acl-us-east-1-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume)); final Acl acl = new S3AccessControlListFeature(session) .getPermission(new Path(container, "test", EnumSet.of(Path.Type.file))); assertTrue(acl.containsKey(new Acl.GroupUser("http://acs.amazonaws.com/groups/global/AllUsers"))); assertTrue(acl.get(new Acl.GroupUser("http://acs.amazonaws.com/groups/global/AllUsers")) .contains(new Acl.Role(Acl.Role.READ))); assertTrue(acl.containsKey(/*from w w w.j a va 2 s . c om*/ new Acl.CanonicalUser("80b9982b7b08045ee86680cc47f43c84bf439494a89ece22b5330f8a49477cf6"))); assertTrue( acl.get(new Acl.CanonicalUser("80b9982b7b08045ee86680cc47f43c84bf439494a89ece22b5330f8a49477cf6")) .contains(new Acl.Role(Acl.Role.FULL))); session.close(); }
From source file:com.gosmarter.it.eis.config.ExcelERPWebApplicationInitializer.java
private void registerSpringSecurityFilterChain(ServletContext servletContext) { DelegatingFilterProxy delegatingFilterProxy = new DelegatingFilterProxy("springSecurityFilterChain"); FilterRegistration fr = servletContext.addFilter("securityFilter", delegatingFilterProxy); fr.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD), true, "/*"); }
From source file:ch.cyberduck.core.b2.B2WriteFeatureTest.java
@Test public void testWrite() throws Exception { final B2Session session = new B2Session(new Host(new B2Protocol(), new B2Protocol().getDefaultHostname(), new Credentials(System.getProperties().getProperty("b2.user"), System.getProperties().getProperty("b2.key")))); session.open(new DisabledHostKeyCallback()); session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback()); final Path bucket = new Path("test-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume)); final Path test = new Path(bucket, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); final TransferStatus status = new TransferStatus(); final byte[] content = "test".getBytes("UTF-8"); status.setLength(content.length);//w w w . j av a 2 s.c om status.setChecksum(new SHA1ChecksumCompute().compute(new ByteArrayInputStream(content), status)); status.setTimestamp(1503654614004L); final OutputStream out = new B2WriteFeature(session).write(test, status, new DisabledConnectionCallback()); assertNotNull(out); new StreamCopier(new TransferStatus(), new TransferStatus()).transfer(new ByteArrayInputStream(content), out); out.close(); test.attributes() .setVersionId(new B2FileidProvider(session).getFileid(test, new DisabledListProgressListener())); assertTrue(new B2FindFeature(session).find(test)); final PathAttributes attributes = session.list(test.getParent(), new DisabledListProgressListener()) .get(test).attributes(); assertEquals(content.length, attributes.getSize()); final Write.Append append = new B2WriteFeature(session).append(test, status.getLength(), PathCache.empty()); assertTrue(append.override); assertEquals(content.length, append.size, 0L); final byte[] buffer = new byte[content.length]; final InputStream in = new B2ReadFeature(session).read(test, new TransferStatus(), new DisabledConnectionCallback()); IOUtils.readFully(in, buffer); in.close(); assertArrayEquals(content, buffer); assertEquals(1503654614004L, new B2AttributesFinderFeature(session).find(test).getModificationDate()); new B2DeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback()); session.close(); }
From source file:com.almende.eve.transport.http.embed.JettyLauncher.java
@Override public void addFilter(final String filterpath, final String path) { LOG.info("Adding filter:" + filterpath + " / " + path); context.addFilter(filterpath, path, EnumSet.of(DispatcherType.INCLUDE, DispatcherType.REQUEST)); }
From source file:com.seajas.search.contender.service.storage.StorageService.java
/** * Retrieve a CompositeEntry document by its ID. * * @param compositeUrl//from ww w.jav a 2 s. c o m * @return CompositeEntry */ public CompositeEntry retrieveEntryByCompositeUrl(final String compositeUrl) { Query query = new Query().addCriteria(where("enricherElement._id").is(compositeUrl)); CompositeEntry entry = mongoTemplate.findOne(query, CompositeEntry.class, defaultCollection); if (entry != null && !EnumSet.of(CompositeState.Source, CompositeState.SourceElement) .contains(entry.getCurrentState())) { if (entry.getOriginalContent() != null) { GridFSDBFile file = gridFs.find(entry.getOriginalContent().getId()); entry.getOriginalContent().setContent(new BufferedInputStream(file.getInputStream())); } else if (entry.getModifiedContent() != null) { GridFSDBFile file = gridFs.find(entry.getModifiedContent().getId()); entry.getModifiedContent().setContent(new BufferedInputStream(file.getInputStream())); } else logger.error( "Content retrieval is relevant given this entry's current state, but no content has been stored"); } return entry; }
From source file:be.nille.generator.parser.ParserService.java
public void testService() throws IOException { try (JavaWriter writer = new JavaWriter(getPrintWriter())) { writer.emitPackage("com.example") .emitImports("javax.persistence.Column", "javax.persistence.Entity", "javax.persistence.GeneratedValue", "javax.persistence.Id", "javax.persistence.Table") .emitEmptyLine().emitAnnotation("Entity").emitAnnotation("Column(name=\"TBL_PERSON\")") .beginType("com.example.Person", "class", EnumSet.of(PUBLIC, FINAL)) .emitField("String", "firstName", EnumSet.of(PRIVATE)) .emitField("String", "lastName", EnumSet.of(PRIVATE)) .emitJavadoc("Returns the person's full name.") .beginMethod("String", "getName", EnumSet.of(PUBLIC)) .emitStatement("return firstName + \" \" + lastName").endMethod().endType(); }/*from ww w.ja va 2s .c o m*/ }