本文整理汇总了Java中org.commcare.resources.model.ResourceLocation类的典型用法代码示例。如果您正苦于以下问题:Java ResourceLocation类的具体用法?Java ResourceLocation怎么用?Java ResourceLocation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ResourceLocation类属于org.commcare.resources.model包,在下文中一共展示了ResourceLocation类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadProfileIntoTable
import org.commcare.resources.model.ResourceLocation; //导入依赖的package包/类
protected void loadProfileIntoTable(ResourceTable table,
String profileRef,
int authority)
throws UnfullfilledRequirementsException,
UnresolvedResourceException,
InstallCancelledException {
Vector<ResourceLocation> locations = new Vector<ResourceLocation>();
locations.addElement(new ResourceLocation(authority, profileRef));
Resource r = new Resource(Resource.RESOURCE_VERSION_UNKNOWN,
CommCarePlatform.APP_PROFILE_RESOURCE_ID, locations,
"Application Descriptor");
table.addResource(r,
table.getInstallers().getProfileInstaller(false),
null);
prepareProfileResource(table);
}
示例2: getResourceName
import org.commcare.resources.model.ResourceLocation; //导入依赖的package包/类
@Override
public Pair<String, String> getResourceName(Resource r, ResourceLocation loc) {
int index = loc.getLocation().lastIndexOf("/");
if (index == -1) {
return new Pair<>(loc.getLocation(), ".dat");
}
String fileName = loc.getLocation().substring(index);
String extension = ".dat";
int lastDot = fileName.lastIndexOf(".");
if (lastDot != -1) {
extension = fileName.substring(lastDot);
fileName = fileName.substring(0, lastDot);
}
return new Pair<>(fileName, extension);
}
示例3: install
import org.commcare.resources.model.ResourceLocation; //导入依赖的package包/类
@Override
public boolean install(Resource r, ResourceLocation location,
Reference ref, ResourceTable table,
CommCarePlatform platform, boolean upgrade)
throws UnresolvedResourceException, UnfullfilledRequirementsException {
try {
OfflineUserRestore offlineUserRestore = OfflineUserRestore.buildInMemoryUserRestore(ref.getStream());
storage(platform).write(offlineUserRestore);
if (upgrade) {
table.commit(r, Resource.RESOURCE_STATUS_INSTALLED);
} else {
table.commit(r, Resource.RESOURCE_STATUS_UPGRADE);
}
cacheLocation = offlineUserRestore.getID();
} catch (IOException | XmlPullParserException | InvalidStructureException e) {
throw new UnresolvedResourceException(r, e.getMessage());
}
return true;
}
示例4: loadProfileIntoTable
import org.commcare.resources.model.ResourceLocation; //导入依赖的package包/类
protected void loadProfileIntoTable(ResourceTable table,
String profileRef,
int authority)
throws UnfullfilledRequirementsException,
UnresolvedResourceException,
InstallCancelledException {
Vector<ResourceLocation> locations = new Vector<>();
locations.addElement(new ResourceLocation(authority, profileRef));
Resource r = new Resource(Resource.RESOURCE_VERSION_UNKNOWN,
CommCarePlatform.APP_PROFILE_RESOURCE_ID, locations,
"Application Descriptor");
table.addResource(r,
table.getInstallers().getProfileInstaller(false),
null);
prepareProfileResource(table);
}
示例5: install
import org.commcare.resources.model.ResourceLocation; //导入依赖的package包/类
public boolean install(Resource r, ResourceLocation location, Reference ref, ResourceTable table, CommCareInstance instance, boolean upgrade) throws UnresolvedResourceException {
boolean result = super.install(r, location, ref, table, instance, upgrade);
if (result) {
table.commit(r, Resource.RESOURCE_STATUS_INSTALLED);
return true;
}
return false;
}
示例6: installAppResources
import org.commcare.resources.model.ResourceLocation; //导入依赖的package包/类
/**
* Installs resources described by profile reference into the provided
* resource table. If the resource table is ready or already has a profile,
* don't do anything.
*
* @param profileReference URL to profile file
* @param global Add profile ref to this table and install its
* resources
* @param forceInstall Should installation be performed regardless of
* version numbers?
*/
public static void installAppResources(CommCarePlatform platform, String profileReference,
ResourceTable global, boolean forceInstall)
throws UnfullfilledRequirementsException,
UnresolvedResourceException,
InstallCancelledException {
synchronized (updateLock) {
try {
if (!global.isReady()) {
global.prepareResources(null, platform);
}
// First, see if the appropriate profile exists
Resource profile =
global.getResourceWithId(CommCarePlatform.APP_PROFILE_RESOURCE_ID);
if (profile == null) {
// grab the local profile and parse it
Vector<ResourceLocation> locations = new Vector<ResourceLocation>();
locations.addElement(new ResourceLocation(Resource.RESOURCE_AUTHORITY_LOCAL, profileReference));
// We need a way to identify this version...
Resource r = new Resource(Resource.RESOURCE_VERSION_UNKNOWN,
CommCarePlatform.APP_PROFILE_RESOURCE_ID,
locations, "Application Descriptor");
global.addResource(r, global.getInstallers().getProfileInstaller(forceInstall), "");
global.prepareResources(null, platform);
}
} catch (StorageFullException e) {
e.printStackTrace();
}
}
}
示例7: parse
import org.commcare.resources.model.ResourceLocation; //导入依赖的package包/类
public Resource parse() throws InvalidStructureException, IOException, XmlPullParserException {
checkNode("resource");
String id = parser.getAttributeValue(null, "id");
int version = parseInt(parser.getAttributeValue(null, "version"));
String descriptor = parser.getAttributeValue(null, "descriptor");
Vector<ResourceLocation> locations = new Vector<ResourceLocation>();
while (nextTagInBlock("resource")) {
//New Location
String sAuthority = parser.getAttributeValue(null, "authority");
String location = parser.nextText();
int authority = Resource.RESOURCE_AUTHORITY_REMOTE;
if (sAuthority.toLowerCase().equals("local")) {
authority = Resource.RESOURCE_AUTHORITY_LOCAL;
} else if (sAuthority.toLowerCase().equals("remote")) {
authority = Resource.RESOURCE_AUTHORITY_REMOTE;
}
//Don't use any authorities which are outside of the scope of the maximum
if (authority >= maximumAuthority) {
locations.addElement(new ResourceLocation(authority, location));
}
}
return new Resource(version, id, locations, descriptor);
}
示例8: getResourceName
import org.commcare.resources.model.ResourceLocation; //导入依赖的package包/类
protected Pair<String, String> getResourceName(Resource r, ResourceLocation loc) {
String input = loc.getLocation();
String extension = "";
int lastDot = input.lastIndexOf(".");
if (lastDot != -1) {
extension = input.substring(lastDot);
}
return new Pair<>(r.getResourceId(), FileSystemUtils.extension(extension));
}
示例9: readExternal
import org.commcare.resources.model.ResourceLocation; //导入依赖的package包/类
@Override
public void readExternal(DataInputStream in, PrototypeFactory pf) throws IOException, DeserializationException {
this.recordId = ExtUtil.readInt(in);
this.version = ExtUtil.readInt(in);
this.id = ExtUtil.readString(in);
this.guid = ExtUtil.readString(in);
this.status = ExtUtil.readInt(in);
this.parent = ExtUtil.nullIfEmpty(ExtUtil.readString(in));
locations = (Vector<ResourceLocation>)ExtUtil.read(in, new ExtWrapList(ResourceLocation.class), pf);
this.initializer = (ResourceInstaller)ExtUtil.read(in, new ExtWrapTagged(), pf);
}
示例10: install
import org.commcare.resources.model.ResourceLocation; //导入依赖的package包/类
@Override
public boolean install(Resource r, ResourceLocation location, Reference ref, ResourceTable table, CommCarePlatform platform, boolean upgrade) throws UnresolvedResourceException {
boolean result = super.install(r, location, ref, table, platform, upgrade);
if (result) {
table.commit(r, Resource.RESOURCE_STATUS_INSTALLED);
return true;
}
return false;
}
示例11: installAppResources
import org.commcare.resources.model.ResourceLocation; //导入依赖的package包/类
/**
* Installs resources described by profile reference into the provided
* resource table. If the resource table is ready or already has a profile,
* don't do anything.
*
* @param profileReference URL to profile file
* @param global Add profile ref to this table and install its
* resources
* @param forceInstall Should installation be performed regardless of
* version numbers?
*/
public static void installAppResources(CommCarePlatform platform, String profileReference,
ResourceTable global, boolean forceInstall,
int authorityForProfile)
throws UnfullfilledRequirementsException,
UnresolvedResourceException,
InstallCancelledException {
synchronized (platform) {
if (!global.isReady()) {
global.prepareResources(null, platform);
}
// First, see if the appropriate profile exists
Resource profile =
global.getResourceWithId(CommCarePlatform.APP_PROFILE_RESOURCE_ID);
if (profile == null) {
// Create a stub for the profile resource that points to the authority and location
// from which we will install it
Vector<ResourceLocation> locations = new Vector<>();
locations.addElement(new ResourceLocation(authorityForProfile, profileReference));
Resource r = new Resource(Resource.RESOURCE_VERSION_UNKNOWN,
CommCarePlatform.APP_PROFILE_RESOURCE_ID,
locations, "Application Descriptor");
global.addResource(r, global.getInstallers().getProfileInstaller(forceInstall), "");
global.prepareResources(null, platform);
}
}
}
示例12: parse
import org.commcare.resources.model.ResourceLocation; //导入依赖的package包/类
@Override
public Resource parse() throws InvalidStructureException, IOException, XmlPullParserException {
checkNode("resource");
String id = parser.getAttributeValue(null, "id");
int version = parseInt(parser.getAttributeValue(null, "version"));
String descriptor = parser.getAttributeValue(null, "descriptor");
Vector<ResourceLocation> locations = new Vector<>();
while (nextTagInBlock("resource")) {
//New Location
String sAuthority = parser.getAttributeValue(null, "authority");
String location = parser.nextText();
int authority = Resource.RESOURCE_AUTHORITY_REMOTE;
if (sAuthority.toLowerCase().equals("local")) {
authority = Resource.RESOURCE_AUTHORITY_LOCAL;
} else if (sAuthority.toLowerCase().equals("remote")) {
authority = Resource.RESOURCE_AUTHORITY_REMOTE;
}
//Don't use any authorities which are outside of the scope of the maximum
if (authority >= maximumAuthority) {
locations.addElement(new ResourceLocation(authority, location));
}
}
return new Resource(version, id, locations, descriptor);
}
示例13: install
import org.commcare.resources.model.ResourceLocation; //导入依赖的package包/类
@Override
public abstract boolean install(Resource r, ResourceLocation location, Reference ref, ResourceTable table, CommCarePlatform platform, boolean upgrade) throws UnresolvedResourceException, UnfullfilledRequirementsException;
示例14: install
import org.commcare.resources.model.ResourceLocation; //导入依赖的package包/类
public abstract boolean install(Resource r, ResourceLocation location, Reference ref, ResourceTable table, CommCareInstance instance, boolean upgrade) throws UnresolvedResourceException, UnfullfilledRequirementsException;