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.openstack.SwiftLargeUploadWriteFeatureTest.java
@Test public void testWriteUploadLargeBuffer() throws Exception { final Host host = new Host(new SwiftProtocol(), "identity.api.rackspacecloud.com", new Credentials(System.getProperties().getProperty("rackspace.key"), System.getProperties().getProperty("rackspace.secret"))); final SwiftSession session = new SwiftSession(host); session.open(new DisabledHostKeyCallback()); session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback()); final SwiftRegionService regionService = new SwiftRegionService(session); final SwiftLargeUploadWriteFeature feature = new SwiftLargeUploadWriteFeature(session, regionService, new SwiftSegmentService(session, ".segments-test/")); final Path container = new Path("test.cyberduck.ch", EnumSet.of(Path.Type.directory, Path.Type.volume)); container.attributes().setRegion("DFW"); final TransferStatus status = new TransferStatus(); status.setLength(-1L);//from w w w. jav a 2 s.c o m final Path file = new Path(container, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); final OutputStream out = feature.write(file, status, new DisabledConnectionCallback()); final byte[] content = RandomUtils.nextBytes(6 * 1024 * 1024); final ByteArrayInputStream in = new ByteArrayInputStream(content); final TransferStatus progress = new TransferStatus(); new StreamCopier(new TransferStatus(), progress).transfer(in, out); assertEquals(content.length, progress.getOffset()); in.close(); out.close(); assertTrue(new SwiftFindFeature(session).find(file)); final byte[] compare = new byte[content.length]; final InputStream stream = new SwiftReadFeature(session, regionService).read(file, new TransferStatus().length(content.length), new DisabledConnectionCallback()); IOUtils.readFully(stream, compare); stream.close(); assertArrayEquals(content, compare); new SwiftDeleteFeature(session).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback()); session.close(); }
From source file:com.iflytek.edu.cloud.frame.web.RestServiceWebApplicationInitializer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { servletContext.setInitParameter("contextConfigLocation", "classpath*:META-INF/spring/*-context.xml"); servletContext.setInitParameter("contextInitializerClasses", ProfileApplicationContextInitializer.class.getName()); servletContext.addListener(new LogBackLoadConfigureListener()); servletContext.addListener(new ContextLoaderListener()); FilterRegistration.Dynamic characterEncodingFilter = servletContext.addFilter("characterEncodingFilter", new CharacterEncodingFilter()); EnumSet<DispatcherType> characterEncodingFilterDispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD);//w w w. java2 s . c o m characterEncodingFilter.setInitParameter("encoding", "UTF-8"); characterEncodingFilter.setInitParameter("forceEncoding", "true"); characterEncodingFilter.addMappingForUrlPatterns(characterEncodingFilterDispatcherTypes, true, "/*"); FilterRegistration.Dynamic openServiceFilter = servletContext.addFilter("openServiceFilter", new DelegatingFilterProxy()); EnumSet<DispatcherType> openServiceFilterDispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD); openServiceFilter.addMappingForUrlPatterns(openServiceFilterDispatcherTypes, true, "/api"); if (EnvUtil.jdbcEnabled()) { FilterRegistration.Dynamic serviceMetricsFilter = servletContext.addFilter("serviceMetricsFilter", new DelegatingFilterProxy()); EnumSet<DispatcherType> serviceMetricsFilterDispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD); serviceMetricsFilter.addMappingForUrlPatterns(serviceMetricsFilterDispatcherTypes, true, "/api"); } FilterRegistration.Dynamic CORSFilter = servletContext.addFilter("CORSFilter", new DelegatingFilterProxy()); EnumSet<DispatcherType> CORSFilterDispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD); CORSFilter.addMappingForUrlPatterns(CORSFilterDispatcherTypes, true, "/api"); if (EnvUtil.oauthEnabled()) { FilterRegistration.Dynamic springSecurityFilterChain = servletContext .addFilter("springSecurityFilterChain", new DelegatingFilterProxyExt()); EnumSet<DispatcherType> springSecurityFilterChainDispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD); springSecurityFilterChain.addMappingForUrlPatterns(springSecurityFilterChainDispatcherTypes, true, "/api"); } else { logger.info( "?oauth2???META-INF/res/profile.propertiesoauth2 profile"); } ServletRegistration.Dynamic dispatcherServlet = servletContext.addServlet("rest", new DispatcherServlet()); dispatcherServlet.setLoadOnStartup(1); dispatcherServlet.setInitParameter("contextClass", AnnotationConfigWebApplicationContext.class.getName()); dispatcherServlet.setInitParameter("contextConfigLocation", "org.spring.rest"); dispatcherServlet.setMultipartConfig(getMultiPartConfig()); dispatcherServlet.addMapping("/api"); ServletRegistration.Dynamic printProjectVersionServlet = servletContext .addServlet("printProjectVersionServlet", new PrintProjectVersionServlet()); printProjectVersionServlet.setLoadOnStartup(Integer.MAX_VALUE); }
From source file:ch.cyberduck.core.b2.B2ObjectListServiceTest.java
@Test public void testList() 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 B2DirectoryFeature(session) .mkdir(new Path(String.format("test-%s", UUID.randomUUID().toString()), EnumSet.of(Path.Type.directory, Path.Type.volume)), null, new TransferStatus()); final Path file = new Path(bucket, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); final TransferStatus status = new TransferStatus(); status.setChecksum(Checksum.parse("da39a3ee5e6b4b0d3255bfef95601890afd80709")); final HttpResponseOutputStream<BaseB2Response> out = new B2WriteFeature(session).write(file, status, new DisabledConnectionCallback()); IOUtils.write(new byte[0], out); out.close();/*from w ww . ja va 2 s. c o m*/ final B2FileResponse resopnse = (B2FileResponse) out.getStatus(); final AttributedList<Path> list = new B2ObjectListService(session).list(bucket, new DisabledListProgressListener()); assertNotNull(list.find(new SimplePathPredicate(file))); assertEquals("1", list.find(new SimplePathPredicate(file)).attributes().getRevision()); assertEquals(0L, list.find(new SimplePathPredicate(file)).attributes().getSize()); new B2DeleteFeature(session).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback()); assertFalse( new B2ObjectListService(session).list(bucket, new DisabledListProgressListener()).contains(file)); new B2DeleteFeature(session).delete(Collections.singletonList(bucket), new DisabledLoginCallback(), new Delete.DisabledCallback()); session.close(); }
From source file:br.eti.danielcamargo.backend.common.config.WebAppInitializer.java
private void configureSpringSecurity(ServletContext servletContext, WebApplicationContext rootContext) { EnumSet<DispatcherType> dispacherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD); FilterRegistration.Dynamic springSecurity = servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy("springSecurityFilterChain", rootContext)); springSecurity.addMappingForUrlPatterns(dispacherTypes, true, "/*"); }
From source file:ReportResourcesIT.java
public void testGetReport() throws SmartsheetException, IOException { EnumSet<ReportInclusion> reportInclusions = EnumSet.of(ReportInclusion.ATTACHMENTS, ReportInclusion.DISCUSSIONS); Report report = smartsheet.reportResources().getReport(reportId, reportInclusions, 1, 1); smartsheet.reportResources().getReport(reportId, null, null, null); assertNotNull(report);/*from ww w. j a v a 2 s . c o m*/ }
From source file:ch.cyberduck.core.cryptomator.SwiftDirectoryFeatureTest.java
@Test public void testMakeDirectoryEncrypted() throws Exception { final Host host = new Host(new SwiftProtocol(), "identity.api.rackspacecloud.com", new Credentials(System.getProperties().getProperty("rackspace.key"), System.getProperties().getProperty("rackspace.secret"))); final SwiftSession session = new SwiftSession(host); session.open(new DisabledHostKeyCallback()); session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback()); final Path home = new Path("/test.cyberduck.ch", EnumSet.of(Path.Type.volume, Path.Type.directory)); final Path vault = new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)); final Path test = new Path(vault, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)); final CryptoVault cryptomator = new CryptoVault(vault, new DisabledPasswordStore()); cryptomator.create(session, null, new VaultCredentials("test")); session.withRegistry(// w w w .java 2s . c o m new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator)); new CryptoDirectoryFeature<StorageObject>(session, new SwiftDirectoryFeature(session), new SwiftWriteFeature(session, new SwiftRegionService(session)), cryptomator).mkdir(test, null, new TransferStatus()); assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(test)); new CryptoDeleteFeature(session, new SwiftDeleteFeature(session), cryptomator) .delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback()); session.close(); }
From source file:ch.cyberduck.core.cryptomator.AzureTouchFeatureTest.java
@Test public void testTouchLongFilenameEncrypted() throws Exception { final Host host = new Host(new AzureProtocol(), "kahy9boj3eib.blob.core.windows.net", new Credentials(System.getProperties().getProperty("azure.account"), System.getProperties().getProperty("azure.key"))); final AzureSession session = new AzureSession(host); session.open(new DisabledHostKeyCallback()); session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback()); final Path home = new Path("cyberduck", EnumSet.of(Path.Type.volume, Path.Type.directory)); final CryptoVault cryptomator = new CryptoVault( new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new DisabledPasswordStore()); final Path vault = cryptomator.create(session, null, new VaultCredentials("test")); session.withRegistry(//from ww w .j a v a 2s .c o m new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator)); final Path test = new Path(vault, new RandomStringGenerator.Builder().build().generate(130), EnumSet.of(Path.Type.file)); new CryptoTouchFeature<Void>(session, new AzureTouchFeature(session, null), new AzureWriteFeature(session, null), cryptomator).touch(test, new TransferStatus()); assertTrue(new CryptoFindFeature(session, new AzureFindFeature(session, null), cryptomator).find(test)); new CryptoDeleteFeature(session, new AzureDeleteFeature(session, null), cryptomator) .delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback()); session.close(); }
From source file:ch.cyberduck.core.cryptomator.S3TouchFeatureTest.java
@Test public void testTouchEncrypted() throws Exception { final Host host = new Host(new S3Protocol(), new S3Protocol().getDefaultHostname(), new Credentials( System.getProperties().getProperty("s3.key"), System.getProperties().getProperty("s3.secret"))); final S3Session session = new S3Session(host); session.open(new DisabledHostKeyCallback()); session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback()); final Path home = new Path("test-us-east-1-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume)); final Path vault = new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)); final Path test = new Path(vault, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); final CryptoVault cryptomator = new CryptoVault(vault, new DisabledPasswordStore()); cryptomator.create(session, null, new VaultCredentials("test")); session.withRegistry(//from w w w. j a va 2 s . c o m new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator)); new CryptoTouchFeature<StorageObject>(session, new S3TouchFeature(session), new S3WriteFeature(session), cryptomator).touch(test, new TransferStatus()); assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(test)); new CryptoDeleteFeature(session, new S3DefaultDeleteFeature(session), cryptomator) .delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback()); session.close(); }
From source file:ch.cyberduck.core.sds.SDSListService.java
public AttributedList<Path> list(final Path directory, final ListProgressListener listener, final int chunksize) throws BackgroundException { final AttributedList<Path> children = new AttributedList<Path>(); try {// w w w . j a va 2s. c o m Integer offset = 0; final SDSAttributesFinderFeature feature = new SDSAttributesFinderFeature(session); NodeList nodes; do { nodes = new NodesApi(session.getClient()).getFsNodes( StringUtils.EMPTY, null, 0, Long.parseLong(new SDSNodeIdProvider(session) .getFileid(directory, new DisabledListProgressListener())), null, null, "name:asc", offset, chunksize); for (Node node : nodes.getItems()) { final PathAttributes attributes = feature.toAttributes(node); final EnumSet<AbstractPath.Type> type; switch (node.getType()) { case ROOM: type = EnumSet.of(Path.Type.directory, Path.Type.volume); if (node.getIsEncrypted()) { type.add(Path.Type.vault); } break; case FOLDER: type = EnumSet.of(Path.Type.directory); if (node.getIsEncrypted()) { type.add(Path.Type.decrypted); } break; default: type = EnumSet.of(Path.Type.file); if (node.getIsEncrypted()) { type.add(Path.Type.decrypted); } } final Map<String, String> custom = new HashMap<>(); if (null != node.getCntDownloadShares()) { custom.put(SDSAttributesFinderFeature.KEY_CNT_DOWNLOADSHARES, String.valueOf(node.getCntDownloadShares())); } if (null != node.getCntUploadShares()) { custom.put(SDSAttributesFinderFeature.KEY_CNT_UPLOADSHARES, String.valueOf(node.getCntUploadShares())); } attributes.setCustom(custom); final Path file = new Path(directory, node.getName(), type, attributes); children.add(file); listener.chunk(directory, children); } offset += chunksize; } while (nodes.getItems().size() == chunksize); } catch (ApiException e) { throw new SDSExceptionMappingService().map("Listing directory {0} failed", e, directory); } return children; }
From source file:com.seajas.search.contender.service.storage.StorageService.java
/** * Retrieve a CompositeEntry document by its ID. * * @param id// w w w . ja v a2s . co m * @return CompositeEntry */ public CompositeEntry retrieveEntryById(final ObjectId id) { CompositeEntry entry = mongoTemplate.findById(id, 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; }