Copy a folder with Smartsheet API - Java SDK 2.0.5 - smartsheet-api

I am trying to copy a folder with the Smartsheet API 2.0 (Java SDK 2.0.5).
Unfortunately the folders and sheets (all sub folders/sheets too) are copied but the sheet data is missing.
I get no errors everything works fine.
I tried several variants of the optional include parameters the ".ALL", "null", ...
This is the example code and the used environment:
Netbeans IDE 8.2
smartsheet-sdk-java-2.0.5.jar (with maven)
// Optional params
EnumSet includes = EnumSet.complementOf(EnumSet.of(FolderCopyInclusion.ALL)); // Copy all fields!
EnumSet skipRemap = EnumSet.noneOf(FolderRemapExclusion.class); // Remap all fields
// Specify destination.
ContainerDestination destination = new ContainerDestination.AddContainerDestinationBuilder()
.setDestinationType(DestinationType.FOLDER)
.setDestinationId(targetFolder.getId())
.setNewName(folder.getName())
.build();
smartsheet.folderResources().copyFolder(folder.getId(), destination, includes, skipRemap);
What am i doing wrong? Thanks a lot for your help.

Perhaps try changing this line:
EnumSet includes = EnumSet.complementOf(EnumSet.of(FolderCopyInclusion.ALL)); // Copy all fields!
To this instead:
EnumSet includes = EnumSet.of(FolderCopyInclusion.ALL);
(I'm not a Java expert, but the change I've suggested is consistent with the code example in the Smartsheet API Documentation.)

Related

How to read html files on Vapor with Leaf when not using the tau version?

There was a version of Leaf that I was using to load .html files instead of .leaf ones from my Vapor project, which would make syntax coloring for those same files done automatically.
The version of Leaf was 4.0.0-tau.1 and the one for LeafKit was 1.0.0-tau.1.1
When using this particular version, I could setup leaf in the configure.swift file this way:
/// Change the classic .leaf extension to .html for the syntax
/// coloring option of Xcode to work each time the app is being load up.
fileprivate func leaf(_ app: Application) {
if !app.environment.isRelease {
LeafRenderer.Option.caching = .bypass // Another issue from the update
}
let detected = LeafEngine.rootDirectory ?? app.directory.viewsDirectory
LeafEngine.rootDirectory = detected
LeafEngine.sources = .singleSource(
NIOLeafFiles(fileio: app.fileio,
limits: .default,
sandboxDirectory: detected,
viewDirectory: detected,
defaultExtension: "html"))
app.views.use(.leaf)
}
In this code, the LeafRenderer.Option.caching = .bypass and the code used with LeafEngine do not work anymore since having updated Leaf to 4.1.3 and LeafKit to 1.3.1.
How can I successfully make this code work as before with the updated Leaf and LeafKit frameworks?
You can use this Xcode plugin:
https://github.com/OmranK/VaporLeafPlugIn
It adds Vapor Leaf language support to Xcode IDE. Provides syntax highlighting for Leaf tags as well as HTML tags with auto-indentation all together.
At the moment the plugin supports Xcode up to 13.2 beta. Future Xcode versions will require small update (add new DVTPlugInCompatibilityUUID) but it can be easily handled even on already installed plugin.

Using Eclipse's JDT, how do I identify the classpath for a project?

I am writing a plug-in that will generate unit tests for a Java class that is selected in Eclipse's Project Explorer. This plug-in uses a third-party program called Randoop to generate the tests, so I make this happen using ProcessBuilder:
ProcessBuilder builder = new ProcessBuilder(command);
where the command that is passed to the ProcessBuilder is a list of Strings, something like
["java", "-classpath", "path1;path2;etc", "randoop.main.Main", ...]
Within the plug-in I am trying to generate the classpath for Randoop based on the classpath that Eclipse knows about. Here is some of what I have so far:
IClasspathEntry[] resolvedClasspath = javaProject.getResolvedClasspath(true);
for (IClasspathEntry entry : resolvedClasspath) {
if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
IPath outputLocation = entry.getOutputLocation();
if (outputLocation != null) {
buf.append(outputLocation.toString());
}
else {
buf.append(entry.getPath().toString());
}
}
else {
buf.append(entry.getPath().toString());
}
buf.append(CLASSPATH_SEP);
}
It isn't quite right. It seems to specify the library jar files okay, but doesn't do so well with identifying the paths to class files corresponding to CPE_SOURCE entries. For example, I see a classpath entry of /myPkgFragRoot/src/main/java instead of myPkgFragRoot/target/classes.
I seem to have a muddled picture of how Eclipse treats classpaths, so I'm looking for some help. Firstly, I'm wondering if my high-level approach is wrong. It seems like I am writing a large amount of code to generate an incorrect classpath. Is there some simpler way of getting a classpath from an IJavaProject than getting the results of getResolvedClasspath and iterating through them and manipulating the individual entries? Secondly, if there isn't a simpler way, how should I be locating the class files produced by building the project?
If the outputLocation is null, you have to use the default output location javaProject.getOutputLocation() instead of entry.getPath().
See Javadoc of IClasspathEntry.getOutputLocation():
Returns:
the full path [...], or null if using default output folder
If in Project > Properties: Java Build Path tab Source the check box Allow output folders for source folders is not checked, IClasspathEntry::getOutputLocation() will always return null.

Accessing Raw Gamer Profile Picture

I am using the new XBox Live API for C# (https://github.com/Microsoft/xbox-live-api-csharp) for official access through a UWP app.
I am able to authenticate fine and reference the XBox Live user in context.
SignInResult result = await user.SignInAsync();
XboxLiveUser user = new XboxLiveUser();
Success! However, I can't seem to find an appropriate API call to return XboxUserProfile or XboxSocialProfile. Both of these classes contain URLs to the player's raw gamer pics. After reviewing MSDN documentation and the GH library it isn't clear to me how this is achieved. Any help is greatly appreciated.
The below sample should work if you meet the following pre requisits:
Reference the Shared Project that contains the API from your project and don't reference the "Microsoft.Xbox.Services.UWP.CSharp" project
Copy all source code files from the "Microsoft.Xbox.Services.UWP.CSharp" project into your project
Include the Newtonsoft.Json NuGet package into your project
Steps 1 & 2 are important as this allows you to access the "internal" constructors which otherwise would be protected from you.
Code to retrieve the profile data:
XboxLiveUser user = new XboxLiveUser();
await user.SignInSilentlyAsync();
if (user.IsSignedIn)
{
XboxLiveContext context = new XboxLiveContext(user);
PeopleHubService peoplehub = new PeopleHubService(context.Settings, context.AppConfig);
XboxSocialUser socialuser = await peoplehub.GetProfileInfo(user, SocialManagerExtraDetailLevel.None);
// Do whatever you want to do with the data in socialuser
}
You may still run into an issue like I did. When building the project you may face the following error:
Error CS0103 The name 'UserPicker' does not exist in the current
context ...\System\UserImpl.cs 142 Active
If you get that error make sure you target Win 10.0 Build 14393.

QBO Queries and SpecifyOperatorOption

I'm trying to query QBO for, among other entities, Accounts, and am running into a couple of issues. I'm using the .Net Dev Kit v 2.1.10.0 (I used NuGet to update to the latest version) and when I use the following technique:
Intuit.Ipp.Data.Qbo.AccountQuery cquery = new Intuit.Ipp.Data.Qbo.AccountQuery();
IEnumerable<Intuit.Ipp.Data.Qbo.Account> qboAccounts = cquery.ExecuteQuery<Intuit.Ipp.Data.Qbo.Account>(context);
(i.e. just create a new AccountQuery of the appropriate type and call ExecuteQuery) I get an error. It seems that the request XML is not created properly, I just see one line in the XML file. I then looked at the online docs and tried to emulate the code there:
Intuit.Ipp.Data.Qbo.AccountQuery cquery = new Intuit.Ipp.Data.Qbo.AccountQuery();
cquery.CreateTime = DateTime.Now.Date.AddDays(-20);
cquery.SpecifyOperatorOption(Intuit.Ipp.Data.Qbo.FilterProperty.CreateTime,
Intuit.Ipp.Data.Qbo.FilterOperatorType.AFTER);
cquery.CreateTime = DateTime.Now.Date;
cquery.SpecifyOperatorOption(Intuit.Ipp.Data.Qbo.FilterProperty.CreateTime,
Intuit.Ipp.Data.Qbo.FilterOperatorType.BEFORE);
// Specify a Request validator
Intuit.Ipp.Data.Qbo.AccountQuery cquery = new Intuit.Ipp.Data.Qbo.AccountQuery();
IEnumerable<Intuit.Ipp.Data.Qbo.Account> qboAccounts = cquery.ExecuteQuery<Intuit.Ipp.Data.Qbo.Account>(context);
unfortunately, VS 2010 insists that AccountQuery doesn't contain a definition for SpecifyOperatorOption and there is no extension method by that name. So I'm stuck.
Any ideas how to resolve this would be appreciated.

How can I create a custom project layout based on another eclipse plugin?

My ultimate goal is to create an eclipse plugin that sets up a PDT project, but with some added builders (and custom build scripts) as well as a specific folder layout (and different folders should be treated as source and some as regular folders).
I've looked at / followed eclipse plugin development tutorials, and ok. I get the gist of creating a wizard that creates a file, but I'm having trouble trying to figure out how to create a project, and more importantly, make that project associated with the PDT (PHP Development Tools) feature.
Answer:
I did stumble upon a solution myself before the answer was given, but it's quite similar.
First, WizardNewProjectCreationPage was used as the first page of my wizard.
Second, on performFinish() I ran the following code:
IProgressMonitor m = new NullProgressMonitor();
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject project = root.getProject(_pageOne.getProjectName());
if (!project.exists())
{
IProjectDescription desc = project.getWorkspace().newProjectDescription(project.getName());
URI projectLocation = _pageOne.getLocationURI();
// desc.setLocationURI(projectLocation);
String[] natures = desc.getNatureIds();
String[] newNatures = new String[natures.length + 1];
System.arraycopy(natures, 0, newNatures, 0, natures.length);
newNatures[natures.length] = PHPNature.ID;
desc.setNatureIds(newNatures);
project.create(desc, m);
project.open(m);
}
how to create a project
Take a look at BasicNewProjectResourceWizard.createNewProject() method.
make that project associated with the PDT (PHP Development Tools) feature
You need to add "org.eclipse.php.core.PHPNature" to the project (that's what Add PHP Support... action does). Use IProjectDescription.setNatureIds().