当前位置: 首页>>代码示例>>Java>>正文


Java StoredObject.delete方法代码示例

本文整理汇总了Java中org.javaswift.joss.model.StoredObject.delete方法的典型用法代码示例。如果您正苦于以下问题:Java StoredObject.delete方法的具体用法?Java StoredObject.delete怎么用?Java StoredObject.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.javaswift.joss.model.StoredObject的用法示例。


在下文中一共展示了StoredObject.delete方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: delete

import org.javaswift.joss.model.StoredObject; //导入方法依赖的package包/类
@Override
public boolean delete(String hostName, Path path, boolean recursive) throws IOException {
  String obj = path.toString();
  if (path.toString().startsWith(hostName)) {
    obj = getObjName(hostName, path);
  }
  LOG.debug("Object name to delete {}. Path {}", obj, path.toString());
  try {
    StoredObject so = mJossAccount.getAccount().getContainer(container)
        .getObject(obj);
    if (so.exists()) {
      so.delete();
      objectCache.remove(obj);
    }
  } catch (Exception e) {
    LOG.warn(e.getMessage());
    LOG.warn("Delete on {} resulted in FileNotFound exception", path);
    return false;
  }
  return true;
}
 
开发者ID:SparkTC,项目名称:stocator,代码行数:22,代码来源:SwiftAPIClient.java

示例2: emptyContainer

import org.javaswift.joss.model.StoredObject; //导入方法依赖的package包/类
/**
 * {@inheritDoc}.
 */
@Override
public synchronized void emptyContainer(Container container, StopRequester stopRequester, SwiftCallback callback) {
	
	CheckAccount () ;
	
	try
	{
     for (StoredObject so : eagerFetchStoredObjects(container)) 
     {
     	if (!keepGoing (stopRequester, callback))
     		return ;
     	
     	if (so.exists())
     		so.delete();
         callback.onNumberOfCalls(account.getNumberOfCalls());
     }
     logger.info(String.format("Container %s has been emptied", container.getName()));
	}
	finally
	{
     reloadContainer(container, callback);
     callback.onNumberOfCalls(account.getNumberOfCalls());
	}
    
}
 
开发者ID:roikku,项目名称:swift-explorer,代码行数:29,代码来源:SwiftOperationsImpl.java

示例3: purgeContainer

import org.javaswift.joss.model.StoredObject; //导入方法依赖的package包/类
/**
 * {@inheritDoc}.
 */
@Override
public synchronized void purgeContainer(Container container, StopRequester stopRequester, SwiftCallback callback) {
	
	CheckAccount () ;
	
	try
	{
     for (StoredObject so : eagerFetchStoredObjects(container)) 
     {
     	if (!keepGoing (stopRequester, callback))
     		return ;
     	
     	if (so.exists())
     		so.delete();
         callback.onNumberOfCalls(account.getNumberOfCalls());
     }
     container.delete();
     logger.info(String.format("Container %s has been removed", container.getName()));
	}
	finally
	{
     callback.onUpdateContainers(eagerFetchContainers(account));
     callback.onNumberOfCalls(account.getNumberOfCalls());
	}
}
 
开发者ID:roikku,项目名称:swift-explorer,代码行数:29,代码来源:SwiftOperationsImpl.java

示例4: shouldCleanUpExtraSegments

import org.javaswift.joss.model.StoredObject; //导入方法依赖的package包/类
@Test
  public void shouldCleanUpExtraSegments() 
  {
  	uploadAndCheckSegmentedFile () ;
  	
  	StoredObject manifest = container.getObject(objName);
  	int initialSegmentCount = largeObjectManager.getSegmentsList(manifest).size() ;
  
  	// we delete the manifest only (so that the segments remain)
  	manifest.delete();
  	assertFalse (manifest.exists()) ;
  	
  	// We reduce the file size so that less segments are required
  	long newFileSize = fileSize / 2 ;
largeFile = null ;
  	uploadAndCheckSegmentedFile (newFileSize, segmentSize) ;
  	
  	// we verify that the actual number of segments is coherent
  	int newSegmentCount = largeObjectManager.getSegmentsList(container.getObject(objName)).size() ;
  	assertTrue (initialSegmentCount > newSegmentCount) ;
  	assertTrue (newSegmentCount == TestUtils.getNumberOfSegments (newFileSize, segmentSize)) ;
  }
 
开发者ID:roikku,项目名称:swift-explorer,代码行数:23,代码来源:LargeObjectManagerTest.java

示例5: cleanUpExtraSegments

import org.javaswift.joss.model.StoredObject; //导入方法依赖的package包/类
private void cleanUpExtraSegments (AbstractStoredObject obj, Set<StoredObject> toKeep)
{
	List<StoredObject> list =  getSegmentsList (obj) ;
	for (StoredObject so : list)
	{
		if (toKeep != null && toKeep.contains(so))
			continue ;
		logger.info("Delete unused segment ({})", so.getBareName()) ;
		so.delete(); 
	}
}
 
开发者ID:roikku,项目名称:swift-explorer,代码行数:12,代码来源:LargeObjectManagerImpl.java

示例6: deleteStoredObjects

import org.javaswift.joss.model.StoredObject; //导入方法依赖的package包/类
private void deleteStoredObjects(Container container, List<StoredObject> storedObjects, StopRequester stopRequester, boolean notify, SwiftCallback callback) {

       for (StoredObject storedObject : storedObjects) 
       {
       	if (!keepGoing (stopRequester, callback))
       		break ;
       	
		// segmented objects should be deleted as well
		if (largeObjectManager.isSegmented (storedObject))
		{				
			List<StoredObject> segments = largeObjectManager.getSegmentsList (storedObject) ;
			// we delete each segment, starting by the last one, so that if something
			// unexpected happen at the middle of the iteration, the getSegmentsList method
			// will still be able to get the list of the remaining segments. 
            ListIterator<StoredObject> segmentsIter = segments.listIterator(segments.size()) ;
			while (segmentsIter.hasPrevious()) 
			{
				StoredObject segment = segmentsIter.previous() ;
				if (segment == null || !segment.exists())
					continue ;
				logger.info("Deleting segment " + segment.getPath());
				segment.delete();
			}
		}
		if (storedObject.exists())
		{
			storedObject.delete();
			logger.info("Deleted object: " + storedObject.getName());
		}
		else
		{
			logger.debug("Attempt at deleting a non-existing object: " + storedObject.getName());
			continue ;
		}
		if (notify)
			callback.onStoredObjectDeleted(container, storedObject);
       }
       callback.onNumberOfCalls(account.getNumberOfCalls());
}
 
开发者ID:roikku,项目名称:swift-explorer,代码行数:40,代码来源:SwiftOperationsImpl.java

示例7: DeleteObject

import org.javaswift.joss.model.StoredObject; //导入方法依赖的package包/类
public static void DeleteObject(String username,String passwod,String dataNode, String container, String key)throws Exception {
	try {
		Account client = ViPRSwiftClient(username, passwod, dataNode);
		Container myContainer = client.getContainer(container);
		StoredObject object = myContainer.getObject(key);
		object.delete();

	} catch (Exception e) {
		System.out.println("error during delete " + key);
		e.printStackTrace();
	}
}
 
开发者ID:thecodeteam,项目名称:VStriker,代码行数:13,代码来源:swiftapi.java

示例8: DeleteObject

import org.javaswift.joss.model.StoredObject; //导入方法依赖的package包/类
public static void DeleteObject(String username,String passwod,String dataNode, String container, String key)throws Exception
{
	
	Account client= ViPRSwiftClient(username, passwod, dataNode);
	Container myContainer=client.getContainer(container);
	StoredObject object = myContainer.getObject(key);
    object.delete();
}
 
开发者ID:thecodeteam,项目名称:VStriker,代码行数:9,代码来源:swiftapi.java

示例9: delete

import org.javaswift.joss.model.StoredObject; //导入方法依赖的package包/类
@Override
public boolean delete(String contentUrl) {
	StoredObject object = this.container.getObject(contentUrl);
	object.delete();
	return true;
}
 
开发者ID:jeci-sarl,项目名称:alfresco-object-storage-connectors,代码行数:7,代码来源:SwiftServiceImpl.java

示例10: example

import org.javaswift.joss.model.StoredObject; //导入方法依赖的package包/类
private static void example() {
  // Create a Connection
  AccountConfig config = new AccountConfig();
  config.setUsername(username);
  config.setPassword(password);
  config.setAuthUrl(authUrl);
  config.setAuthenticationMethod(AuthenticationMethod.BASIC);
  Account account = new AccountFactory(config).createAccount();

  // Create a Container
  Container container = account.getContainer("my-new-container");
  container.create();

  // Create an Object
  StoredObject object = container.getObject("foo.txt");
  object.uploadObject(new File("src/test/resources/foo.txt"));

  // Add/Update Object Metadata
  Map<String, Object> metadata = new TreeMap<String, Object>();
  metadata.put("key", "value");
  object.setMetadata(metadata);

  // List Owned Containers
  Collection<Container> containers = account.list();
  for (Container currentContainer : containers) {
    System.out.println(currentContainer.getName());
  }

  // List a Container's Content
  Collection<StoredObject> objects = container.list();
  for (StoredObject currentObject : objects) {
    System.out.println(currentObject.getName());
  }

  // Retrieve an Object's Metadata
  Map<String, Object> returnedMetadata = object.getMetadata();
  for (String name : returnedMetadata.keySet()) {
    System.out.println("META / " + name + ": " + returnedMetadata.get(name));
  }

  // Retrieve an Object
  object.downloadObject(new File("/tmp/outfile.txt"));

  // Delete an Object
  object.delete();

  // Delete a Container
  container.delete();
}
 
开发者ID:twonote,项目名称:radosgw-admin4j,代码行数:50,代码来源:SwiftExample.java

示例11: shouldFindFilesDifferences

import org.javaswift.joss.model.StoredObject; //导入方法依赖的package包/类
public void shouldFindFilesDifferences (FindFilesDifferencesTestScenario scenario)
  {
  	Container container = account.getContainer("x").create() ;
  	final String fileName = "myFile" ;
try 
{
	File local = TestUtils.getTestFile(tmpFolder, fileName, 100) ;
	ops.uploadFiles(container, null, new File[]{local} , true, stopRequester, callback);
	StoredObject remote = container.getObject(fileName) ;
	assertTrue (remote.exists()) ;
	
	switch (scenario)
	{
	case MISSING_LOCAL:
		{
			assertTrue (local.delete()) ;
		}
		break;
	case MISSING_REMOTE:
		{
			remote.delete();
			assertFalse (remote.exists()) ;
		}
		break ;
	case MODIFIED_FILE:
		{
			// we modify the file
	    	FileOutputStream out = new FileOutputStream(local);
	      	out.write(new byte[]{'a', 'b', 'c', 'd', 'e'});
	    	out.close();
		}
		break;
	case NO_DIFF:
		break;
       default:
       	throw new IllegalStateException () ;
	}

   	@SuppressWarnings("unchecked")
   	ResultCallback<Collection<Pair<? extends ComparisonItem, ? extends ComparisonItem> > > resultCallback 
   	 	= (ResultCallback<Collection<Pair<? extends ComparisonItem, ? extends ComparisonItem> > >)Mockito.mock(ResultCallback.class) ;
   	
   	@SuppressWarnings({ "unchecked", "rawtypes" })
	ArgumentCaptor<Collection<Pair<? extends ComparisonItem, ? extends ComparisonItem> > > argument = ArgumentCaptor.forClass((Class) ResultCallback.class);
   	
   	ops.findDifferences(container, remote, local, resultCallback, stopRequester, callback);
   	
   	Mockito.verify(resultCallback, Mockito.times(1)).onResult(argument.capture());
   	
   	assertTrue ((scenario == FindFilesDifferencesTestScenario.NO_DIFF) ? (argument.getValue().isEmpty()) : (!argument.getValue().isEmpty())) ;
} 
catch (IOException e) {
      	logger.error ("Error occurred in shouldFindFilesDifferences", e) ;
      	assertFalse(true) ;
}
  }
 
开发者ID:roikku,项目名称:swift-explorer,代码行数:57,代码来源:SwiftOperationsTest.java


注:本文中的org.javaswift.joss.model.StoredObject.delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。