Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.javaswift.joss.client.core;
  
 
 
 public abstract class AbstractContainer extends AbstractObjectStoreEntity<ContainerInformationimplements Container {
 
     public static final Logger LOG = LoggerFactory.getLogger(UploadInstructions.class);
 
     private static final Integer MAX_PAGE_SIZE = 9999;
 
     protected final String name;
 
     private final Account account;
 
     private final ContainerCommandFactory commandFactory;
 
     private Collection<HeadercustomHeaders;
 
     public AbstractContainer(Account accountString nameboolean allowCaching) {
         super(allowCaching);
         this. = ((AbstractAccount)account).getFactory().getContainerCommandFactory();
         this. = name;
         this. = account;
         this. = new ContainerInformation();
     }
 
     public Collection<StoredObjectlist() {
         return new ContainerPaginationMap(thisnull).listAllItems();
     }
 
     public Collection<StoredObjectlist(PaginationMap paginationMapint page) {
         return list(paginationMap.getPrefix(), paginationMap.getMarker(page), paginationMap.getPageSize());
     }
 
     public Collection<StoredObjectlist(String prefixString markerint pageSize) {
         ListInstructions listInstructions = new ListInstructions()
                 .setPrefix(prefix)
                 .setMarker(marker)
                 .setLimit(pageSize);
         return .createListObjectsCommand(getAccount(), thislistInstructions).call();
     }
 
     @Override
     public Collection<DirectoryOrObjectlistDirectory(String prefixCharacter delimiterString markerint pageSize) {
         ListInstructions listInstructions = new ListInstructions()
                 .setPrefix(prefix)
                 .setDelimiter(delimiter)
                 .setMarker(marker)
                 .setLimit(pageSize);
         return .createListDirectoryCommand(getAccount(), thislistInstructions.getDelimiter()).call();
     }
 
     @Override
     public Collection<DirectoryOrObjectlistDirectory(Directory directory) {
         return new ContainerDirectoryPaginationMap(this.getDelimiter(), directory == null ? null : directory.getName(), ).listAllItems();
     }
 
     @Override
         return listDirectory(null);
     }
 
     public void metadataSetFromHeaders() {
         this. = false;
     }
 
     public PaginationMap getPaginationMap(String prefixint pageSize) {
         return new ContainerPaginationMap(thisprefixpageSize).buildMap();
     }
 
     public PaginationMap getPaginationMap(int pageSize) {
         return getPaginationMap(nullpageSize);
     }
 
     public StoredObject getObjectSegment(String nameint part) {
         return getObject(name + "/" + String.format("%08d"part));
     }
 
     public int getCount() {
        return .getObjectCount();
    }
    public long getBytesUsed() {
        return .getBytesUsed();
    }
    @Override
    public FormPost getFormPost(String redirectlong maxFileSizelong maxFileCountlong seconds) {
        String path = .getTempUrlPrefix() + getPath();
        long expires = getAccount().getActualServerTimeInSeconds(seconds);
        String plainText =
                path+"\n"+
                redirect+"\n"+
                maxFileSize+"\n"+
                maxFileCount+"\n"+
                expires;
        FormPost formPost = new FormPost();
        formPost.expires = expires;
        formPost.signature = HashSignature.getSignature(getAccount().getHashPassword(), plainText);
        return formPost;
    }
    public void setCount(int count) {
        .setObjectCount(new ContainerObjectCount(Integer.toString(count)));
    }
    public void setBytesUsed(long bytesUsed) {
        .setBytesUsed(new ContainerBytesUsed(Long.toString(bytesUsed)));
    }
    public boolean isPublic() {
        checkForInfo();
        return .isPublicContainer();
    }
    
        checkForInfo();
        return .getReadPermissions();
    }
        checkForInfo();
        return .getWritePermissions();
    }
    public String getName() {
        return ;
    }
    public Account getAccount() {
        return ;
    }
    public int hashCode() {
        return getName().hashCode();
    }
    @SuppressWarnings("ConstantConditions")
    public boolean equals(Object o) {
        return o instanceof Container && getName().equals(((Containero).getName());
    }
    @SuppressWarnings("ConstantConditions")
    public int compareTo(Container o) {
        return getName().compareTo(o.getName());
    }
    protected Metadata createMetadataEntry(String nameString value) {
        return new ContainerMetadata(namevalue);
    }
    public void uploadSegmentedObjects(String nameUploadInstructions uploadInstructions) {
        String path = getName()+"/"+name;
        try {
            .info("JOSS / Setting up a segmentation plan for "+path);
            SegmentationPlan plan = uploadInstructions.getSegmentationPlan();
            InputStream segmentStream = plan.getNextSegment();
            while (segmentStream != null) {
                .info("JOSS / Uploading segment "+plan.getSegmentNumber());
                StoredObject segment = getObjectSegment(nameplan.getSegmentNumber().intValue());
                segment.uploadObject(segmentStream);
                segmentStream.close();
                segmentStream = plan.getNextSegment();
            }
        } catch (IOException err) {
            .error("JOSS / Failed to set up a segmentation plan for "+path+": "+err.getMessage());
            throw new CommandException("Unable to upload segments"err);
        }
    }
    public int getMaxPageSize() {
        return ;
    }
        return this.;
    }
    public void makePublic() {
        setContainerRights(true);
    }
    public void makePrivate() {
        setContainerRights(false);
    }
    public void setContainerRights(boolean publicContainer) {
        .createContainerRightsCommand(getAccount(), thispublicContainer).call();
        this..setPublicContainer(publicContainer);
    }
    
    public void setContainerRights(String writePermissionsString readPermissions) {
        .createContainerRightsCommand(getAccount(), thiswritePermissionsreadPermissions).call();
        this..setWritePermissions(writePermissions);
        this..setReadPermissions(readPermissions);
    }
    public Container create() {
        return this;
    }
    public void delete() {
    }
    @Override
    protected void saveSpecificMetadata() {
    }
    protected void getInfo(boolean allowErrorLog) {
        this. = .createContainerInformationCommand(getAccount(), thisallowErrorLog).call();
        this.setInfoRetrieved();
    }
    @Override
        return "/" + SpaceURLEncoder.encode(getName());
    }
    @Override
    public void setCustomHeaders(Collection<Headerheaders) {
         = headers;
    }
    @Override
    public Collection<HeadergetCustomHeaders() {
        return ;
    }
    
New to GrepCode? Check out our FAQ X