Class ServerResource

java.lang.Object
com.perforce.p4java.impl.generic.core.ServerResource
All Implemented Interfaces:
IServerResource
Direct Known Subclasses:
BranchSpecSummary, ChangelistSummary, ClientSummary, Depot, ExtensionSummary, FileSpec, Fix, Job, JobSpec, LabelSummary, License, LicenseLimits, Repo, ServerIPMACAddress, ServerProcess, Streamlog, StreamSummary, UserGroup, UserSummary

public abstract class ServerResource extends Object implements IServerResource
Abstract implementation class for the IServerResource interface.

Implementations of interfaces that extend IServerResource should use this as a superclass unless there are good reasons not to.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
    Refreshable flag
    protected IServer
    Server instance
    protected boolean
    Updateable flag
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    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
    Sets complete to true, completable, refreshable, and updateable to false, and server to the passed-in value.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns true if the underlying object is refreshable from the Perforce server.
    boolean
    Returns true if the underlying object can be updated back to (or on) the associated Perforce server.
    void
    Create new map and clear all fields.
    void
    Old method called used to call refresh when completing a spec.
    Fetch a value from the raw spec map.
    Fetch the whole raw spec map.
    boolean
    Look for field in map.
    protected Date
     
    void
    Refresh the underlying object from the Perforce server.
    void
    setRawField(String field, Object value)
    Enter Key/Pair for a spec field.
    void
    Add all elements in a map to the spec
    void
    setRefreshable(boolean refreshable)
    Set the resource as refreshable
    void
    Set the server associated with this resource.
    protected String
     
    void
    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 the Perforce server object associated with the underlying P4Java object and its options, if possible.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • refreshable

      protected boolean refreshable
      Refreshable flag
    • updateable

      protected boolean updateable
      Updateable flag
    • server

      protected IServer server
      Server instance
  • Constructor Details

    • ServerResource

      protected ServerResource()
      Default constructor -- sets complete to true, completable, refreshable, and updateable to false, and server to null.
    • ServerResource

      protected ServerResource(IServer server)
      Sets complete to true, completable, refreshable, and updateable to false, and server to the passed-in value.
      Parameters:
      server - server
    • ServerResource

      protected ServerResource(boolean refreshable, boolean updateable)
      Explicit some-value constructor; sets server to null.
      Parameters:
      refreshable - refreshable
      updateable - updateable
    • ServerResource

      protected ServerResource(boolean refreshable, boolean updateable, IServer server)
      Explicit all-value constructor.
      Parameters:
      refreshable - refreshable
      updateable - updateable
      server - server
  • Method Details

    • canRefresh

      public boolean canRefresh()
      Description copied from interface: IServerResource
      Returns true if the underlying object is refreshable from the Perforce server.

      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.

      Specified by:
      canRefresh in interface IServerResource
      Returns:
      true if the underlying the object is refreshable.
      See Also:
    • canUpdate

      public boolean canUpdate()
      Description copied from interface: IServerResource
      Returns true if the underlying object can be updated back to (or on) the associated Perforce server. The semantics of server updates are generally object-specific.
      Specified by:
      canUpdate in interface IServerResource
      Returns:
      true if the underlying object can be updated back to (or on) the associated Perforce server
      See Also:
    • complete

      public void complete() throws ConnectionException, RequestException, AccessException
      Description copied from interface: IServerResource
      Old method called used to call refresh when completing a spec.
      Specified by:
      complete in interface IServerResource
      Throws:
      ConnectionException - when there is an error talking to the Helix server
      RequestException - when there is a problem with the data provided in the request
      AccessException - when access to the branch command is not authorised
      See Also:
    • refresh

      public void refresh() throws ConnectionException, RequestException, AccessException
      Description copied from interface: IServerResource
      Refresh the underlying object from the Perforce server.

      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).

      Specified by:
      refresh in interface IServerResource
      Throws:
      ConnectionException - if the Perforce server is unreachable or is not connected.
      RequestException - if the Perforce server encounters an error during its processing of the request
      AccessException - if the Perforce server denies access to the caller
      See Also:
    • update

      public void update() throws ConnectionException, RequestException, AccessException
      Description copied from interface: IServerResource
      Update the Perforce server object associated with the underlying P4Java object, if possible. The semantics of server updates are generally object-specific and will be spelled out for each participating object.

      The results of calling this method on objects whose canUpdate method returns false are undefined (but will generally result in a UnimplementedError being thrown).

      Specified by:
      update in interface IServerResource
      Throws:
      ConnectionException - if the Perforce server is unreachable or is not connected.
      RequestException - if the Perforce server encounters an error during its processing of the request
      AccessException - if the Perforce server denies access to the caller
      See Also:
    • update

      public void update(boolean force) throws ConnectionException, RequestException, AccessException
      Description copied from interface: IServerResource
      Force (if true) update the Perforce server object associated with the underlying P4Java object, if possible. The semantics of server updates are generally object-specific and will be spelled out for each participating object.

      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).

      Specified by:
      update in interface IServerResource
      Parameters:
      force - if true, force the update of the object on the server.
      Throws:
      ConnectionException - if the Perforce server is unreachable or is not connected.
      RequestException - if the Perforce server encounters an error during its processing of the request
      AccessException - if the Perforce server denies access to the caller
      See Also:
    • update

      public void update(Options opts) throws ConnectionException, RequestException, AccessException
      Description copied from interface: IServerResource
      Update the Perforce server object associated with the underlying P4Java object and its options, if possible. The semantics of server updates are generally object-specific and will be spelled out for each participating object.

      The results of calling this method on objects whose canUpdate method returns false are undefined (but will generally result in a UnimplementedError being thrown).

      Specified by:
      update in interface IServerResource
      Parameters:
      opts - Options object describing optional parameters; if null, no options are set.
      Throws:
      ConnectionException - if the Perforce server is unreachable or is not connected.
      RequestException - if the Perforce server encounters an error during its processing of the request
      AccessException - if the Perforce server denies access to the caller
      See Also:
    • setRefreshable

      public void setRefreshable(boolean refreshable)
      Set the resource as refreshable
      Parameters:
      refreshable - true if refreshable
    • setServer

      public void setServer(IServer server)
      Description copied from interface: IServerResource
      Set the server associated with this resource. Setting this null can have bad effects down the line...
      Specified by:
      setServer in interface IServerResource
      Parameters:
      server - IServer to be used for refresh, update, etc.
      See Also:
    • getRawField

      public Object getRawField(String field)
      Description copied from interface: IServerResource
      Fetch a value from the raw spec map.
      Specified by:
      getRawField in interface IServerResource
      Parameters:
      field - spec field
      Returns:
      valuse as an Object
    • setRawField

      public void setRawField(String field, Object value)
      Description copied from interface: IServerResource
      Enter Key/Pair for a spec field.
      Specified by:
      setRawField in interface IServerResource
      Parameters:
      field - field kay
      value - value
    • hasRawField

      public boolean hasRawField(String field)
      Description copied from interface: IServerResource
      Look for field in map.
      Specified by:
      hasRawField in interface IServerResource
      Parameters:
      field - field name
      Returns:
      true if field exists.
    • getRawFields

      public Map<String,Object> getRawFields()
      Description copied from interface: IServerResource
      Fetch the whole raw spec map.
      Specified by:
      getRawFields in interface IServerResource
      Returns:
      Spec Map
    • setRawFields

      public void setRawFields(Map<String,Object> map)
      Description copied from interface: IServerResource
      Add all elements in a map to the spec
      Specified by:
      setRawFields in interface IServerResource
      Parameters:
      map - field map
    • clearRawFields

      public void clearRawFields()
      Description copied from interface: IServerResource
      Create new map and clear all fields.
      Specified by:
      clearRawFields in interface IServerResource
    • parseDate

      protected Date parseDate(String value)
    • toDateString

      protected String toDateString(Date date)