public abstract class ServerResource extends java.lang.Object implements IServerResource
Implementations of interfaces that extend IServerResource should use this as a superclass unless there are good reasons not to.
Modifier and Type | Field and Description |
---|---|
protected boolean |
refreshable
Refreshable flag
|
protected IServer |
server
Server instance
|
protected boolean |
updateable
Updateable flag
|
Modifier | Constructor and Description |
---|---|
protected |
ServerResource()
Default constructor -- sets complete to true,
completable, refreshable, and updateable to false,
and server to null.
|
protected |
ServerResource(boolean refreshable,
boolean updateable)
Explicit some-value constructor; sets server to null.
|
protected |
ServerResource(boolean refreshable,
boolean updateable,
IServer server)
Explicit all-value constructor.
|
protected |
ServerResource(IServer server)
Sets complete to true, completable, refreshable, and
updateable to false, and server to the passed-in value.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canRefresh()
Returns true if the underlying object is refreshable from the Perforce
server.
|
boolean |
canUpdate()
Returns true if the underlying object can be updated back to (or on) the
associated Perforce server.
|
void |
clearRawFields()
Create new map and clear all fields.
|
void |
complete()
Old method called used to call refresh when completing a spec.
|
java.lang.Object |
getRawField(java.lang.String field)
Fetch a value from the raw spec map.
|
java.util.Map<java.lang.String,java.lang.Object> |
getRawFields()
Fetch the whole raw spec map.
|
boolean |
hasRawField(java.lang.String field)
Look for field in map.
|
protected java.util.Date |
parseDate(java.lang.String value) |
void |
refresh()
Refresh the underlying object from the Perforce server.
|
void |
setRawField(java.lang.String field,
java.lang.Object value)
Enter Key/Pair for a spec field.
|
void |
setRawFields(java.util.Map<java.lang.String,java.lang.Object> map)
Add all elements in a map to the spec
|
void |
setRefreshable(boolean refreshable)
Set the resource as refreshable
|
void |
setServer(IServer server)
Set the server associated with this resource.
|
protected java.lang.String |
toDateString(java.util.Date date) |
void |
update()
Update the Perforce server object associated with the underlying P4Java object,
if possible.
|
void |
update(boolean force)
Force (if true) update the Perforce server object associated with the underlying
P4Java object, if possible.
|
void |
update(Options opts)
Update the Perforce server object associated with the underlying P4Java object
and its options, if possible.
|
protected boolean refreshable
protected boolean updateable
protected IServer server
protected ServerResource()
protected ServerResource(IServer server)
server
- serverprotected ServerResource(boolean refreshable, boolean updateable)
refreshable
- refreshableupdateable
- updateableprotected ServerResource(boolean refreshable, boolean updateable, IServer server)
refreshable
- refreshableupdateable
- updateableserver
- serverpublic boolean canRefresh()
IServerResource
The details of what "refreshable" means in this context are always object-dependent, but typically mean that "live" data and metadata will be updated from the server. This is especially useful on objects like changelists, where the underlying server-side data may change often outside P4Java's control.
canRefresh
in interface IServerResource
IServerResource.canRefresh()
public boolean canUpdate()
IServerResource
canUpdate
in interface IServerResource
IServerResource.canUpdate()
public void complete() throws ConnectionException, RequestException, AccessException
IServerResource
complete
in interface IServerResource
ConnectionException
- when there is an error talking to the Helix serverRequestException
- when there is a problem with the data provided in the requestAccessException
- when access to the branch command is not authorisedIServerResource.complete()
public void refresh() throws ConnectionException, RequestException, AccessException
IServerResource
The details of what "refreshable" means in this context are always object-dependent, but typically mean that "live" data and metadata will be updated from the server.
The results of calling this method on objects whose canRefresh method returns false are undefined (but will generally result in a UnimplementedError being thrown).
refresh
in interface IServerResource
ConnectionException
- if the Perforce server is unreachable or is not
connected.RequestException
- if the Perforce server encounters an error during
its processing of the requestAccessException
- if the Perforce server denies access to the callerIServerResource.refresh()
public void update() throws ConnectionException, RequestException, AccessException
IServerResource
The results of calling this method on objects whose canUpdate method returns false are undefined (but will generally result in a UnimplementedError being thrown).
update
in interface IServerResource
ConnectionException
- if the Perforce server is unreachable or is not
connected.RequestException
- if the Perforce server encounters an error during
its processing of the requestAccessException
- if the Perforce server denies access to the callerIServerResource.update()
public void update(boolean force) throws ConnectionException, RequestException, AccessException
IServerResource
Note, in order to force the change it may require super user / admin privileges to work properly.
The results of calling this method on objects whose canUpdate method returns false are undefined (but will generally result in a UnimplementedError being thrown).
update
in interface IServerResource
force
- if true, force the update of the object on the server.ConnectionException
- if the Perforce server is unreachable or is not
connected.RequestException
- if the Perforce server encounters an error during
its processing of the requestAccessException
- if the Perforce server denies access to the callerIServerResource.update(boolean)
public void update(Options opts) throws ConnectionException, RequestException, AccessException
IServerResource
The results of calling this method on objects whose canUpdate method returns false are undefined (but will generally result in a UnimplementedError being thrown).
update
in interface IServerResource
opts
- Options object describing optional parameters; if null, no
options are set.ConnectionException
- if the Perforce server is unreachable or is not
connected.RequestException
- if the Perforce server encounters an error during
its processing of the requestAccessException
- if the Perforce server denies access to the callerIServerResource.update(com.perforce.p4java.option.Options)
public void setRefreshable(boolean refreshable)
refreshable
- true if refreshablepublic void setServer(IServer server)
IServerResource
setServer
in interface IServerResource
server
- IServer to be used for refresh, update, etc.IServerResource.setServer(com.perforce.p4java.server.IServer)
public java.lang.Object getRawField(java.lang.String field)
IServerResource
getRawField
in interface IServerResource
field
- spec fieldpublic void setRawField(java.lang.String field, java.lang.Object value)
IServerResource
setRawField
in interface IServerResource
field
- field kayvalue
- valuepublic boolean hasRawField(java.lang.String field)
IServerResource
hasRawField
in interface IServerResource
field
- field namepublic java.util.Map<java.lang.String,java.lang.Object> getRawFields()
IServerResource
getRawFields
in interface IServerResource
public void setRawFields(java.util.Map<java.lang.String,java.lang.Object> map)
IServerResource
setRawFields
in interface IServerResource
map
- field mappublic void clearRawFields()
IServerResource
clearRawFields
in interface IServerResource
protected java.util.Date parseDate(java.lang.String value)
protected java.lang.String toDateString(java.util.Date date)